Mitsubishi Electric MELSEC iQ-F Series Programming Manual
Mitsubishi Electric MELSEC iQ-F Series Programming Manual

Mitsubishi Electric MELSEC iQ-F Series Programming Manual

Instructions, standard functions/function blocks
Hide thumbs Also See for MELSEC iQ-F Series:
Table of Contents

Advertisement

Quick Links

MELSEC iQ-F
FX5 Programming Manual
(Instructions, Standard Functions/Function Blocks)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MELSEC iQ-F Series and is the answer not in the manual?

Questions and answers

Summary of Contents for Mitsubishi Electric MELSEC iQ-F Series

  • Page 1 MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/Function Blocks)
  • Page 3: Safety Precautions

    This manual describes the instructions and functions/function blocks required for programming MELSEC iQ-F series systems. This manual and the related manuals should be read and the functions and performance of the MELSEC iQ-F series PLC should be understood before attempting to use the unit.
  • Page 4: Table Of Contents

    CONTENTS SAFETY PRECAUTIONS ..............1 INTRODUCTION .
  • Page 5 CHAPTER 5 STANDARD FUNCTIONS/FUNCTION BLOCKS Standard Functions..............100 Type conversion functions .
  • Page 6 Shifting n-bit data to the right by 1 bit ............165 Shifting n-bit data to the left by 1 bit .
  • Page 7 Decrementing 32-bit binary data ............279 Logical Operation Instructions .
  • Page 8 Two's complement of 16-bit binary data (sign inversion)......... . 370 Two's complement of 32-bit binary data (sign inversion).
  • Page 9 Forcibly terminating the FOR to NEXT instruction loop......... . . 458 Calling a subroutine program .
  • Page 10 Single-precision real number data band comparison ..........663 Adding single-precision real numbers .
  • Page 11 8.14 Special Timer Instruction ..............769 Teaching timer .
  • Page 12 Writing clock data ............... 894 Adding clock data .
  • Page 13 PART 4 MODULE DEDICATED INSTRUCTION CHAPTER 12 NETWORK COMMON INSTRUCTION 12.1 Link Dedicated Instructions ............. . 988 Reading data from another station programmable controller .
  • Page 14 16.2 High-speed Current Value Transfer Instruction ..........1108 High-speed current value transfer of 16-bit data .
  • Page 15 20.4 Converting BOOL to DINT ............. . 1210 20.5 Converting BOOL to TIME .
  • Page 16 20.55 Writing the Specified Bit of Word Label ........... 1282 20.56 Copying the Specified Bit of Word Label .
  • Page 17 27.4 Link Character Strings ..............1345 27.5 Inserting Character String .
  • Page 18: Relevant Manuals

    RELEVANT MANUALS Manual name <manual number> Description MELSEC iQ-F FX5 Programming Manual (Program Design) Describes the specifications of ladder, ST, FBD/LD, and SFC programs, and <JY997D55701> labels. MELSEC iQ-F FX5 Programming Manual (Instructions, Standard Functions/ Describes the specifications of instructions and functions that can be used Function Blocks) in programs.
  • Page 19: How To Read This Manual

    HOW TO READ THIS MANUAL The following describes the page layout and symbols used in this manual. How to read PART 3 and PART 4 The contents described in this section are provided only for explaining how to read this manual. Thus, the actual description may differ.
  • Page 20: Specification

    Indicates the instruction symbol. • The instruction symbol with brackets means multiple instructions. For example, "GRY(P)(_U)" means the GRY, GRYP, GRY_U, and GRYP_U instructions. Instruction symbol Description of symbol Instruction symbol with "(P)" The instruction is executed on the rising edge. Instruction symbol with "(_U)"...
  • Page 21 How to read PART 5 and PART 6 The contents described in this section are provided only for explaining how to read this manual. Thus, the actual description may differ. Ò Ó Ô Õ Ö × Indicates function symbols. When character strings in brackets are added to the end of the function symbol for standard functions and function blocks, the function symbol indicates multiple functions.
  • Page 22 Indicates an error code which occurs at the execution and the error description when the standard function or the function block has a specific operation error. A device in which an error code is stored is described in the error code column. When an error code is stored in SD0, the error flag SM0 turns on.
  • Page 23: Part 1 Overview

    PART 1 OVERVIEW Part 1 consists of the following chapter. 1 OVERVIEW 2 PRECAUTIONS ON PROGRAMMING...
  • Page 24: Instruction Configuration

    OVERVIEW Instruction Configuration Many instructions available for CPU module are each divided into the instruction part and device part. The instruction part and device part are used as follows. • Instruction part: Indicates the function of the relevant instruction. • Device part: Indicates the data used for the instruction. The device part is further classified to source data, destination data, and numerical data.
  • Page 25: Data Specification Method

    Be careful when a large numerical value is used such as for the number of transfers. It delays the scan time. Data Specification Method The following table lists the types of data that can be used for instructions in CPU modules. Data Classification Bit data...
  • Page 26 Label data Primitive data type Data type (label) Specifiable label • Bit type label (BOOL) • Bit-specified word [unsigned]/bit string [16 bits] type label • Bit-specified word [signed] type label • Timer/retentive timer type label contact/coil • Counter/ long counter type label contact/coil Word [unsigned]/bit string [16 bits] •...
  • Page 27 Generic data type Data type (label) Specifiable label Bit, word [signed], double word [signed], word [unsigned]/bit string [16 bits], double word [unsigned]/bit string[32 bits], single-precision real number, hour, character string, structure ANY_BITADDR ANY_BOOL ANY_ELEMENTARY Bit, word [signed], double word [signed], word [unsigned]/bit string [16 bits], double word [unsigned]/bit string[32 bits], single-precision real number, hour, character string ANY_WORDADDR Word [signed], double word [signed], word [unsigned]/bit string [16 bits], double word [unsigned]/bit string[32 bits],...
  • Page 28: Bit Data

    Bit data Data size and data range Bit data is handled in increments of bits such as contacts and coils. Data name Data size Value range Bit data 1 bit 0, 1 Handling bit data with bit devices and labels Bit data of one point per point can be handled.
  • Page 29: 16-Bit Data (Word Data)

    16-bit data (word data) Data size and data range 16-bit data includes signed and unsigned 16-bit data. In signed 16-bit data, a negative number is represented in two's complement. Data name Data size Value range Decimal notation Hexadecimal notation Signed 16-bit data 16 bits (1 word) -32768 to 32767 0000H to FFFFH...
  • Page 30 Digit specification range The following table lists the range of 16-bit data for each digit specification. Digit Decimal notation Hexadecimal notation specification 0 to 15 0H to FH 0 to 255 00H to FFH 0 to 4095 000H to FFFH Signed 16-bit data: -32768 to 32767 0000H to FFFFH Unsigned 16-bit data: 0 to 65535...
  • Page 31: 32-Bit Data (Double Word Data)

    Handling 16-bit data with word devices/labels Word device One point of word device can handle 16-bit data. Word type label One point of word type label can handle 16-bit data. 32-bit data (double word data) Data size and data range 32-bit data includes signed and unsigned 32-bit data.
  • Page 32 Digit specification range The following table lists the range of 32-bit data for each digit specification. Digit Decimal notation Hexadecimal notation specification 0 to 15 0H to FH 0 to 255 00H to FFH 0 to 4095 000H to FFFH 0 to 65535 0000H to FFFFH 0 to 1048575...
  • Page 33 Specifying a bit device with digit specification in the source (s) When a bit device with digit specification is specified in the source of an instruction, 0 is stored in the bits, which follow the bit for which digit specification is made in the source, in the word device of the destination. Ladder example Processing •...
  • Page 34: Real Number Data (Floating-Point Data)

    Real number data (floating-point data) Data size and data range Real number data includes single-precision 32-bit real number data. Real number data can be stored only in devices other than bit devices or in single-precision real data type labels. Data name Data size Value range -126...
  • Page 35: Character String Data

    The monitor function of the engineering tool can monitor real number data of CPU modules. To represent "0" in real number data, set all numbers in each of the following range to 0. • Single-precision real number data: b0 to b31 The setting range of real number data is as follows.
  • Page 36: Data Range

    Data range The following table summarizes the ranges of character string data. Type Maximum number of character strings Maximum number of character strings that can be handled in the program Character string 255 single-byte characters (excluding the last NULL 16383 characters (excluding the last NULL character) character) Unicode character string 255 characters (NULL at the end is not included.)
  • Page 37: Execution Condition

    Execution Condition Types of execution conditions The following are the five types of execution conditions of the instructions and functions of CPU module. Execution condition Description An instruction is executed during on. It is executed only while the precondition of the instruction is on. When the precondition is off, the instruction is not executed.
  • Page 38: Acceleration Of Instruction Processing Time

    Acceleration of Instruction Processing Time High-speed instruction In some instructions, when the device and label specified in each operand satisfy the specific condition, the instruction processing time is accelerated. Such accelerated instructions are called high-speed instructions. The instructions capable of accelerating and the conditions of acceleration The table below shows the instructions capable of accelerating and the conditions of acceleration (conditions of non- acceleration).
  • Page 39 Classification Instruction symbol Conditions of non-acceleration Arithmetic operation instruction + (2 operands), +_U (2 operands), + (3 operands), +_U • When indexing is executed (3 operands), - (2 operands), -_U (2 operands), - (3 • When link register (W) is specified, the number of points of operands), -_U (3 operands), D+ (2 operands), D+_U file register (R) + the number of link register (W) >...
  • Page 40 Execution time of high-speed instruction For execution time of high-speed instruction, refer to the following. Page 1392 Instruction Processing Time 1 OVERVIEW 1.4 Acceleration of Instruction Processing Time...
  • Page 41: Chapter 2 Precautions On Programming

    PRECAUTIONS ON PROGRAMMING Errors Common to Instructions The following table lists the conditions under which an error occurs when the instruction is executed. Error content Error code (SD0/SD8067) An I/O number which corresponds to no module is specified. 2801H • An I/O number which is out of range (0 to 1777 (Octal number)) is specified. 2820H •...
  • Page 42: Operations Arising When The Out, Set/Rst, And Pls/Plf Instructions Of The Same Device Are Used

    Operations Arising when the OUT, SET/RST, and PLS/PLF Instructions of the Same Device are Used If two or more OUT, SET/RST, and PLS/PLF instructions are executed using the same device during one scan, they operate as described in this section. For OUT instructions of the same device More than one OUT instruction of the same device must not be issued during one scan.
  • Page 43 If SET/RST instructions of the same device are used For SET instructions The SET instruction turns on the specified device if the execution command is on, and causes no operation if it is off. Thus, if two or more SET instructions of the same device are executed during one scan, the specified device turns on even if one execution command is on.
  • Page 44 If PLS instructions of the same device are used The PLS instruction turns on the specified device when the execution command specifies an off-to-on change. The specified device is turned off unless the execution command specifies an off-to-on change (i.e. off to off, on to on, on to off). Thus, if two or more PLS instructions of the same device are issued during one scan, the specified device is turned on when the execution command of each PLS instruction specifies an off-to-on change.
  • Page 45 • If the off-to-on changes of X0 and X1 are at the same timing PLS M0 PLS M0 PLS M0 (1) Since X0 turns on, M0 turns on. (2) Since X1 turns on, M0 remains on. (3) Since X0 is other than turning on, M0 turns off. (4) Since X1 is other than turning on, M0 remains off.
  • Page 46 If PLF instructions of the same device are used The PLF instruction turns on the specified device when the execution command specifies an on-to-off change. The specified device is turned off unless the execution command specifies an on-to-off change (i.e. off to off, off to on, on to on). Thus, if two or more PLF instructions of the same device are issued during one scan, the specified device is turned on when the execution command of each PLF instruction specifies an on-to-off change.
  • Page 47: Handling General Flags

    • If the on-to-off changes of X0 and X1 are at the same timing PLF M0 PLF M0 PLF M0 (1) Since X0 turns off, M0 turns on. (2) Since X1 turns off, M0 remains on. (3) Since X0 is other than turning off, M0 turns off. (4) Since X1 is other than turning off, M0 remains off.
  • Page 48 Program containing many flags (example of SM8029 (Instruction execution complete flag)) When two or more SM8029 (Instruction execution complete flag) are programmed together for instructions which operate the same flag, it is difficult to determine which instruction executes which flag. Also, the flag corresponding to each instruction cannot be read normally.
  • Page 49: Standard Function/Function Block Return Values

    Method for using flags in any positions other than directly under instructions (example of SM8029 (Instruction execution complete flag)) When two or more instructions are programmed, general flags turn ON or OFF when each instruction turns ON. Accordingly, when using a flag in any position other than directly under an instruction, set another device to ON or OFF just under the instruction, and then use the contact of the device as the command input.
  • Page 50 MEMO 2 PRECAUTIONS ON PROGRAMMING 2.5 Standard Function/Function Block Return Values...
  • Page 51: Part 2 Instruction/Function List

    PART 2 INSTRUCTION/ FUNCTION LIST This part consists of the following chapters. 3 CPU MODULE INSTRUCTION 4 MODULE SPECIFIC INSTRUCTION 5 STANDARD FUNCTIONS/FUNCTION BLOCKS...
  • Page 52: Chapter 3 Cpu Module Instruction

    CPU MODULE INSTRUCTION Sequence Instruction Contact instruction Operation start, series connection, parallel connection Instruction symbol Description Reference Starts logical operation (Starts NO contact logical operation) Page 114 Starts logical NOT operation (Starts NC contact logical operation) Logical AND (NO contact series connection) Logical NAND (NC contact series connection) Logical OR (NO contact parallel connection) Logical NOR (NC contact parallel connection)
  • Page 53 Converting the operation result into a pulse Instruction symbol Description Reference Conversion of operation result to rising edge pulse Page 129 Conversion of operation result to falling edge pulse Output instruction Out (excluding the timer, counter and annunciator) Instruction symbol Description Reference Device output...
  • Page 54 Shift instruction Shifting bit devices Instruction symbol Description Reference 1 bit shift of the device Page 159 SFTP Shifting 16-bit data to the right/left by n bit (s) Instruction symbol Description Reference Page 161 bn-1 (SM700, SM8022) SFRP 0∙∙∙0 Page 163 bn+1 bn (SM700, SM8022) SFLP...
  • Page 55 Shifting n-bit data to the right/left by n bit (s) Instruction symbol Description Reference SFTR Page 171 (n1) (n2) (n2) SFTRP SFTL Page 173 (n1) (n2) (n2) SFTLP Shifting n-word data to the right/left by n word (s) Instruction symbol Description Reference WSFR...
  • Page 56: Basic Instruction

    Basic Instruction Comparison operation instruction Comparing 16-bit binary data Instruction symbol Description Reference LD=, AND=, OR= (s1)=(s2): Conductive Page 189 (s1)(s2): Non-Conductive LD=_U, AND=_U, OR=_U LD<>, AND<>, OR<> (s1)(s2): Conductive (s1)=(s2): Non-Conductive LD<>_U, AND<>_U, OR<>_U LD>, AND>, OR> (s1)>(s2): Conductive (s1)(s2): Non-Conductive LD>_U, AND>_U, OR>_U LD<=, AND<=, OR<=...
  • Page 57 Comparing 16-bit binary data band Instruction symbol Description Reference (s1)>(s3): (d) is on Page 198 (s1)(s3)(s2): (d) + 1 is on ZCPP (s3)>(s2): (d) + 2 is on ZCP_U ZCPP_U Comparing 32-bit binary data band Instruction symbol Description Reference DZCP [(s1)+1, (s1)] >...
  • Page 58 Arithmetic operation instruction Adding/subtracting 16-bit binary data Instruction symbol Description Reference (d)+(s)  (d) Page 208 +P_U (s1)+(s2)  (d) Page 210 +P_U (s1)+(s2)  (d) Page 212 ADDP ADD_U ADDP_U (d)-(s)  (d) Page 214 -P_U (s1)-(s2)  (d) Page 216 -P_U (s1)-(s2) ...
  • Page 59 Adding/subtracting 32-bit binary data Instruction symbol Description Reference [(d)+1, (d)] + [(s)+1, (s)]  [(d)+1, (d)] Page 220 D+_U D+P_U [(s1)+1, (s1)] + [(s2)+1, (s2)]  [(d)+1, (d)] Page 222 D+_U D+P_U [(s1)+1, (s1)] + [(s2)+1, (s2)]  [(d)+1, (d)] DADD Page 224 DADDP...
  • Page 60 Multiplying/dividing 32-bit binary data Instruction symbol Description Reference [(s1)+1, (s1)]  [(s2)+1, (s2)]  [(d)+3, (d)+2, (d)+1, (d)] Page 240 D*_U D*P_U [(s1)+1, (s1)]  [(s2)+1, (s2)]  [(d)+3, (d)+2, (d)+1, (d)] DMUL Page 242 DMULP DMUL_U DMULP_U [(s1)+1, (s1)]  [(s2)+1, (s2)]  quotient [(d)+1, (d)], remainder [(d)+3, (d)+2] Page 244 D/_U D/P_U...
  • Page 61 Adding/subtracting 16-bit binary block data Instruction symbol Description Reference Adds the 16-bit binary bit data in the device area ((n) points) from (s1) and the data or constants in Page 267 the device area ((n) points) from (s2) at once, and stores the result in the device area ((n) points) BK+P from (d).
  • Page 62 Logical operation instruction Performing an AND operation on 16-bit/32-bit data Instruction symbol Description Reference (d)(s)  (d) WAND Page 280 WANDP (s1) (s2)  (d) WAND Page 281 WANDP [(d)+1, (d)] [(s)+1, (s)]  [(d)+1, (d)] DAND Page 282 DANDP [(s1)+1, (s1)]...
  • Page 63 Performing an XNOR operation on 16-bit/32-bit data Instruction symbol Description Reference WXNR Page 301 WXNRP WXNR Page 302 (s1) (s2) WXNRP DXNR Page 303 [(d)+1, (d)] [(s)+1, (s)] [(d)+1, (d)] DXNRP DXNR Page 304 [(s1)+1, (s1)] [(s2)+1, (s2)] [(d)+1, (d)] DXNRP Performing an XNOR operation on 16-bit block data Instruction symbol...
  • Page 64 Batch-resetting devices Instruction symbol Description Reference ZRST Page 315 (d2) (d1)+2 (d1)+1 (d1) ZRSTP (d2) (d1)+2 (d1)+1 (d1) (1): (d1), (d2) are bit devices: Writes off (reset) from (d1) to (d2) (d1), (d2) are word devices: Writes K0 from (d1) to (d2) Data conversion instruction Converting binary data to BCD 4-digit/8-digit data Instruction symbol...
  • Page 65 Converting 16-bit signed binary data to 16-bit/32-bit unsigned binary data Instruction symbol Description Reference INT2UINT Converts 16-bit signed data in the device specified by (s) to 16-bit unsigned data, and stores the Page 334 converted data in the device specified by (d). INT2UINTP INT2UDINT Converts 16-bit signed data in the device specified by (s) to 32-bit unsigned data, and stores the...
  • Page 66 Converting 16-bit/32-bit binary data to Gray code Instruction symbol Description Reference Converts the specified 16-bit binary data (-32768 to 32767) to 16-bit binary Gray code data. Page 346 GRYP Gc: Gray code GRY_U Converts the specified 16-bit binary data (0 to 65535) to 16-bit binary Gray code data. GRYP_U Gc: Gray code DGRY...
  • Page 67 Converting character string to 16-bit/32-bit binary data Instruction symbol Description Reference Converts a character string including decimal point in the device specified by (s) to a 1 word binary Page 364 value and number of decimal fraction digits, and stores the converted data in the devices specified VALP by (d1) and (d2).
  • Page 68 Separating/connecting the specified number of bits Instruction symbol Description Reference NDIS Separates the data in the devices starting from the one specified by (s1) into bits specified by the Page 386 devices from (s2), and stores them to the devices starting from the one specified by (d). NDISP NUNI Connects the data in the devices starting from the one specified by (s1) with bits specified by the...
  • Page 69 Data transfer instruction Transferring 16-bit/32-bit data Instruction symbol Description Reference Page 397 MOVP DMOV Page 399 (s+1, s) (d+1, d) DMOVP Inverting and transferring 16-bit/32-bit data Instruction symbol Description Reference Page 401 CMLP DCML Page 403 (s+1, s) (d+1, d) DCMLP Shift move Instruction symbol...
  • Page 70 Exchanging the upper and lower bytes of 16-bit data Instruction symbol Description Reference SWAP Page 417 ··· b8 b7 ··· 8 bits 8 bits SWAPP ··· b8 b7 ··· 8 bits 8 bits Exchanging the upper and lower bytes of 32-bit data Instruction symbol Description Reference...
  • Page 71: Application Instruction

    Application Instruction Rotation instruction Rotating 16-bit data to the right Instruction symbol Description Reference Rotates the 16-bit binary data to the right by (n) bit(s) (not including the carry flag). Page 426 (SM700, SM8022) RORP (1): (n) bit right rotation Rotates the 16-bit binary data to the right by (n) bit(s) (including the carry flag).
  • Page 72 Rotating 32-bit data to the left Instruction symbol Description Reference DROL Rotates the 32-bit binary data to the left by (n) bit(s) (not including the carry flag). Page 434 (d+1) (SM700, SM8022) ∙∙∙ b16 b15 ∙∙∙ DROLP (1): (n) bit left rotation DRCL Rotates the 32-bit binary data to the left by (n) bit(s) (including the carry flag).
  • Page 73 Structuring instruction Performing the FOR to NEXT instruction loop Instruction symbol Description Reference Execute the instructions between FOR instruction and NEXT instruction (n) times Page 455 NEXT Forcibly terminating the FOR to NEXT instruction loop Instruction symbol Description Reference BREAK Forcibly end execution between FOR instruction and NEXT instruction, and jump to pointer (P) Page 458 BREAKP...
  • Page 74 Writing data to the data table Instruction symbol Description Reference SFWR Page 474 SFWRP P: Pointer Deleting/inserting data from/to the data table Instruction symbol Description Reference FINS Page 476 FINSP N: Number of stored data FDEL Page 478 FDELP N: Number of stored data Reading/writing data instructions Reading data from the data memory Instruction symbol...
  • Page 75 File operation instructions Reading data from the specified file Instruction symbol Processing details Reference SP.FREAD Reads data from the specified file. Page 486 Writing data to the specified file Instruction symbol Processing details Reference SP.FWRITE Writes data to the specified file. Page 512 Deleting the specified file Instruction symbol...
  • Page 76 Character string operation instruction Comparing character strings Instruction symbol Description Reference LD$=, AND$=, OR$= Compares the character string (s1) with the character string (s2) one character at a time. Page 589 [Character string (s1)] = [Character string (s2)]: Conductive state [Character string (s1)] ...
  • Page 77 Converting HEX code data to ASCII Instruction symbol Description Reference ASCI Converts the (n) characters within the HEX code data specified by (s) to ASCII, and stores in the Page 611 device area specified by (d) onwards. ASCIP Converting 16-bit/32-bit binary data to character string Instruction symbol Description Reference...
  • Page 78 Storing/replacing the specified number of character strings Instruction symbol Description Reference MIDR Stores the specified number of characters from the position specified by (s2) of the character string Page 645 (s1) into the device specified by (d). MIDRP MIDW Stores the specified number of characters from the character string (s1) into the location specified Page 648 by (s2) of the character string (d).
  • Page 79 Adding/subtracting single-precision real numbers Instruction symbol Description Reference • In case of 2 operands Page 665 [(d)+1, (d)] + [(s)+1, (s)]  [(d)+1, (d)] • In case of 3 operands Page 667 [(s1)+1, (s1)] + [(s2)+1, (s2)]  [(d)+1, (d)] DEADD Page 673 DEADDP...
  • Page 80 Converting decimal floating point to binary floating point Instruction symbol Description Reference DEBIN Converts the decimal floating point specified by (s) into binary floating point, and stores in (d). Page 696 DEBINP Inverting the sign of single-precision real number Instruction symbol Description Reference ENEG...
  • Page 81 Calculating the arc tangent of single-precision real number Instruction symbol Description Reference [(s)+1, (s)]  [(d)+1, (d)] ATAN Page 714 ATANP DATAN DATANP Converting single-precision real number angle to radian Instruction symbol Description Reference Page 716 (s+1, s) (d+1, d) Converts from degrees to radians RADP DRAD...
  • Page 82 Searching the maximum value of single-precision real number Instruction symbol Description Reference EMAX These instructions search for the maximum value in the (n) points of single-precision real number Page 730 block data specified by the device starting from the one specified by (s), and store the maximum EMAXP value in the device area specified by (d).
  • Page 83 Dead band control of 16-bit/32-bit binary data Instruction symbol Description Reference When (s1)  (s3)  (s2): 0  (d) BAND Page 747 When (s3) < (s1): (s3) - (s1)  (d) BANDP When (s2) < (s3): (s3) - (s2)  (d) BAND_U BANDP_U When [(s1)+1, (s1)] ...
  • Page 84 Special timer instruction Teaching timer Instruction symbol Description Reference TTMR Page 769 ) × (s) (s)=0:1, (s)=1:10, (s)=2:100 : On time of TTMR Special function timer Instruction symbol Description Reference STMR The 4 points from the bit device specified by (d) operate as shown below, depending on the ON/ Page 772 OFF status of the input conditions for the STMR instruction: (d)+0: Off delay timer output...
  • Page 85 Pulse related instruction Measuring the density of 16 bit binary/32 bit binary pulses Instruction symbol Description Reference Counts the pulse input from the device specified by (s1) for the duration of time specified by (s2), Page 782 and stores the count in the device specified by (d). DSPD Page 788 16 bit binary/32 bit binary pulse output...
  • Page 86 Data operation instruction Searching 16-bit/32-bit data Instruction symbol Description Reference SERMM Searches for data same as (s2) in (s1). Page 848 (s1) (s2) SERMMP (d) to (d)+4 (d) to (d)+4: Search result DSERMM Searches for data same as (s2) in (s1). Page 850 32 bits (s1)
  • Page 87 Searching the minimum value of 16-bit/32-bit data Instruction symbol Description Reference This instruction searches the data of (n) points from the device specified by (s) in 16-bit units, and Page 863 stores the minimum value in the device specified by (d). MINP MIN_U MINP_U...
  • Page 88 Calculating the square root of 16-bit/32-bit data Instruction symbol Description Reference SQRT Page 884 → (d) SQRTP DSQRT Page 886 (s)+1,(s) → (d)+1,(d) DSQRTP CRC calculation Instruction symbol Description Reference This instruction generates a CRC value for (n) 8-bit data (unit: byte) starting from the device Page 887 specified by (s), and stores the CRC value to (d).
  • Page 89 Subtracting clock data Instruction symbol Description Reference TSUB Page 900 (s1) (s2) hour hour hour minute minute minute TSUBP seconds seconds seconds Converting time data from hour/minute/second to seconds in 16 bits/32 bits Instruction symbol Description Reference HTOS Page 903 hour minute seconds...
  • Page 90 Comparing time data Instruction symbol Description Reference LDTM=, ANDTM=, ORTM= Page 914 (s1) (s2) hour hour (s1)+1 (s2)+1 minute minute seconds seconds (s1)+2 (s2)+2 (1): Result LDTM<>, ANDTM<>, (s1) (s2) hour hour ORTM<> (s1)+1 minute < > (s2)+1 minute seconds seconds (s1)+2 (s2)+2...
  • Page 91: Reading 1-Word/2-Word Data From Another Module (16-Bit Specification)

    Timing check instruction Generating timing pulses Instruction symbol Description Reference DUTY Page 923 (n1) (n2) (n1): (n1) scans (n2): (n2) scans (d): SM420 to SM424, SM2330 to SM2334 Hour meter Instruction symbol Description Reference HOURM This instruction adds the time during which the input contact is ON in units of 1 hour, turns ON the Page 926 device specified by (d2) when the total ON time exceeds the time specified by (s) (16-bit binary data), and stores the current value in units of 1 hour (16-bit binary data) to (d1), and the current...
  • Page 92: Step Ladder Instructions

    Writing 1-word/2-word data to another module (32-bit specification) Instruction symbol Description Reference These instructions write the (n) word data to the buffer memory of the intelligent function module. Page 942 TODP DTOD These instructions write the (n)2 word data to the buffer memory of the intelligent function module. DTODP Logging instructions Setting/resetting trigger logging...
  • Page 93: Sfc Program Instructions

    SFC Program Instructions SFC control instructions Checking the status of a step Instruction symbol Description Reference LD [S/BL\S] Outputs the status (active or inactive) of the specified step as the operation result. (Normally open Page 956 contact instruction) LDI [S/BL\S] Outputs the status (active or inactive) of the specified step as the operation result.
  • Page 94 Pausing a block Instruction symbol Description Reference PAUSE [BL] Temporarily stops the step sequence in the specified block. Page 972 Restarting a block Instruction symbol Description Reference RSTART [BL] Releases the temporary stop, and restarts the sequence from the step where the sequence was Page 974 stopped in the specified block.
  • Page 95: Chapter 4 Module Specific Instruction

    MODULE SPECIFIC INSTRUCTION Network Common Instruction Link dedicated instruction Reading data from another station programmable controller Instruction symbol Description Reference GP.READ Reads data from another station PLC device in units of words. Page 988 Reading data from another station programmable controller (with notification) Instruction symbol Description Reference...
  • Page 96 Sending data Instruction symbol Description Reference SP.SOCSND This instruction sends the data set in (s3) to the target device of the connection specified by (s1). Page 1038 Reading connection information Instruction symbol Description Reference SP.SOCCINF This instruction reads the connection information of the connection specified by (s1). Page 1041 Reading socket communication receive data Instruction symbol...
  • Page 97: Cc-Link Ie Tsn Instructions

    CC-Link IE TSN Instructions Own station number/IP address setting Instruction symbol Description Reference G.UINI Sets the station number and IP address for FX5-CCLGN-MS (own station). Page 1073 GP.UINI Sending an SLMP Frame Instruction symbol Description Reference G.SLMPSND Sends an SLMP message to the SLMP-compatible device on the same network. Page 1076 GP.SLMPSND CC-Link IE Field Network Instruction...
  • Page 98: High-Speed Counter Instruction

    High-speed Counter Instruction High-speed processing instruction Setting 32-bit data comparison Instruction symbol Description Reference DHSCS Turns ON the bit device of (d) when the current value of the high-speed counter of CH specified by Page 1091 (s2) is changed to the value specified by (s1). Reset 32-bit data comparison Instruction symbol Description...
  • Page 99: External Device Communication Instruction

    External Device Communication Instruction Serial communication 2 Instruction symbol Description Reference Sends/receives data by non-protocol communication. Page 1113 Inverter Communication Instruction Inverter operation monitoring (Status check) Instruction symbol Description Reference IVCK Reads the contents of the corresponding instruction code from the specified inverter station Page 1115 number.
  • Page 100: Positioning Instruction

    Positioning Instruction Positioning instruction Zero return(OPR) with 16-bit/32- bit data DOG search Instruction symbol Description Reference DSZR • When FX3 compatible operand is specified Page 1136 Specifies the proximity dog signal, zero signal and device (Y). Outputs a pulse with the specified DDSZR Page 1140 device (Y) to perform the zero return operation.
  • Page 101: Bfm Device Read/ Write Instruction

    16-bit/32-bit data absolute positioning Instruction symbol Description Reference DRVA • When FX3 compatible operand is specified Page 1174 Specifies the travel distance from the reference position, speed and performs pulse output with the DDRVA Page 1178 specified device (Y). • When FX5 operand is specified Specifies the travel distance from the reference position, speed and performs pulse output with the specified axis number.
  • Page 102: Chapter 5 Standard Functions/Function Blocks

    STANDARD FUNCTIONS/FUNCTION BLOCKS Standard Functions Type conversion functions Converting BOOL to WORD/DWORD Function symbol Description Reference BOOL_TO_WORD Converts BOOL type data to WORD type data. Page 1206 BOOL_TO_WORD_E BOOL_TO_DWORD Converts BOOL type data to DWORD type data. Page 1208 BOOL_TO_DWORD_E Converting BOOL to INT/DINT Function symbol Description...
  • Page 103 Converting WORD to TIME Function symbol Description Reference WORD_TO_TIME Converts WORD type data to TIME type data. Page 1218 WORD_TO_TIME_E Converting DWORD to BOOL Function symbol Description Reference DWORD_TO_BOOL Converts DWORD type data to BOOL type data. Page 1219 DWORD_TO_BOOL_E Converting DWORD to WORD Function symbol Description...
  • Page 104 Converting INT to BCD Function symbol Description Reference INT_TO_BCD Converts INT type data to BCD type data. Page 1231 INT_TO_BCD_E Converting INT to REAL Function symbol Description Reference INT_TO_REAL Converts INT type data to REAL type data. Page 1233 INT_TO_REAL_E Converting INT to TIME Function symbol Description...
  • Page 105 Converting DINT to TIME Function symbol Description Reference DINT_TO_TIME Converts DINT type data to TIME type data. Page 1246 DINT_TO_TIME_E Converting DINT to STRING Function symbol Description Reference DINT_TO_STRING Converts DINT type data to STRING type data. Page 1247 DINT_TO_STRING_E Converting BCD to INT/DINT Function symbol Description...
  • Page 106 Converting TIME to STRING Function symbol Description Reference TIME_TO_STRING Converts TIME type data to STRING type data. Page 1265 TIME_TO_STRING_E Converting STRING to BOOL Function symbol Description Reference STRING_TO_ BOOL Converts STRING type data to BOOL type data. Page 1267 STRING_TO_ BOOL_E Converting STRING to INT/DINT Function symbol...
  • Page 107: Standard Functions Of One Numeric Variable

    Reading the specified bit of word label Function symbol Description Reference GET_BIT_OF_INT Reads a value of a specified bit of INT type data. Page 1281 GET_BIT_OF_INT_E Writing the specified bit of word label Function symbol Description Reference SET_BIT_OF_INT Writes a value to a specified bit of INT type data. Page 1282 SET_BIT_OF_INT_E Copying the specified bit of word label...
  • Page 108: Standard Arithmetic Functions

    Sine operation Function symbol Description Reference Outputs the sine of the angle of an input value. Page 1292 SIN_E Cosine operation Function symbol Description Reference Outputs the cosine of the angle of an input value. Page 1293 COS_E Tangent operation Function symbol Description Reference...
  • Page 109: Standard Bit Shift Functions

    Division Function symbol Description Reference Outputs the quotient of input values ((s1)  (s2)). Page 1308 DIV_E Remainder Function symbol Description Reference Outputs the remainder of input values ((s1)  (s2)). Page 1310 MOD_E Exponentiation Function symbol Description Reference EXPT Outputs the exponentiation of an input value.
  • Page 110: Standard Selection Functions

    Standard selection functions Selection Function symbol Description Reference Outputs a selected input value. Page 1327 SEL_E Selecting Maximum/Minimum Value Function symbol Description Reference Outputs the maximum value of an input value. Page 1329 MAX_E Outputs the minimum value of an input value. MIN_E Limit Control Function symbol...
  • Page 111: Standard Character String Functions

    Standard character string functions Character string length detection Function symbol Description Reference Detects the length of an input character string and outputs the result. Page 1339 LEN_E Extracting character string data from the left/right Function symbol Description Reference LEFT Outputs specified number of characters from the left of input character string data. Page 1341 LEFT_E RIGHT...
  • Page 112: Time Data Functions

    Time data functions Addition Function symbol Description Reference ADD_TIME Outputs the sum of input values (time data) ((s1) + (s2)). Page 1356 ADD_TIME_E Subtraction Function symbol Description Reference SUB_TIME Outputs the difference of input values (time data) ((s1) - (s2)). Page 1358 SUB_TIME_E Multiplication...
  • Page 113: Standard Function Blocks

    Standard Function Blocks Bistable function blocks Bistable function blocks (set priority) Function block symbol Description Reference Judges two input values and outputs 1 (TRUE) or 0 (FALSE). (Set priority) Page 1366 SR_E Bistable function blocks (reset priority) Function block symbol Description Reference Judges two input values and outputs 1 (TRUE) or 0 (FALSE).
  • Page 114: Timer Function Blocks

    Timer function blocks Pulse timer Function block symbol Description Reference Keeps ON a signal for specified duration. Page 1383 TP_E TP_10 TP_10_E On-delay timer Function block symbol Description Reference Turns ON a signal after a specified time. Page 1385 TON_E TON_10 TON_10_E Off-delay timer...
  • Page 115: Part 3 Cpu Module Instructions

    PART 3 CPU MODULE INSTRUCTIONS This part consists of the following chapters. 6 SEQUENCE INSTRUCTIONS 7 BASIC INSTRUCTIONS 8 APPLICATION INSTRUCTION 9 STEP LADDER INSTRUCTIONS 10 PID CONTROL INSTRUCTION 11 SFC PROGRAM INSTRUCTIONS...
  • Page 116: Chapter 6 Sequence Instructions

    SEQUENCE INSTRUCTIONS Contact Instructions Operation start, series connection, parallel connection LD, LDI, AND, ANI, OR, ORI FX5S FX5UJ FX5U FX5UC • LD: NO contact operation start instruction/LDI: NC contact operation start instruction These instructions capture the ON/OFF information of the device specified by (s), and use that as the operation result. •...
  • Page 117 Processing details LD, LDI • The LD instruction is the NO contact operation start instruction, and the LDI instruction is the NC contact operation start instruction. These instructions capture the ON/OFF information of the specified device, and use the result as the operation result.
  • Page 118: Operation Error

    OR, ORI • The OR instruction is NO contact parallel connection and the ORI instruction is NC contact parallel connection. These instructions capture the ON/OFF information of the specified device, OR with the operation result so far, and use the result as the operation result.
  • Page 119: Pulse Operation Start, Pulse Series Connection, Pulse Parallel Connection

    Pulse operation start, pulse series connection, pulse parallel connection LDP, LDF, ANDP, ANDF, ORP, ORF FX5S FX5UJ FX5U FX5UC • LDP: Rising edge pulse operation start instruction This becomes conductive (ON) only at the rising edge (OFF to ON) of the bit device specified by (s). •...
  • Page 120: Processing Details

    Applicable devices Operand Word Double word Indirect Constant Others specification (DX) X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R          ...
  • Page 121 - ANDP instruction (series connection of rising edge pulse) ANDP instruction SM400 Timing chart SM400 ANDP instruction ON during one operation cycle - ANDF instruction (series connection of falling edge pulse) ANDF instruction SM400 Timing chart ANDF instruction ON during one operation cycle ORP, ORF...
  • Page 122 • LDF and ORF instructions (initial logical operation of falling edge pulse, and parallel connection of falling edge pulse) LDF instruction ORF instruction Timing chart LDF instruction X0 ORF instruction ON during one operation cycle In the example shown above, M0 is ON during only one operation cycle when X0 or X1 turn from ON to OFF. Operation error There is no operation error.
  • Page 123: Pulse Not Operation Start, Pulse Not Series Connection, Pulse Not Parallel Connection

    Pulse NOT operation start, pulse NOT series connection, pulse NOT parallel connection LDPI, LDFI, ANDPI, ANDFI, ORPI, ORFI FX5S FX5UJ FX5U FX5UC • LDPI: Rising edge pulse NOT operation start instruction This instruction becomes conductive (ON) at OFF, ON and the falling edge (ON to OFF) of the bit device specified by (s). •...
  • Page 124 Applicable devices Operand Word Double word Indirect Constant Others specification (DX) X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R          ...
  • Page 125: Association Instruction

    Association Instruction Ladder block series/parallel connection ANB, ORB FX5S FX5UJ FX5U FX5UC These instructions AND or OR the A and B blocks, and use the result as the operation result. Ladder diagram Structured text Not supported. A: A block B: B block FBD/LD Not supported.
  • Page 126 ORB • This instruction ORs the A and B blocks, and uses the result as the operation result. • This instruction connects the ladder blocks of two contacts or more in parallel. For parallel connection of only one contact, use the OR and ORI instructions; there is no need to use this instruction. •...
  • Page 127: Storing/Reading/Clearing The Operation Result

    Storing/reading/clearing the operation result MPS, MRD, MPP FX5S FX5UJ FX5U FX5UC • MPS: This instruction stores the preceding operation result (ON/OFF) to memory. • MRD, MPP: These instructions read the operation result stored by the MPS instruction, and executes operations from the next step using that operation result.
  • Page 128: Program Example

    Program example • Continuous use of MPS instruction - once Only one stack is used in this example. • Continuous use of MPS instruction - once (both ANB and ORB used) 6 SEQUENCE INSTRUCTIONS 6.2 Association Instruction...
  • Page 129 • Continuous use of MPS instruction - twice • Continuous use of MPS instruction - four times MPS instruction is used three times in programming. By changing the circuit as follows, the same contents can be programmed easily without MPS instruction. Operation error There is no operation error.
  • Page 130: Inverting The Operation Result

    Inverting the operation result FX5S FX5UJ FX5U FX5UC This instruction inverts the operation result up to this instruction. Ladder diagram Structured text ENO:=INV(EN); FBD/LD Processing details • This instruction inverts the operation result up to this instruction. Operation result up to the INV instruction Operation result after execution of INV instruction Operation error There is no operation error.
  • Page 131: Converting The Operation Result Into A Pulse

    Converting the operation result into a pulse MEP, MEF FX5S FX5UJ FX5U FX5UC • MEP: This instruction turns ON at the rising edge of the operation result up to the MEP instruction and turns OFF in other instances. • MEF: This instruction turns ON at the falling edge of the operation result up to the MEF instruction and turns OFF in other instances.
  • Page 132: Output Instructions

    Output Instructions Out (excluding the timer, counter and annunciator) FX5S FX5UJ FX5U FX5UC This instruction outputs the operation result up to this instruction to the specified device. Ladder diagram Structured text ENO:=OUT(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 133 Program example Drive contact of OUT instruction OUT instruction OUT instruction M100 OUT instruction M101 Timing chart OUT instruction OUT instruction M100 OUT instruction M101 Operation error There is no operation error. 6 SEQUENCE INSTRUCTIONS 6.3 Output Instructions...
  • Page 134: Timer

    Timer OUT T, OUTH T, OUTHS T, OUT ST, OUTH ST, OUTHS ST FX5S FX5UJ FX5U FX5UC The timer counts up to the set value when the operation result up to the OUT instruction is ON and the coil of the timer/ retentive timer specified by (d) turns ON.
  • Page 135 Processing details • These instructions count up to the set value when the operation result up to the OUT instruction is ON and the coil of the timer/retentive timer specified by (d) turns ON. When the timer reaches the end of its count (current value  set value), NO contact becomes conductive and NC contact becomes non-conductive.
  • Page 136 Program example The set value is required after OUT instruction for the coil of a timer or counter. The set value can be specified directly by a decimal number (K) or indirectly using a data register (D) or file register (R). •...
  • Page 137: Counter

    Counter OUT C FX5S FX5UJ FX5U FX5UC This instruction increments the current value of the counter specified by (d) by 1 when the operation result up to OUT instruction changes from OFF to ON, and when the counter reaches the end of its count, NO contact becomes conductive and NC contact becomes non-conductive.
  • Page 138 Processing details • This instruction increments the current value of the counter specified by (d) by 1 when the operation result up to OUT instruction changes from OFF to ON, and when the counter reaches the end of its count (current value  set value), NO contact becomes conductive and NC contact becomes non-conductive.
  • Page 139: Long Counter

    Long counter OUT LC FX5S FX5UJ FX5U FX5UC This instruction increments the current value of the long counter specified by (d) by 1 when the operation result up to the OUT instruction changes from OFF to ON, and when the counter reaches the end of its count, NO contact becomes conductive and NC contact becomes non-conductive.
  • Page 140 Processing details • This instruction increments the current value of the long counter specified by (d) by 1 when the operation result up to the OUT instruction changes from OFF to ON, and when the counter reaches the end of its count (current value  set value), NO contact becomes conductive and NC contact becomes non-conductive.
  • Page 141: Annunciator

    Annunciator OUT F FX5S FX5UJ FX5U FX5UC This instruction outputs the operation result up to the OUT F instruction to the specified annunciator. Ladder diagram Structured text ENO:=OUT(EN,d); FBD/LD ("OUT" enters .) Setting data Descriptions, ranges, and data types Operand Description Range Data type...
  • Page 142 Operation error There is no operation error. 6 SEQUENCE INSTRUCTIONS 6.3 Output Instructions...
  • Page 143: Setting Devices (Excluding Annunciator)

    Setting devices (excluding annunciator) FX5S FX5UJ FX5U FX5UC The status of the device specified by (d) changes as follows when the execution command turns ON. • Bit device: Turns the coils and contacts ON. • Bit specification of word device: Set the specified bit to 1. Ladder diagram Structured text ENO:=SET(EN,d);...
  • Page 144 Precautions When the SET and RST instructions are executed on the same output relay (Y), the result of the instruction nearer the END instruction (end of program) is output. Operation error There is no operation error. 6 SEQUENCE INSTRUCTIONS 6.3 Output Instructions...
  • Page 145: Resetting Devices (Excluding Annunciator)

    Resetting devices (excluding annunciator) FX5S FX5UJ FX5U FX5UC The status of the device specified by (d) changes as follows when the RST input turns ON. • Bit devices: Turns the coils and contacts OFF. • Timers, counters: Sets the current value to 0, and turns contacts OFF. •...
  • Page 146 • Function when a word device is specified by the RST instruction is the same as the following circuit. Precautions When the RST instruction for a timer or counter is executed by a program containing a jump or by a subroutine program or interrupt program, the timer or counter is held in a reset state, and the timer or counter may not work normally.
  • Page 147: Setting Annunciator

    Setting annunciator SET F FX5S FX5UJ FX5U FX5UC This instruction turns ON the specified annunciator. Ladder diagram Structured text ENO:=SET(EN,d); FBD/LD ("SET" enters .) Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)  ...
  • Page 148: Related Devices

    Processing details • This instruction turns ON the annunciator specified by (d) when the execution command turns ON. • Operation is as follows when annunciator (F) is turned ON. • The annunciator number (F number) that turns ON is stored in special registers (SD64 to SD79). •...
  • Page 149: Resetting Annunciator

    Resetting annunciator RST F FX5S FX5UJ FX5U FX5UC This instruction turns OFF the specified annunciator. Ladder diagram Structured text ENO:=RST(EN,d); FBD/LD ("RST" enters .) Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)  Annunciator number (F number) that is reset ANY_ELEMENTARY ...
  • Page 150 Processing details • This instruction turns OFF the annunciator specified by (d) when the execution command turns ON. • An annunciator number (F number) that turns OFF is deleted from special registers (SD64 to SD79) and the content of SD63 is decremented by 1. •...
  • Page 151: Setting Annunciator (With Check Time)

    Setting annunciator (with check time) FX5S FX5UJ FX5U FX5UC This instruction sets the annunciator (F device). Ladder diagram Structured text ENO:=ANS(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)  Timer number for evaluation time 16-bit signed binary ANY16 Evaluation time data...
  • Page 152: Program Example

    Related devices Device Name Description SM8049 ON status annunciator smallest number When SM8049 is turned ON, SM8048 and SD8049 are enabled. enabled SM8048 Annunciator operation When one of the F devices is operating, SM8048 turns ON. SD8049 ON status annunciator smallest number The smallest number of the F devices that are operating is stored.
  • Page 153: Resetting Annunciator (Smallest Number Reset)

    Resetting annunciator (smallest number reset) ANR(P) FX5S FX5UJ FX5U FX5UC This instruction resets the lowest number annunciator (F device) in the ON status. Ladder diagram Structured text ENO:=ANR(EN); ENO:=ANRP(EN); FBD/LD Processing details • Annunciator (F device) that is operating (in ON status) is reset when the command input turns ON. This instruction resets the annunciator with the smallest number when multiple annunciators are ON.
  • Page 154: Rising Edge Output

    Rising edge output FX5S FX5UJ FX5U FX5UC This instruction turns ON the device specified by (d) for one scan when the PLS command turns from OFF to ON, and turns OFF in other cases. Ladder diagram Structured text ENO:=PLS(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 155 Processing details • This instruction turns ON the specified device for one scan when the PLS command turns from OFF to ON, and turns OFF in other cases. When there is one PLS instruction programmed for the device specified by (d) during a scan, the specified device turns ON for one scan.
  • Page 156: Falling Edge Output

    Falling edge output FX5S FX5UJ FX5U FX5UC This instruction turns ON the device specified by (d) for one scan when the PLF command turns from ON to OFF, and turns OFF in other cases. Ladder diagram Structured text ENO:=PLF(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 157 Precautions • When write during RUN is completed for a circuit including a falling edge instruction (LDF/ANDF/ORF instruction), the instruction is not executed regardless of the ON/OFF status of the target device of the falling edge instruction. Also, in the case of a falling edge instruction (PLF instruction), the instruction is not executed regardless of the ON/OFF status of the device that is set as the operation condition.
  • Page 158: Inverting The Bit Device Output

    Inverting the bit device output FX5S FX5UJ FX5U FX5UC This instruction reverses the output status of the device specified by (d) when the execution command changes from OFF to Ladder diagram Structured text ENO:=FF(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 159: Inverting The Bit Device Output

    Inverting the bit device output ALT(P) FX5S FX5UJ FX5U FX5UC These instructions reverse (ON  OFF) bit devices when input turns ON. Ladder diagram Structured text ENO:=ALT(EN,d); ENO:=ALTP(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Bit device number whose output is alternated ...
  • Page 160 Precautions When the CPU module is programmed with the ALT instruction, reversal operation is performed at every operation cycle. To perform reversal operation by command ON/OFF, either use the ALTP instruction (pulse execution type) or set a command contact as LDP etc. (pulse execution type). Operation error There is no operation error.
  • Page 161: Shift Instructions

    Shift Instructions Shifting bit devices SFT(P) FX5S FX5UJ FX5U FX5UC • In case of bit device: These instructions shift the ON/OFF status of the device before the device specified by (d) to the device specified by (d). • When bit of word device is specified: These instructions shift the 1/0 status of the bit before the bit specified by (d) to the bit specified by (d).
  • Page 162 Processing details In case of bit device • This instruction shifts the ON/OFF status of the device before the device specified by (d) to the device specified by (d). The device before the device specified by (d) turns OFF. When M11 is specified by the SFTP instruction and the SFTP instruction is executed, the ON/OFF status of M10 is shifted to M11 and M10 is turned OFF.
  • Page 163: Shifting 16-Bit Data To The Right By N Bit(S)

    Shifting 16-bit data to the right by n bit(s) SFR(P) FX5S FX5UJ FX5U FX5UC These instructions shift the 16-bit data in the device specified by (d) to the right by (n) bit(s). Ladder diagram Structured text ENO:=SFR(EN,n,d); ENO:=SFRP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 164 • When (d) is a bit device, bits are shifted to the right within the device range specified by digit specification. When (n)=4 Y14 Y13 ··· ··· ··· (SM700, SM8022) Y14 Y13 ··· ··· ··· • Specify any value between 0 and 15 for (n). If a value 16 or larger is specified for (n), bits are shifted to the right by the remainder value of (n)16.
  • Page 165: Shifting 16-Bit Data To The Left By N Bit(S)

    Shifting 16-bit data to the left by n bit(s) SFL(P) FX5S FX5UJ FX5U FX5UC These instructions shift the 16-bit data in the device specified by (d) to the left by (n) bit(s). Ladder diagram Structured text ENO:=SFL(EN,n,d); ENO:=SFLP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 166 • When (d) is a bit device, bit(s) are shifted to the left within the device range specified by digit specification. When (n)=3 ··· ··· (SM700, SM8022) X14 X13 ··· ··· • Specify any value between 0 and 15 for (n). If a value 16 or larger is specified for (n), bit(s) are shifted to the left by the remainder value of (n)16.
  • Page 167: Shifting N-Bit Data To The Right By 1 Bit

    Shifting n-bit data to the right by 1 bit BSFR(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n) point(s) of data to the right by 1 bit from the device specified by (d). Ladder diagram Structured text ENO:=BSFR(EN,n,d); ENO:=BSFRP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 168 Operation error Error code Description (SD0/SD8067) 2820H The (n) points of data starting from the device specified by (d) exceed in the corresponding device. 6 SEQUENCE INSTRUCTIONS 6.4 Shift Instructions...
  • Page 169: Shifting N-Bit Data To The Left By 1 Bit

    Shifting n-bit data to the left by 1 bit BSFL(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n) point(s) of data to the left by 1 bit from the device specified by (d). Ladder diagram Structured text ENO:=BSFL(EN,n,d); ENO:=BSFLP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 170 Operation error Error code Description (SD0/SD8067) 2820H The (n) points of data starting from the device specified by (d) exceed in the corresponding device. 6 SEQUENCE INSTRUCTIONS 6.4 Shift Instructions...
  • Page 171: Shifting N-Word Data To The Right By 1 Word

    Shifting n-word data to the right by 1 word DSFR(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n) point(s) of data to the right by 1 word from the device specified by (d). Ladder diagram Structured text ENO:=DSFR(EN,n,d); ENO:=DSFRP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 172: Shifting N-Word Data To The Left By 1 Word

    Shifting n-word data to the left by 1 word DSFL(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n) point(s) of data to the left by 1 word from the device specified by (d). Ladder diagram Structured text ENO:=DSFL(EN,n,d); ENO:=DSFLP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 173: Shifting N-Bit(S) Data To The Right By (N) Bit(S)

    Shifting n-bit(s) data to the right by (n) bit(s) SFTR(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n1) bits of data to the right by (n2) bit(s) from the device specified by (d). Ladder diagram Structured text ENO:=SFTR(EN,s,n1,n2,d); ENO:=SFTRP(EN,s,n1,n2,d); (n1) (n2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 174 Processing details • These instructions shift (n1) bits of data to the right by (n2) bit(s) from the device specified by (d). After the shift, (n2) points from (s) are set into (n2) points from (d)+(n1-n2). • When K0 is specified for (s), set 0s for (n2) points of bits from (d)+(n1-n2) after the shift. •...
  • Page 175: Shifting N-Bit Data To The Left By N Bit(S)

    Shifting n-bit data to the left by n bit(s) SFTL(P) FX5S FX5UJ FX5U FX5UC These instructions shift (n1) bits of data to the left by (n2) bit(s) from the device specified by (d). Ladder diagram Structured text ENO:=SFTL(EN,s,n1,n2,d); ENO:=SFTLP(EN,s,n1,n2,d); (n1) (n2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 176 Processing details • These instructions shift (n1) bits of data to the left by (n2) bit(s) from the device specified by (d). After the shift, (n2) points from (s) are set into (n2) points from (d). • When K0 is specified for (s), set 0s for (n2) points of bits from (d) after the shift. •...
  • Page 177: Shifting N-Word Data To The Right By N Word(S)

    Shifting n-word data to the right by n word(s) WSFR(P) FX5S FX5UJ FX5U FX5UC This instruction shifts (n1) words of data to the right by (n2) word(s) from the device specified by (d). Ladder diagram Structured text ENO:=WSFR(EN,s,n1,n2,d); ENO:=WSFRP(EN,s,n1,n2,d); (n1) (n2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 178 Processing details • This instruction shifts (n1) words of data to the right by (n2) word(s) from the device specified by (d). After the shift, (n2) points from (s) are set into (n2) points from (d)+(n1-n2). • This instruction sets the specified value for (n2) points of devices from (d) + (n1-n2) after the shift when K is specified for (s).
  • Page 179: Shifting N-Word Data To The Left By N Word(S)

    Shifting n-word data to the left by n word(s) WSFL(P) FX5S FX5UJ FX5U FX5UC This instruction shifts (n1) words of data to the left by (n2) word(s) from the device specified by (d). Ladder diagram Structured text ENO:=WSFL(EN,s,n1,n2,d); ENO:=WSFLP(EN,s,n1,n2,d); (n1) (n2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 180 Processing details • This instruction shifts (n1) words of data to the left by (n2) word(s) from the device specified by (d). After the shift, (n2) points from (s) are set into (n2) points from (d). • This instruction sets the specified value for (n2) points of devices from (d) + (n1-n2) after the shift when K is specified for (s).
  • Page 181: Master Control Instruction

    Master Control Instruction Setting/resetting the master control MC, MCR FX5S FX5UJ FX5U FX5UC • MC: This instruction starts master control. • MCR: This instruction ends master control. Ladder diagram Structured text ENO:=MC(EN,n,d); ENO:=MCR(EN,n); (1): Master control ladder FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 182 Processing details These instructions create program with efficient ladder switching by opening/closing common buses in ladders. Ladder using master control is illustrated below. (Left: Display on the engineering tool, Right: Actual operation) (1) Executed only when X0 is on MC •...
  • Page 183 Master control instructions can be used in a nested fashion. Each master control section is distinguished by nesting (N). Nesting is available within the range N0 to N14. A nested structure allows you to create a ladder for successively restricting program execution conditions. A nested structure ladder is illustrated as follows: (Left: Display on the engineering tool, Right: Actual operation) N0 M15...
  • Page 184 Precautions • If an instruction (e.g. LD, LDI) to be connected to the bus is not programmed following the MC instruction, a program structure error (error code: 33E0) occurs. • These instructions cannot be used in FOR to NEXT, STL to RETSTL, P to RET (SRET), and I to IRET. Also, do not block by I, IRET, FEND, END, RET (SRET), RETSTL, etc.
  • Page 185: Termination Instructions

    Termination Instructions Ending the main routine program FEND FX5S FX5UJ FX5U FX5UC This instruction is used to branch operation of the sequence program by the CJ instruction or to divide the main routine program into a subroutine program or an interrupt program. Ladder diagram Structured text Not supported.
  • Page 186 Program example • Example in which outputs in the subroutine are latched In the following program example, the counter C0 is provided to count X1. When X0 is input, the subroutine P0 is executed only in one scan, and then the counter is reset and Y7 is output. CALLP FEND Timing chart...
  • Page 187 • Example for resetting outputs in the subroutine CALLP Y7 is reset at an arbitrary timing. FEND SM401 The preceding RST C0 instruction is RUN monitor deactivated in the subroutine. (normally OFF) Timing chart Subroutine is executed. Execution of P0 is triggered by X0 Current value of C0...
  • Page 188: Ending The Sequence Program

    Ending the sequence program FX5S FX5UJ FX5U FX5UC This instruction indicates the end of a program. Ladder diagram Structured text Not supported. FBD/LD Not supported. Processing details • This instruction indicates the end of all programs including the main routine program, subroutine program, and interrupt program.
  • Page 189 The END instruction executed while a program is divided into multiple program blocks indicates the end of a program block. The END instruction executed for END processing is executed at the end of the last executed program registered in the program settings. Operation error Error code Description...
  • Page 190: Stop Instruction

    Stop Instruction Stopping the sequence program STOP FX5S FX5UJ FX5U FX5UC This instruction resets outputs (Y) and stops operation of the CPU module when the execution command turns ON. (This operation is the same as setting the switch to STOP.) Ladder diagram Structured text ENO:=STOP(EN);...
  • Page 191: Chapter 7 Basic Instructions

    BASIC INSTRUCTIONS Comparison Operation Instructions Comparing 16-bit binary data LD(_U), AND(_U), OR(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the 16-bit binary data in the device specified by (s1) and the 16- bit binary data in the device specified by (s2). (Devices are used as NO contacts.) Ladder diagram Structured text ENO:=LD_(EN,s1,s2);...
  • Page 192: Applicable Devices

    Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 193 Precautions • When the most significant bit is "1" in the data stored in (s1) or (s2), it is regarded as a negative binary value for comparison. (Excluding unsigned operation) Program example • LD(_U) When the current value of C10 is "200", Y10 turns ON. K200 When the content value of D200 is "-29"...
  • Page 194: Comparing 32-Bit Binary Data

    Comparing 32-bit binary data LDD(_U), ANDD(_U), ORD(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the 32-bit binary data in the device specified by (s1) and the 32- bit binary data in the device specified by (s2). (Devices are used as NO contacts) Ladder diagram Structured text ENO:=LDD_(EN,s1,s2);...
  • Page 195 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 196: Comparison Output 16-Bit Binary Data

    Comparison output 16-bit binary data CMP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the 16-bit binary data in the devices specified by (s1) and (s2). Ladder diagram Structured text ENO:=CMP(EN,s1,s2,d); ENO:=CMP_U(EN,s1,s2,d); ENO:=CMPP(EN,s1,s2,d); ENO:=CMPP_U(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 197 Processing details • These instructions perform a comparison operation between the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2) and according to the result (small, equal, large), (d), (d) + 1, or (d) + 2 is turned ON.
  • Page 198: Comparison Output 32-Bit Binary Data

    Comparison output 32-bit binary data DCMP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the 32-bit binary data in the devices specified by (s1) and (s2). Ladder diagram Structured text ENO:=DCMP(EN,s1,s2,d); ENO:=DCMP_U(EN,s1,s2,d); ENO:=DCMPP(EN,s1,s2,d); ENO:=DCMPP_U(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 199 Processing details • These instructions perform a comparison operation between the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2) and according to the result (small, equal, large), (d), (d) + 1, or (d) + 2 is turned ON.
  • Page 200: Comparing 16-Bit Binary Data Band

    Comparing 16-bit binary data band ZCP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation on the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2) with the 16-bit binary data in the device specified by comparison source (s3), and output the comparison result (below, within zone, above) to the device specified by (d) onwards.
  • Page 201 • Large and small comparison is executed algebraically. • With sign…-10 (FFF6H) < 2 (0002H) < 10 (000AH) • Without sign…0 (0000H) < 32767 (7FFFH) < 40000 (9C40H) (s1) (s2) (s3) Turns ON in the case of (s1)>(s3). (d)+1 Turns ON in the case of (s1)≤(s3)≤(s2). (d)+2 Turns ON in the case of (s3)>(s2).
  • Page 202: Comparing 32-Bit Binary Data Band

    Comparing 32-bit binary data band DZCP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation on the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2) with the 32-bit binary data in the device specified by comparison source (s3), and output the comparison result (below, within zone, above) to the device specified by (d) onwards.
  • Page 203 Processing details • These instructions perform a comparison operation on the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2) with the 32-bit binary data in the device specified by comparison source (s3), and according to the comparison result (below, within zone, above), (d), (d) + 1, or (d) + 2 is turned ON.
  • Page 204: Comparing 16-Bit Binary Block Data

    Comparing 16-bit binary block data BKCMP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between (n) point(s) of 16-bit binary data in the device starting from the one specified by (s1) and (n) point(s) of 16-bit binary data in the device starting from the one specified by (s2), and store the operation result in the device specified by (d).
  • Page 205 Processing details • These instructions perform a comparison operation between (n) point(s) of 16-bit binary data in the device starting from the one specified by (s1) and (n) point(s) of 16-bit binary data in the device starting from the one specified by (s2), and store the comparison result in (n) point(s) of data starting from the device specified by (d).
  • Page 206 Program example • In the program shown below, four 16-bit binary data starting from D100 are compared with four 16-bit binary data starting from D200 by BKCMP= instruction when X20 is set to ON, and the comparison result is stored in four points starting from M10.
  • Page 207: Comparing 32-Bit Binary Block Data

    Comparing 32-bit binary block data DBKCMP(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the (n) point(s) of 32-bit binary data starting from the device specified by (s1) and the (n) point(s) of 32-bit binary data starting from the device specified by (s2), and store the operation result in the device specified by (d).
  • Page 208 Processing details • These instructions perform a comparison operation between (n) point(s) of 32-bit binary data starting from the device specified by (s1) and (n) point(s) of 32-bit binary data starting from the device specified by (s2), and store the comparison result in (n) point(s) of data starting from the device specified by (d).
  • Page 209 Operation error Error code Description (SD0/SD8067) The (n)  2 points of data starting from the device specified by (s1) and (s2) or the (n) point(s) of data starting from the device specified by 2820H (d) exceeds said device. When (d) specifies "D.b", the (n) point(s) of data starting from the device specified by (d) and the device range of the (n)  2 points of 2821H data starting from the device specified by (s1) overlap.
  • Page 210: Arithmetic Operation Instructions

    Arithmetic Operation Instructions Adding 16-bit binary data +(P)(_U) instruction and ADD(P)(_U) instruction can be used for addition of 16-bit binary data. +(P)(_U) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions add the 16-bit binary data in the device specified by (d) and the 16-bit binary data in the device specified by (s), and store the result in the device specified by (d).
  • Page 211 Processing details • These instructions add the 16-bit binary data in the device specified by (s) to the 16-bit binary data in the device specified by (d), and store the addition result in the device specified by (d). ··· ··· ···...
  • Page 212 +(P)(_U) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions add the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=PLUS(EN,s1,s2,d);...
  • Page 213 Processing details • These instructions add the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the addition result in the device specified by (d). (s1) (s2) ···...
  • Page 214 ADD(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=ADDP(EN,s1,s2,d);...
  • Page 215 Relationship between the flag operation and the sign (positive or negative) of a numeric value Device Name Description SM700, SM8022 Carry When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON. SM8020 Zero When the operation result is 0, the zero flag is turned ON.
  • Page 216: Subtracting 16-Bit Binary Data

    Subtracting 16-bit binary data -(P)(_U) instruction and SUB(P)(_U) instruction can be used for subtraction of 16-bit binary data. -(P)(_U) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the 16-bit binary data in the device specified by (d) and the 16-bit binary data in the device specified by (s), and store the result in the device specified by (d).
  • Page 217 Processing details • These instructions subtract the 16-bit binary data in the device specified by (d) and the 16-bit binary data in the device specified by (s), and store the subtraction result in the device specified by (d). ··· ··· ···...
  • Page 218 -(P)(_U) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=MINUS(EN,s1,s2,d);...
  • Page 219 Processing details • These instructions subtract the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the subtraction result in the device specified by (d). (s1) (s2) ···...
  • Page 220 SUB(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract the 16-bit binary data in the device specified by (s1) and the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=SUBP(EN,s1,s2,d);...
  • Page 221 Relationship between the flag operation and the sign (positive or negative) of a numeric value Device Name Description SM700, SM8022 Carry When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON. SM8020 Zero When the operation result is 0, the zero flag is turned ON.
  • Page 222: Adding 32-Bit Binary Data

    Adding 32-bit binary data D+(P)(_U) instruction and DADD(P)(_U) instruction can be used for addition of 32-bit binary data. D+(P)(_U) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions add the 32-bit binary data in the device specified by (d) and the 32-bit binary data in the device specified by (s), and store the result in the device specified by (d).
  • Page 223 Processing details • These instructions add the 32-bit binary data in the device specified by (d) and the 32-bit binary data in the device specified by (s), and store the addition result in the device specified by (d). (d)+1 (s)+1 (d)+1 b16 b15 b16 b15...
  • Page 224 D+(P)(_U) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions add the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DPLUS(EN,s1,s2,d);...
  • Page 225 Processing details • These instructions add the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the addition result in the device specified by (d). (s1) (s2) (s1)+1 (s2)+1 (d)+1...
  • Page 226 DADD(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DADD(EN,s1,s2,d);...
  • Page 227 Relationship between the flag operation and the sign (positive or negative) of a numeric value Device Name Description SM700, SM8022 Carry When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON. SM8020 Zero When the operation result is 0, the zero flag is turned ON.
  • Page 228: Subtracting 32-Bit Binary Data

    Subtracting 32-bit binary data D-(P)(_U) instruction and DSUB(P)(_U) instruction can be used for subtraction of 32-bit binary data. D-(P)(_U) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the 16-bit binary data in the device specified by (d) and the 16-bit binary data in the device specified by (s), and store the result in the device specified by (d).
  • Page 229 Processing details • These instructions subtract the 32-bit binary data in the device specified by (d) and the 32-bit binary data in the device specified by (s), and store the subtraction result in the device specified by (d). (d)+1 (s)+1 (d)+1 b16 b15 b16 b15...
  • Page 230 D-(P)(_U) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DMINUS(EN,s1,s2,d);...
  • Page 231 Processing details • These instructions subtract the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the subtraction result in the device specified by (d). (s1) (s2) (s1)+1 (s2)+1 (d)+1...
  • Page 232 DSUB(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DSUB(EN,s1,s2,d);...
  • Page 233 Relationship between the flag operation and the sign (positive or negative) of a numeric value Device Name Description SM700, SM8022 Carry When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON. SM8020 Zero When the operation result is 0, the zero flag is turned ON.
  • Page 234: Multiplying 16-Bit Binary Data

    Multiplying 16-bit binary data *(P)(_U) instruction and MUL(P)(_U) instruction can be used for multiplication of 16-bit binary data. *(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions multiply the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d).
  • Page 235 Processing details • These instructions multiply the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the multiplication result in the device specified by (d). (s1) (s2) (d)+1 b16 b15 ···...
  • Page 236 MUL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions multiply the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=MULP(EN,s1,s2,d);...
  • Page 237: Program Example

    • Nibble can be specified ranging from K1 to K8 for (d). For example, when K2 is specified, only the lower-order 8 bits can be obtained out of the product (32 bits). (s1) (s2) K2Y0 (s1) K53(0035H) × K15(000FH) (s2) When command contact is ON K795(031BH) Sign bit (0: Positive, 1: Negative)
  • Page 238: Dividing 16-Bit Binary Data

    Dividing 16-bit binary data /(P)(_U) instruction and DIV(P)(_U) instruction can be used for division of 16-bit binary data. /(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions divide the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d).
  • Page 239 Processing details • These instructions divide the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the division result in the device specified by (d). (s1) (s2) (d)+1 b0 b15 ···...
  • Page 240 DIV(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions divide the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DIVP(EN,s1,s2,d);...
  • Page 241 Processing details • These instructions divide the 16-bit binary data in the device specified by (s1) by the 16-bit binary data in the device specified by (s2), and store the division result in the device specified by (d). (s1) (s2) (d)+1 b0 b15 ···...
  • Page 242: Multiplying 32-Bit Binary Data

    Multiplying 32-bit binary data D*(P)(_U) instruction and DMUL(P)(_U) instruction can be used for multiplication of 32-bit binary data. D*(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions multiply the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d).
  • Page 243 Processing details • These instructions multiply the 32-bit binary data in the device specified by (s1) by the 32-bit binary data in the device specified by (s2), and store the multiplication result in the device specified by (d). (s1) (s2) (d)+2 (s1)+1 (s2)+1...
  • Page 244 DMUL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions multiply the 32-bit binary data in the device specified by (s1) and the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DMUL(EN,s1,s2,d);...
  • Page 245 Processing details • These instructions multiply the 32-bit binary data in the device specified by (s1) by the 32-bit binary data in the device specified by (s2), and store the multiplication result in the device specified by (d). (s1) (s2) (d)+2 (s1)+1 (s2)+1...
  • Page 246: Dividing 32-Bit Binary Data

    Dividing 32-bit binary data D/(P)(_U) instruction and DDIV(P)(_U) instruction can be used for division of 32-bit binary data. D/(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions divide the 32-bit binary data in the device specified by (s1) by the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d).
  • Page 247 Operation error Error code Description (SD0/SD8067) 2820H The device range specified by (d) exceeds the corresponding device range. 3400H 0 is specified for (s2) value. 7 BASIC INSTRUCTIONS 7.2 Arithmetic Operation Instructions...
  • Page 248 DDIV(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions divide the 32-bit binary data in the device specified by (s1) by the 32-bit binary data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DDIV(EN,s1,s2,d);...
  • Page 249 Precautions Operation result • The most significant bit of the quotient and remainder indicates the sign (positive: 0, negative: 1), respectively. • The quotient is negative when either (s1) or (s2) is negative. The remainder is negative when the (s1) is negative. Device specified by (d) •...
  • Page 250: Adding Bcd 4-Digit Data

    Adding BCD 4-digit data B+(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions add the BCD 4-digit data in the device specified by (d) and the BCD 4-digit data in the device specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 251 B+(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions add the BCD 4-digit data in the device specified by (s1) and the BCD 4-digit data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=BPLUS(EN,s1,s2,d);...
  • Page 252: Subtracting Bcd 4-Digit Data

    Subtracting BCD 4-digit data B-(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the BCD 4-digit data in the device specified by (d) and the BCD 4-digit data in the device specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 253 B-(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the BCD 4-digit data in the device specified by (s1) and the BCD 4-digit data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=BMINUS(EN,s1,s2,d);...
  • Page 254: Error Code

    Operation error Error code Description (SD0/SD8067) 3405H BCD data in the device specified by (s1) is outside of the valid range (0 to 9999). BCD data in the device specified by (s2) is outside of the valid range (0 to 9999). 7 BASIC INSTRUCTIONS 7.2 Arithmetic Operation Instructions...
  • Page 255: Adding Bcd 8-Digit Data

    Adding BCD 8-digit data DB+(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions add the BCD 8-digit data in the device specified by (d) and the BCD 8-digit data in the device specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 256 DB+(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions add the BCD 8-digit data in the device specified by (s1) and the BCD 8-digit data in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DBPLUS(EN,s1,s2,d);...
  • Page 257 Operation error Error code Description (SD0/SD8067) 3405H BCD data in the device specified by (s1) is outside of the valid range (0 to 99999999). BCD data in the device specified by (s2) is outside of the valid range (0 to 99999999). 7 BASIC INSTRUCTIONS 7.2 Arithmetic Operation Instructions...
  • Page 258: Subtracting Bcd 8-Digit Data

    Subtracting BCD 8-digit data DB-(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the BCD 8-digit data in the device specified by (d) and the BCD 8-digit data in the device specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 259 DB-(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the BCD 8-digit data specified by (s1) and the BCD 8-digit data specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=DBMINUS(EN,s1,s2,d);...
  • Page 260 Operation error Error code Description (SD0/SD8067) 3405H BCD data in the device specified by (s1) is outside of the valid range (0 to 99999999). BCD data in the device specified by (s2) is outside of the valid range (0 to 99999999). 7 BASIC INSTRUCTIONS 7.2 Arithmetic Operation Instructions...
  • Page 261: Multiplying Bcd 4-Digit Data

    Multiplying BCD 4-digit data B*(P) FX5S FX5UJ FX5U FX5UC These instructions multiply the BCD 4-digit data specified by (s1) and the BCD 4-digit data specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text Not supported (s1) (s2)
  • Page 262 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (d) exceeds the corresponding device range. 3405H BCD data in the device specified by (s1) is outside of the valid range (0 to 9999). BCD data in the device specified by (s2) is outside of the valid range (0 to 9999). 7 BASIC INSTRUCTIONS 7.2 Arithmetic Operation Instructions...
  • Page 263: Dividing Bcd 4-Digit Data

    Dividing BCD 4-digit data B/(P) FX5S FX5UJ FX5U FX5UC These instructions divide the BCD 4-digit data specified by (s1) by the BCD 4-digit data specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text Not supported (s1) (s2)
  • Page 264 Processing details • These instructions divide the BCD 4-digit data specified by (s1) by the BCD 4-digit data specified by (s2), and store the results of division in the device specified by (d). (s1) (s2) (d)+1 ÷ 0 is entered. (d): Quotient (d)+1: Remainder •...
  • Page 265: Multiplying Bcd 8-Digit Data

    Multiplying BCD 8-digit data DB*(P) FX5S FX5UJ FX5U FX5UC These instructions multiply the BCD 8-digit data specified by (s1) and the BCD 8-digit data specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text Not supported (s1) (s2)
  • Page 266 Processing details • These instructions multiply the BCD 8-digit data specified by (s1) and the BCD 8-digit data specified by (s2), and store the multiplication results in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) × (d)+3 (d)+2 (d)+1 •...
  • Page 267: Dividing Bcd 8-Digit Data

    Dividing BCD 8-digit data DB/(P) FX5S FX5UJ FX5U FX5UC These instructions divide the BCD 8-digit data specified by (s1) by the BCD 8-digit data specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text Not supported (s1) (s2)
  • Page 268 Processing details • These instructions divide the BCD 8-digit data specified by (s1) by the BCD 8-digit data specified by (s2), and store the results of division in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) ÷ 0 is entered. Quotient (d)+1 Remainder...
  • Page 269: Adding 16-Bit Binary Block Data

    Adding 16-bit binary block data BK+(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add (n) point(s) of 16-bit binary data from the device specified by (s1) and the (n) point(s) of 16-bit binary data from the device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=BKPLUS(EN,s1,s2,n,d);...
  • Page 270: Program Example

    Processing details • These instructions add (n) point(s) of 16-bit binary data from the device specified by (s1) and the (n) point(s) of 16-bit binary data from the device specified by (s2), and store the results of addition in the device specified by (d). •...
  • Page 271: Subtracting 16-Bit Binary Block Data

    Subtracting 16-bit binary block data BK-(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract (n) point(s) of 16-bit binary data from the device specified by (s1) and the (n) point(s) of 16-bit binary data from the device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=BKMINUS(EN,s1,s2,n,d);...
  • Page 272 Processing details • These instructions subtract (n) point(s) of 16-bit binary data from the device specified by (s1) and the (n) point(s) of 16-bit binary data from the device specified by (s2), and store the subtraction results in the device specified by (d). •...
  • Page 273: Adding 32-Bit Binary Block Data

    Adding 32-bit binary block data DBK+(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add (n) point(s) of 32-bit binary data from the device specified by (s1) and the (n) point(s) of 32-bit binary data from the device specified by (s2), and store the results of addition in the device specified by (d). Ladder diagram Structured text ENO:=DBKPLUS(EN,s1,s2,n,d);...
  • Page 274 If device is specified for (s2) (signed) ∙∙∙ ∙∙∙ ∙∙∙ (s2)+1, (s2) (s1)+1, (s1) 50000 (BIN) (BIN) -30000 (BIN) (d)+1, 20000 (s2)+3, (s1)+3, (s2)+2 (s1)+2 40000 (BIN) 20000 (BIN) (d)+2 60000 (BIN) (d)+3, (s2)+5, (s2)+4 (s1)+5, (s1)+4 -10000 (BIN) (BIN) -50000 (BIN) (d)+5,...
  • Page 275: Subtracting 32-Bit Binary Block Data

    Subtracting 32-bit binary block data DBK-(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract (n) point(s) of 32-bit binary data from the device specified by (s1) and the (n) point(s) of 32-bit binary data from the device specified by (s2), and store the results of subtraction in the device specified by (d). Ladder diagram Structured text ENO:=DBKMINUS(EN,s1,s2,n,d);...
  • Page 276 If device is specified for (s2) (signed) ∙∙∙ ∙∙∙ ∙∙∙ (s2)+1, (s2) (s1)+1, (s1) 44445 (BIN) (BIN) -55555 (BIN) (d)+1, -1000000 (s2)+3, (s1)+3, (s2)+2 (s1)+2 33333 (BIN) 3333 (BIN) (d)+2 30000 (BIN) (d)+3, (s2)+5, (s2)+4 (s1)+5, (s1)+4 -10000 (BIN) (BIN) 44444 (BIN) (d)+5,...
  • Page 277: Incrementing 16-Bit Binary Data

    Incrementing 16-bit binary data INC(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add 1 to the device (16-bit binary data) specified by (d). Ladder diagram Structured text ENO:=INC(EN,d); ENO:=INC_U(EN,d); ENO:=INCP(EN,d); ENO:=INCP_U(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 278 Program example MOVP 0→(Z0) Z0 is cleared by the reset input X10. The current values of counters C0 to C9 are converted into BCD format, and (C0Z0)→(K4Y0) BCDP C0Z0 K4Y0 output to K4Y0. Every time X11 is set to ON, the current INCP (Z0)+1→(Z0) values of C0, C1 ...
  • Page 279: Decrementing 16-Bit Binary Data

    Decrementing 16-bit binary data DEC(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract 1 from the device (16-bit binary data) specified by (d). Ladder diagram Structured text ENO:=DEC(EN,d); ENO:=DEC_U(EN,d); ENO:=DECP(EN,d); ENO:=DECP_U(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 280: Incrementing 32-Bit Binary Data

    Incrementing 32-bit binary data DINC(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add 1 to the device (32-bit binary data) specified by (d). Ladder diagram Structured text ENO:=DINC(EN,d); ENO:=DINC_U(EN,d); ENO:=DINCP(EN,d); ENO:=DINCP_U(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 281: Decrementing 32-Bit Binary Data

    Decrementing 32-bit binary data DDEC(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions subtract 1 from the device (32-bit binary data) specified by (d). Ladder diagram Structured text ENO:=DDEC(EN,d); ENO:=DDEC_U(EN,d); ENO:=DDECP(EN,d); ENO:=DDECP_U(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 282: Logical Operation Instructions

    Logical Operation Instructions Performing an AND operation on 16-bit data WAND(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions AND each bit of 16-bit binary data from the device specified by (d) and each bit of 16-bit binary data from device specified by (s), and store the results in the device specified by (d).
  • Page 283 WAND(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions AND each bit of 16-bit binary data from the device specified by (s1) and each bit of 16-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=WAND(EN,s1,s2,d);...
  • Page 284: Performing An And Operation On 32-Bit Data

    Performing an AND operation on 32-bit data DAND(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions AND each bit of 32-bit binary data from the device specified by (d) and each bit of 32-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 285 DAND(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions AND each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=DAND(EN,s1,s2,d);...
  • Page 286 Operation error There is no operation error. 7 BASIC INSTRUCTIONS 7.3 Logical Operation Instructions...
  • Page 287: Performing An And Operation On 16-Bit Block Data

    Performing an AND operation on 16-bit block data BKAND(P) FX5S FX5UJ FX5U FX5UC These instructions AND contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. Ladder diagram Structured text ENO:=BKAND(EN,s1,s2,n,d);...
  • Page 288 Processing details • These instructions AND contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. (s1)+(n-1) (s1)+1 (s1) … …...
  • Page 289: Performing An Or Operation On 16-Bit Data

    Performing an OR operation on 16-bit data WOR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions OR each bit of 16-bit binary data from the device specified by (d) and each bit of 16-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 290 WOR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions OR each bit of 16-bit binary data from the device specified by (s1) and each bit of 16-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=WOR(EN,s1,s2,d);...
  • Page 291: Performing An Or Operation On 32-Bit Data

    Performing an OR operation on 32-bit data DOR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions OR each bit of 32-bit binary data from the device specified by (d) and each bit of 32-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 292 DOR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions OR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=DOR(EN,s1,s2,d);...
  • Page 293 Processing details • These instructions OR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). (s1)+1 (s1) ∙∙∙...
  • Page 294: Performing An Or Operation On 16-Bit Block Data

    Performing an OR operation on 16-bit block data BKOR(P) FX5S FX5UJ FX5U FX5UC These instructions OR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. Ladder diagram Structured text ENO:=BKOR(EN,s1,s2,n,d);...
  • Page 295 Processing details • These instructions OR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. (s1)+(n-1) (s1)+1 (s1) … …...
  • Page 296: Performing An Xor Operation On 16-Bit Data

    Performing an XOR operation on 16-bit data WXOR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive OR each bit of 16-bit binary data from the device specified by (d) and each bit of 16-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 297 WXOR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive OR each bit of 16-bit binary data from the device specified by (s1) and each bit of 16-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=WXOR(EN,s1,s2,d);...
  • Page 298: Performing An Xor Operation On 32-Bit Data

    Performing an XOR operation on 32-bit data DXOR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive OR each bit of 32-bit binary data from the device specified by (d) and each bit of 32-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 299 DXOR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive OR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=DXOR(EN,s1,s2,d);...
  • Page 300 Processing details • These instructions exclusive OR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). (s1)+1 (s1) ∙∙∙...
  • Page 301: Performing An Xor Operation On 16-Bit Block Data

    Performing an XOR operation on 16-bit block data BKXOR(P) FX5S FX5UJ FX5U FX5UC These instructions exclusive OR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. Ladder diagram Structured text ENO:=BKXOR(EN,s1,s2,n,d);...
  • Page 302 Processing details • These instructions exclusive OR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onwards. (s1)+(n-1) (s1)+1 (s1) …...
  • Page 303: Performing An Xnor Operation On 16-Bit Data

    Performing an XNOR operation on 16-bit data WXNR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive NOR each bit of 16-bit binary data from the device specified by (d) and each bit of 16-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 304 WXNR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive NOR each bit of 16-bit binary data from the device specified by (s1) and each bit of 16-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=WXNR(EN,s1,s2,d);...
  • Page 305: Performing An Xnor Operation On 32-Bit Data

    Performing an XNOR operation on 32-bit data DXNR(P) [using two operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive NOR each bit of 32-bit binary data from the device specified by (d) and each bit of 32-bit binary data from device specified by (s), and store the results in the device specified by (d). Ladder diagram Structured text Not supported...
  • Page 306 DXNR(P) [using three operands] FX5S FX5UJ FX5U FX5UC These instructions exclusive NOR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). Ladder diagram Structured text ENO:=DXNR(EN,s1,s2,d);...
  • Page 307 Processing details • These instructions exclusive NOR each bit of 32-bit binary data from the device specified by (s1) and each bit of 32-bit binary data from device specified by (s2), and store the results in the device specified by (d). (s1)+1 (s1) (s1)
  • Page 308: Performing An Xnor Operation On 16-Bit Block Data

    Performing an XNOR operation on 16-bit block data BKXNR(P) FX5S FX5UJ FX5U FX5UC These instructions exclusive NOR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onward. Ladder diagram Structured text ENO:=BKXNR(EN,s1,s2,n,d);...
  • Page 309 Processing details • These instructions exclusive NOR contents of (n) point(s) from the device specified by (s1) and (n) point(s) from the device specified by (s2), and store the results in the devices specified by (d) onward. (s1)+(n-1) (s1)+1 (s1) XNOR (s2)+(n-1) (s2)+1...
  • Page 310: Bit Processing Instructions

    Bit Processing Instructions Setting a bit in the word device BSET(P) FX5S FX5UJ FX5U FX5UC These instructions set (to 1) (n)th bit of word device specified by (d). Ladder diagram Structured text ENO:=BSET(EN,n,d); ENO:=BSETP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 311: Resetting A Bit In The Word Device

    Resetting a bit in the word device BRST(P) FX5S FX5UJ FX5U FX5UC These instructions reset (to 0) (n)th bit of word device specified by (d). Ladder diagram Structured text ENO:=BRST(EN,n,d); ENO:=BRSTP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type...
  • Page 312: Performing A 16-Bit Test

    Performing a 16-bit test TEST(P) FX5S FX5UJ FX5U FX5UC These instructions take bit data at position specified by (s2) from device specified by (s1) and write to bit device specified by (d). Ladder diagram Structured text ENO:=TEST(EN,s1,s2,d); ENO:=TESTP(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 313 Processing details • These instructions take bit data at position specified by (s2) from device specified by (s1) and write to bit device specified by (d). ∙∙∙ ∙∙∙ (s1) (1): (s2) bit (When (s2)=5) • If relevant bit is "0", device specified by (d) is turned OFF, and if it is "1", device is turned ON. •...
  • Page 314: Performing A 32-Bit Test

    Performing a 32-bit test DTEST(P) FX5S FX5UJ FX5U FX5UC These instructions take bit data at position specified by (s2) from device specified by (s1) and write to bit device specified by (d). Ladder diagram Structured text ENO:=DTEST(EN,s1,s2,d); ENO:=DTESTP(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 315 Processing details • These instructions take bit data at position specified by (s2) from device specified by (s1), (s1) +1 and write to bit device specified by (d). ∙∙∙ ∙∙∙ ∙∙∙ (s1)+1 (s1) (1): (s2) bit (When (s2)=21) • If relevant bit is "0", device specified by (d) is turned OFF, and if it is "1", device is turned ON. •...
  • Page 316: Batch-Resetting Bit Devices

    Batch-resetting bit devices BKRST(P) FX5S FX5UJ FX5U FX5UC These instructions reset (n) point(s) bit devices from the bit device specified by (d). Ladder diagram Structured text ENO:=BKRST(EN,n,d); ENO:=BKRSTP(EN,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Head device to be reset ...
  • Page 317: Batch-Resetting Devices

    Batch-resetting devices ZRST(P) FX5S FX5UJ FX5U FX5UC These instructions reset all data among devices of same type specified by (d1) and (d2). Use these instructions for restarting operation from the beginning after pause or after resetting control data. Ladder diagram Structured text ENO:=ZRST(EN, d1, d2);...
  • Page 318 Processing details • These instructions reset all data among devices of same type specified by (d1) and (d2). • OFF (reset) is written to the entire range of devices from (d1) to (d2) all at once if (d1) and/or (d2) are bit devices. .
  • Page 319: Program Example

    Program example In the program shown below, when the power to the CPU module is turned ON or when the PLC mode is changed to RUN, the specified ranges of bit devices and word devices are reset at one time. SM402 M500 to M599 are reset at one time.
  • Page 320: Data Conversion Instructions

    Data Conversion Instructions Converting binary data to BCD 4-digit data BCD(P) FX5S FX5UJ FX5U FX5UC These instructions convert the binary data in the device specified by (s) to BCD data, and store the converted data in the device specified by (d). Binary data is used in operations in CPU module.
  • Page 321 • The table below shows digit specification for the data in the device specified by (s) and (d). CPU module BCD Y14 to Y10 to Y4 to Y0 to When "K4Y000" is specified Number of digits Data range K1Y0 1-digit 0 to 9 K2Y0 2-digit...
  • Page 322: Converting Binary Data To Bcd 8-Digit Data

    Converting binary data to BCD 8-digit data DBCD(P) FX5S FX5UJ FX5U FX5UC These instructions convert the binary data in the device specified by (s) to BCD data, and store the converted data in the device specified by (d). Binary data is used in operations in CPU module. Use this instruction to display numeric values on seven-segment display unit equipped with BCD decoder.
  • Page 323 • The table below shows digit specification for the data in the device specified by (s) and (d). CPU module DBCD DBCD Y34 to Y30 to Y24 to Y20 to Y14 to Y10 to Y4 to Y0 to When "K8Y0" is specified (d)+1, (d) Number of digits Data range...
  • Page 324: Converting Bcd 4-Digit Data To Binary Data

    Converting BCD 4-digit data to binary data BIN(P) FX5S FX5UJ FX5U FX5UC These instructions convert the binary-coded decimal data in the device specified by (s) to binary data, and store the converted data in the device specified by (d). Use this instruction to convert a binary-coded decimal (BCD) value such as a value set by a digital switch into binary (BIN) data and to receive the converted binary data so that the data can be handled in operations in CPU module.
  • Page 325 • The table below shows digit specification for the data in the device specified by (s) and (d). In case of K4X0 X14 to X10 to X4 to X0 to BIN CPU module Number of digits Data range K1X0 1-digit 0 to 9 K2X0 2-digit...
  • Page 326: Converting Bcd 8-Digit Data To Binary Data

    Converting BCD 8-digit data to binary data DBIN(P) FX5S FX5UJ FX5U FX5UC These instructions convert the binary-coded decimal data in the device specified by (s) to binary data, and store the converted data in the device specified by (d). Use this instruction to convert a binary-coded decimal (BCD) value such as a value set by a digital switch into binary (BIN) data and to receive the converted binary data so that the data can be handled in operations in CPU module.
  • Page 327 • The table below shows digit specification for the data in the device specified by (s) and (d). DBIN In case of K8X0 X34 to X30 to X24 to X20 to X14 to X10 to X4 to X0 to DBIN CPU module (s)+1, (s) Number of digits...
  • Page 328: Converting Single-Precision Real Number To 16-Bit Signed Binary Data

    Converting single-precision real number to 16-bit signed binary data FLT2INT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the single-precision real number in the device specified by (s) to 16-bit signed binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 329 Processing details • These instructions convert the single-precision real number in the device specified by (s) to 16-bit signed binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 330: Converting Single-Precision Real Number To 16-Bit Unsigned Binary Data

    Converting single-precision real number to 16-bit unsigned binary data FLT2UINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the single-precision real number in the device specified by (s) to 16-bit unsigned binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 331 Processing details • These instructions convert the single-precision real number in the device specified by (s) to 16-bit unsigned binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 332: Converting Single-Precision Real Number To 32-Bit Signed Binary Data

    Converting single-precision real number to 32-bit signed binary data FLT2DINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the single-precision real number in the device specified by (s) to 32-bit signed binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 333 Processing details • These instructions convert the single-precision real number in the device specified by (s) to 32-bit signed binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 334: Converting Single-Precision Real Number To 32-Bit Unsigned Binary Data

    Converting single-precision real number to 32-bit unsigned binary data FLT2UDINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the single-precision real number in the device specified by (s) to 32-bit unsigned binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 335 Processing details • These instructions convert the single-precision real number in the device specified by (s) to 32-bit unsigned binary data, and store the converted data in the device specified by (d). After conversion, the digits after the decimal point of the single- precision real number, specified with (s), are truncated.
  • Page 336: Converting 16-Bit Signed Binary Data To 16-Bit Unsigned Binary Data

    Converting 16-bit signed binary data to 16-bit unsigned binary data INT2UINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit signed binary data in the device specified by (s) to 16-bit unsigned binary data, and store the result in the device specified by (d). Ladder diagram Structured text ENO:=INT2UINT(EN,s,d);...
  • Page 337: Converting 16-Bit Signed Binary Data To 32-Bit Signed Binary Data

    Converting 16-bit signed binary data to 32-bit signed binary data INT2DINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit signed binary data in the device specified by (s) to 32-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=INT2DINT(EN,s,d);...
  • Page 338: Converting 16-Bit Signed Binary Data To 32-Bit Unsigned Binary Data

    Converting 16-bit signed binary data to 32-bit unsigned binary data INT2UDINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit signed binary data in the device specified by (s) to 32-bit unsigned binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=INT2UDINT(EN,s,d);...
  • Page 339: Converting 16-Bit Unsigned Binary Data To 16-Bit Signed Binary Data

    Converting 16-bit unsigned binary data to 16-bit signed binary data UINT2INT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit unsigned binary data in the device specified by (s) to 16-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UINT2INT(EN,s,d);...
  • Page 340: Converting 16-Bit Unsigned Binary Data To 32-Bit Signed Binary Data

    Converting 16-bit unsigned binary data to 32-bit signed binary data UINT2DINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit unsigned binary data in the device specified by (s) to 32-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UINT2DINT(EN,s,d);...
  • Page 341: Converting 16-Bit Unsigned Binary Data To 32-Bit Unsigned Binary Data

    Converting 16-bit unsigned binary data to 32-bit unsigned binary data UINT2UDINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit unsigned binary data in the device specified by (s) to 32-bit unsigned binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UINT2UDINT(EN,s,d);...
  • Page 342: Converting 32-Bit Signed Binary Data To 16-Bit Signed Binary Data

    Converting 32-bit signed binary data to 16-bit signed binary data DINT2INT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit signed binary data in the device specified by (s) to 16-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DINT2INT(EN,s,d);...
  • Page 343: Converting 32-Bit Signed Binary Data To 16-Bit Unsigned Binary Data

    Converting 32-bit signed binary data to 16-bit unsigned binary data DINT2UINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit signed binary data in the device specified by (s) to 16-bit unsigned binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DINT2UINT(EN,s,d);...
  • Page 344: Converting 32-Bit Signed Binary Data To 32-Bit Unsigned Binary Data

    Converting 32-bit signed binary data to 32-bit unsigned binary data DINT2UDINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit signed binary data in the device specified by (s) to 32-bit unsigned binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DINT2UDINT(EN,s,d);...
  • Page 345: Converting 32-Bit Unsigned Binary Data To 16-Bit Signed Binary Data

    Converting 32-bit unsigned binary data to 16-bit signed binary data UDINT2INT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit unsigned binary data in the device specified by (s) to 16-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UDINT2INT(EN,s,d);...
  • Page 346: Converting 32-Bit Unsigned Binary Data To 16-Bit Unsigned Binary Data

    Converting 32-bit unsigned binary data to 16-bit unsigned binary data UDINT2UINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit unsigned binary data in the device specified by (s) to 16-bit unsigned binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UDINT2UINT(EN,s,d);...
  • Page 347: Converting 32-Bit Unsigned Binary Data To 32-Bit Signed Binary Data

    Converting 32-bit unsigned binary data to 32-bit signed binary data UDINT2DINT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit unsigned binary data in the device specified by (s) to 32-bit signed binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UDINT2DINT(EN,s,d);...
  • Page 348: Converting 16-Bit Binary Data To Gray Code

    Converting 16-bit binary data to Gray code GRY(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit binary data in the device specified by (s) to 16-bit binary gray code data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=GRY(EN,s,d);...
  • Page 349: Converting 32-Bit Binary Data To Gray Code

    Converting 32-bit binary data to Gray code DGRY(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit binary data in the device specified by (s) to 32-bit binary gray code data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DGRY(EN,s,d);...
  • Page 350 Processing details • These instructions convert the 32-bit binary data in the device specified by (s) to 32-bit binary gray code data, and store the converted data in the device specified by (d). (s)+1 ∙∙∙ ∙∙∙ 305419896 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 (s) BIN (d)+1 ∙∙∙...
  • Page 351: Converting Gray Code To 16-Bit Binary Data

    Converting Gray code to 16-bit binary data GBIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit binary gray code data in the device specified by (s) to 16-bit binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=GBIN(EN,s,d);...
  • Page 352: Converting Gray Code To 32-Bit Binary Data

    Converting Gray code to 32-bit binary data DGBIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit binary gray code data in the device specified by (s) to 32-bit binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DGBIN(EN,s,d);...
  • Page 353 Processing details • These instructions convert the 32-bit binary gray code data in the device specified by (s) to 32-bit binary data, and store the converted data in the device specified by (d). (s)+1 ∙∙∙ ∙∙∙ 305419896 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 0 0 (d)+1 ∙∙∙...
  • Page 354: Converting Decimal Ascii To 16-Bit Binary Data

    Converting decimal ASCII to 16-bit binary data DABIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the decimal ASCII data in the device areas specified by (s) and later to 16-bit binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DABIN(EN,s,d);...
  • Page 355 Setting method of (s) for when SM705 (Number of conversion digits selection) is off Set decimal ASCII data with the fixed number of digits in (s) to (s)+2. ∙∙∙ ∙∙∙ ASCII 10 ASCII S ∙∙∙ (s)+1 ASCII 10 ASCII 10 (s)+2 ASCII 10 ASCII 10...
  • Page 356: Program Example

    Setting method of (s) for when SM705 (Number of conversion digits selection) is on Set decimal ASCII data with a desired number of digits (including 00H (NULL code)) in (s). Note that 00H (NULL code) is not required to be set if the integral part has the maximum number of digits (5 digits). The following table lists the setting method of (s).
  • Page 357 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (s) exceeds the corresponding device range. 3401H The sign data is other than 20H, 2DH. A value specified by (s) to (s)+2 for each place of the ASCII code is other than "30H" to "39H", "20H", and "00H". The ASCII data in the device specified by (s) to (s)+2 is out of the valid range (-32768 to +32767) (when a signed data is specified).
  • Page 358: Converting Decimal Ascii To 32-Bit Binary Data

    Converting decimal ASCII to 32-bit binary data DDABIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the decimal ASCII data in the device numbers specified by (s) and later to 32-bit binary data, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DDABIN(EN,s,d);...
  • Page 359 Processing details • These instructions convert the decimal ASCII data in the device numbers specified by (s) and later to 32-bit binary data, and store the converted data in the device specified by (d). • The setting method of the decimal ASCII data to be set in (s) depends on the status of SM705 (Number of conversion digits selection).
  • Page 360 Setting method of (s) for when SM705 (Number of conversion digits selection) is on Set decimal ASCII data with a desired number of digits (including 00H (NULL code)) in (s). Note that 00H (NULL code) is not required to be set if the integral part has the maximum number of digits (10 digits). The following table lists the setting method of (s).
  • Page 361 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (s) exceeds the corresponding device range. 3401H The sign data is other than 20H, 2DH. A value specified by (s) to (s)+2 for each place of the ASCII code is other than "30H" to "39H", "20H", and "00H". The ASCII data in the device specified by (s) to (s)+5 is out of the valid range (-2147483648 to +2147483647) (when a signed data is specified).
  • Page 362: Converting Ascii To Hex

    Converting ASCII to HEX HEXA(P) FX5S FX5UJ FX5U FX5UC These instructions convert the ASCII data stored in the number of characters specified by (n) in the device numbers specified by (s) and later to HEX code data, and store the converted data in the device numbers specified by (d) and later. Ladder diagram Structured text ENO:=HEXA(EN,s,n,d);...
  • Page 363 Processing details These instructions convert the ASCII data stored in the number of characters specified by (n) in the device numbers specified by (s) and later to HEX code data, and store the converted data in the device numbers specified by (d) and later. 16-bit conversion mode and 8-bit conversion mode options are available for these instructions.
  • Page 364 Number of specified characters and conversion result "" indicates "0". When (n)=K4 D200 D102 D101 D100 41H to "A" 30H to "0" D201 43H to "C" 42H to "B" 0ABH 0ABCH D100 ABC1H BC12H 0ABH C123H 0ABCH 1234H ABC1H 2345H (1): The data remain the same.
  • Page 365 Number of specified characters and conversion result "." indicates "0". When (n)=K2 D200 D102 D101 D100 30H to "0" D201 41H to "A" 0ABH 0ABCH D100 ABC1H BC12H 0ABH C123H 0ABCH 1234H ABC1H 2345H (1): The data remain the same. Precautions •...
  • Page 366: Converting Character String To 16-Bit Binary Data

    Converting character string to 16-bit binary data VAL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the character string in the device numbers specified by (s) and later to 16-bit binary data, and store the number of digits in the device specified by (d1) and the binary data in the device specified by (d2). Ladder diagram Structured text ENO:=VAL(EN,s,d1,d2);...
  • Page 367 Processing details • These instructions convert the character string in the device numbers specified by (s) and later to 16-bit binary data, and store the number of digits in the device specified by (d1) and the binary data in the device specified by (d2). When converting a character string into binary data, the data from the device number specified by (s) to a device number storing "00H"...
  • Page 368 Precautions • Store signed data, "space (20H)" or "- (2DH)" only in the 1st byte (low-order 8 bits of the head device set in (s)). Only the ASCII data "0 (30H)" to "9 (39H)", "space (20H)" and "decimal point (2EH)" can be stored from the 2nd byte to the "00H" at the end of the character string in (s).
  • Page 369: Converting Character String To 32-Bit Binary Data

    Converting character string to 32-bit binary data DVAL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert the character string in the device numbers specified by (s) and later to 32-bit binary data, and store the number of digits in the device specified by (d1) and the binary data in the device specified by (d2). Ladder diagram Structured text ENO:=DVAL(EN,s,d1,d2);...
  • Page 370 • The total number of digits stored in (d1) is the total number of characters (including the sign and decimal point) representing the numeric value. The number of digits in the decimal part stored in (d1)+1 is the number of characters representing the decimal part after 2EH (.).
  • Page 371 When "20H" exists between the sign and the first non-zero number (a signed value is specified) Total number of digits Number of digits of the decimal part 6 5 4 3 . BIN32 6 5 4 3 2 1 Ignore When "30H"...
  • Page 372: Two's Complement Of 16-Bit Binary Data (Sign Inversion)

    Two's complement of 16-bit binary data (sign inversion) NEG(P) FX5S FX5UJ FX5U FX5UC These instructions invert the sign of the 16-bit binary data in the device specified by (d), and store the resultant data in the device specified by (d). Ladder diagram Structured text ENO:=NEG(EN,d);...
  • Page 373 Precautions Note that data is inverted in every operation cycle in a continuous operation type (NEG) instruction. Program example The program examples below are provided to obtain the absolute value of a negative binary 16-bit data. • Obtaining the absolute value of a negative value using NEG instruction SM400 In BON (ON bit check) instruction, M0 turns ON when the bit 15 (b15 among b0 to b15) of D10 is "1".
  • Page 374: Two's Complement Of 32-Bit Binary Data (Sign Inversion)

    Two's complement of 32-bit binary data (sign inversion) DNEG(P) FX5S FX5UJ FX5U FX5UC These instructions invert the sign of the 32-bit binary data in the device specified by (d), and store the resultant data in the device specified by (d). Ladder diagram Structured text ENO:=DNEG(EN,d);...
  • Page 375: Decoding From 8 To 256 Bits

    Decoding from 8 to 256 bits DECO(P) FX5S FX5UJ FX5U FX5UC These instructions decode the lower-order (n) bits of the device specified by (s), and store the result in the 2 (to the power (n)) bit from the device specified by (d). Ladder diagram Structured text ENO:=DECO(EN,s,n,d);...
  • Page 376 Program example • When setting bit devices to ON according to the value of a data register The value of D0 (whose current value is "14" in this example) is decoded to M0 to M15. SM400 DECO 4 bits Ignored (D0 b0 to b3) (D0 b4 to b15) …...
  • Page 377: Encoding From 256 To 8 Bits

    Encoding from 256 to 8 bits ENCO(P) FX5S FX5UJ FX5U FX5UC These instructions encode the 2(n) bits of data from the device specified by (s), and store it in (d). Ladder diagram Structured text ENO:=ENCO(EN,s,n,d); ENO:=ENCOP(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 378: Error Code

    Operation error Error code Description (SD0/SD8067) 2820H The device specified by (s) exceeds the corresponding device range. 3401H The entire data from (s) to 2 number of bits is 0. (s) is specified as a bit device and (n) is other than 0 to 8. (s) is specified as a word device and (n) is other than 0 to 4.
  • Page 379: Seven-Segment Decoding

    Seven-segment decoding SEGD(P) FX5S FX5UJ FX5U FX5UC This instruction decodes data, and turns the seven-segment display unit (1 digit) ON. Ladder diagram Structured text ENO:=SEGD(EN,s,d); ENO:=SEGDP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Head device to be decoded -32768 to +32767 16-bit signed binary...
  • Page 380 Processing details • "0" to "F" (hexadecimal numbers) in low-order 4 bits (1 digit) of (s) are decoded to data for the seven-segment display unit, and stored in the low-order 8 bits of (d). Low-order 8 bits of (d) are occupied, and high-order 8 bits do not change. •...
  • Page 381: Seven Segment With Latch

    Seven Segment With Latch SEGL FX5S FX5UJ FX5U FX5UC This instruction controls one or two sets of 4-digit seven-segment display units having the latch function. Ladder diagram Structured text ENO:=SEGL(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 382 Processing details The 4-digit numeric value stored in (s) is converted into BCD data, and each digit is output to the seven-segment display unit with the BCD decoder by the time division method. For (s), binary data ranging from 0 to 9999 is valid. Set the parameters (n) as follows according to the positive/negative logic of the PLC and the positive/negative logic of the seven-segment display module.
  • Page 383 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (s) or (d) exceeds the corresponding device range. 3405H (n) is other than 0 to 7. The value specified by (s), (s)+1 is other than 0 to 9999. 1811H The number of the SEGL instructions which are used simultaneously exceeds four.
  • Page 384: Separating 4 Bits From 16-Bit Data

    Separating 4 bits from 16-bit data DIS(P) FX5S FX5UJ FX5U FX5UC These instructions store the data equivalent of the (n) nibbles (1-nibble/ 4-bits) of the 16-bit binary data specified by (s) in to the lower-order 4 bits of (n) number of devices starting from the one specified by (d). Ladder diagram Structured text ENO:=DIS(EN,s,n,d);...
  • Page 385 Program example In the program below, D0 is separated into 4 bit units and stored in D10 to D13 when X0 turns ON. DISP … … … … … b12 b11 b8 b7 b4 b3 b4 b3 b2 b1 They are set to "0". Data storage area Operation error Error code...
  • Page 386: Connecting 4 Bits To 16-Bit Data

    Connecting 4 bits to 16-bit data UNI(P) FX5S FX5UJ FX5U FX5UC These instructions link the lower-order 4 bits of the 16-bit binary data of the (n) number of devices starting from the one specified by (s) to the device storing 16-bit binary data specified by (d). Ladder diagram Structured text ENO:=UNI(EN,s,n,d);...
  • Page 387 Program example In the program below, the low-order 4 bits of D0 to D2 are combined and stored in D10 when X0 turns ON. UNIP … … … … … b4 b3 b12 b11 b4 b3 Combined data Because "n" is "K3", they are set to "0".
  • Page 388: Separating The Specified Number Of Bits

    Separating the specified number of bits NDIS(P) FX5S FX5UJ FX5U FX5UC These instructions separate each bit of the data in the device numbers specified by (s1) onwards into bit units specified by (s2), and store the separated data in the device number specified by (d) onwards. Ladder diagram Structured text ENO:=NDIS(EN,s1,s2,d);...
  • Page 389 Processing details • These instructions separate each bit of the data in the device numbers specified by (s1) and later into bit units specified by (s2), and store the separated data in the device numbers starting from the one specified by (d). (s2) (s2)+1 (s2)+2...
  • Page 390: Connecting The Specified Number Of Bits

    Connecting the specified number of bits NUNI(P) FX5S FX5UJ FX5U FX5UC These instructions link each bit of the data in the device numbers specified by (s1) onwards into bit units specified by (s2), and store the connected data in the device number specified by (d) onwards. Ladder diagram Structured text ENO:=NUNI(EN,s1,s2,d);...
  • Page 391 Processing details • These instructions link each bit of the data in the device numbers specified by (s1) onwards into bit units specified by (s2), and store the linked data in the device number specified by (d). (s2) (s2)+1 (s2)+2 (s2)+3 (s2)+4 (s2)+5...
  • Page 392: Separating Data In Byte Units

    Separating data in byte units WTOB(P) FX5S FX5UJ FX5U FX5UC These instructions separate the 16-bit binary data in the device numbers starting from the one specified by (s) onwards into (n) byte units, and store the separated data in the device number specified by (d) onwards. Ladder diagram Structured text ENO:=WTOB(EN,s,n,d);...
  • Page 393 For example, when (n) is 5, data starting from (s) to the lower 8 bits of (s)+2 is stored into (d) through (d)+4. ∙∙∙ ∙∙∙ ∙∙∙ ∙∙∙ (d)+1 (s)+1 (d)+2 (s)+2 (d)+3 (d)+4 (1): The data FEH is ignored when (n) is 5. (2): When (n) is 5 •...
  • Page 394: Connecting Data In Byte Units

    Connecting data in byte units BTOW(P) FX5S FX5UJ FX5U FX5UC These instructions link the lower-order 8 bits of the 16-bit binary data of (n) number of bytes stored in the device numbers starting from the one specified by (s) onwards into word units, and store the linked data in the device numbers starting from the one specified by (d) onwards.
  • Page 395 Processing details • These instructions link the lower-order 8 bits of the 16-bit binary data of (n) number of bytes stored in the device numbers starting from the one specified by (s) onwards into word units, and store the linked data in the device numbers starting from the one specified by (d) onwards.
  • Page 396 Program example In the program shown below, the low-order 8-bits data stored in D20 to D25 is combined, and stored in D10 to D12 when X0 is set to ON. BTOWP … b8 b7 … … b8 b7 … 6 bytes The high-order bytes is ignored.
  • Page 397: Digital Switch

    Digital Switch FX5S FX5UJ FX5U FX5UC This instruction reads the set value of digital switches. This instruction can read a set of 4 digits (n = K1) or two sets of 4 digits (n = K2). Ladder diagram Structured text ENO:=DSW(EN,s,n,d1,d2);...
  • Page 398 Processing details The value of each digital switch connected to (s) is input by the time division method (in which the value is input in turn from the 1st digit by 100 ms interval output signal), and stored to (d2). A numeric value from 0 to 9999 (up to 4 digits) can be read, the first set is stored to (d2), and the second set is stored to (d2)+1.
  • Page 399: Data Transfer Instructions

    Data Transfer Instructions Transferring 16-bit data MOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer the 16-bit binary data in the device specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=MOV(EN,s,d); ENO:=MOVP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 400 Program example • When reading the current value of a timer and counter (Current value of T0) → (D20) The operation is the same as a counter. • When indirectly specifying the set value of a timer or counter As the set value of the timer T20, two values can be specified by turning ON or OFF the switch X2. For specifying more than two set values, more than one switch is required.
  • Page 401: Transferring 32-Bit Data

    Transferring 32-bit data DMOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer the 32-bit binary data in the device specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=DMOV(EN,s,d); ENO:=DMOVP(EN,s,d) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 402 Program example Make sure to use DMOV instruction for transferring an instruction (such as MUL instruction) whose operation result is output in 32 bits, a 32-bit numeric value or a 32-bit device. (D1, D0) → (D11, D10) DMOV D0(D1) D10(D11) (Current value of LC0) →...
  • Page 403: Inverting And Transferring 16-Bit Data

    Inverting and transferring 16-bit data CML(P) FX5S FX5UJ FX5U FX5UC These instructions invert each bit of the 16-bit binary data in the device specified by (s), and transfer the result to the device specified by (d). Ladder diagram Structured text ENO:=CML(EN,s,d);...
  • Page 404 Program example • When receiving an inverted input The sequence program shown below can be written by CML instruction. SM400 K1X0 K1M0 RUN monitor • When four bits are specified for a device with digit specification (D0) → (K1Y0) K1Y0 Sign bit (0: Positive, 1: Negative) X0=ON K1Y0...
  • Page 405: Inverting And Transferring 32-Bit Data

    Inverting and transferring 32-bit data DCML(P) FX5S FX5UJ FX5U FX5UC These instructions invert each bit of the 32-bit binary data in the device specified by (s), and transfer the result to the device specified by (d). Ladder diagram Structured text ENO:=DCML(EN,s,d);...
  • Page 406: Digit Move

    Digit move SMOV(P) FX5S FX5UJ FX5U FX5UC These instructions distribute and compose data in units of nibble (4 bits). Ladder diagram Structured text ENO:=SMOV(EN,s,n1,n2,n3,d); ENO:=SMOVP(EN,s,n1,n2,n3,d); (n1) (n2) (n3) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 407: Extension Function

    Processing details These instructions distribute and compose data in units of nibble (4 bits). The contents of the transfer source (s) and transfer destination (d) are converted into 4-digit BCD (0000 to 9999). (n2) nibbles starting from the (n1)th nibble are transferred to the transfer destination (d) starting from the (n3)th nibble, converted into binary, and then stored to the transfer destination (d).
  • Page 408: Inverting And Transferring 1-Bit Data

    Inverting and transferring 1-bit data CMLB(P) FX5S FX5UJ FX5U FX5UC These instructions invert the bit data in the device specified by (s), and transfer the result into the device specified by (d). Ladder diagram Structured text ENO:=CMLB(EN,s,d); ENO:=CMLBP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 409: Transferring 16-Bit Block Data (65535 Points Maximum)

    Transferring 16-bit block data (65535 points maximum) BMOV(P) FX5S FX5UJ FX5U FX5UC These instructions block transfer the 16-bit binary data of (n) number of devices starting from the one specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=BMOV(EN,s,n,d);...
  • Page 410 Processing details • These instructions block transfer the 16-bit binary data of (n) number of devices starting from the one specified by (s) to the device specified by (d). ∙∙∙ ∙∙∙ 1234H 1234H (s)+1 5678H 5678H (d)+1 (s)+2 7FF0H 7FF0H (d)+2 (s)+(n-2) 6FFFH...
  • Page 411: Transferring Identical 16-Bit Block Data (65535 Points Maximum)

    Transferring identical 16-bit block data (65535 points maximum) FMOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer (n) point(s) of data identical to the 16-bit binary data in the device specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=FMOV(EN,s,n,d);...
  • Page 412 Precautions When the value specified in (n) is 0, an operation error does not occur, but no processing is performed. Program example • When writing specified data to two or more devices FMOV Before execution After execution …… → …… →...
  • Page 413: Transferring Identical 32-Bit Block Data (65535 Points Maximum)

    Transferring identical 32-bit block data (65535 points maximum) DFMOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer (n) point(s) of data identical to the 32-bit binary data in the device specified by (s) to the device specified by (d). (65535 points maximum) Ladder diagram Structured text ENO:=DFMOV(EN,s,n,d);...
  • Page 414 Precautions When the value specified in (n) is 0, an operation error does not occur, but no processing is performed. Operation error There is no operation error. 7 BASIC INSTRUCTIONS 7.7 Data Transfer Instructions...
  • Page 415: Exchanging 16-Bit Data

    Exchanging 16-bit data XCH(P) FX5S FX5UJ FX5U FX5UC These instructions exchange 16-bit binary data of (d1) and (d2). Ladder diagram Structured text ENO:=XCH(EN,d1,d2); ENO:=XCHP(EN,d1,d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) (d1) Head device for storing the data to be exchanged ...
  • Page 416 Program example This program exchanges the contents of D1 and D2 when X1 is set to ON. XCHP Operation error There is no operation error. 7 BASIC INSTRUCTIONS 7.7 Data Transfer Instructions...
  • Page 417: Exchanging 32-Bit Data

    Exchanging 32-bit data DXCH(P) FX5S FX5UJ FX5U FX5UC These instructions exchange 32-bit binary data of (d1) and (d2). Ladder diagram Structured text ENO:=DXCH(EN,d1,d2); ENO:=DXCHP(EN,d1,d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) (d1) Head device for storing the data to be exchanged ...
  • Page 418 Program example This program exchanges the contents of D0, D1 and D2, D3 when X2 is set to ON. DXCHP Operation error There is no operation error. 7 BASIC INSTRUCTIONS 7.7 Data Transfer Instructions...
  • Page 419: Exchanging The Upper And Lower Bytes Of 16-Bit Data

    Exchanging the upper and lower bytes of 16-bit data SWAP(P) FX5S FX5UJ FX5U FX5UC These instructions swap the value of 8 bits of the upper and lower bytes of the device specified by (d). Ladder diagram Structured text ENO:=SWAP(EN,d); ENO:=SWAPP(EN,d); FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 420: Exchanging The Upper And Lower Bytes Of 32-Bit Data

    Exchanging the upper and lower bytes of 32-bit data DSWAP(P) FX5S FX5UJ FX5U FX5UC These instructions swap the value of 8 bits of the upper and lower bytes of the devices specified by (d) and (d)+1. Ladder diagram Structured text ENO:=DSWAP(EN,d);...
  • Page 421: Transferring 1-Bit Data

    Transferring 1-bit data MOVB(P) FX5S FX5UJ FX5U FX5UC These instructions store bit data specified by (s) to (d). Ladder diagram Structured text ENO:=MOVB(EN,s,d); ENO:=MOVBP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Head device for storing the transfer-source data ...
  • Page 422: Transferring Octal Bits (16-Bit Data)

    Transferring octal bits (16-bit data) PRUN(P) FX5S FX5UJ FX5U FX5UC These instructions handle the device number of (s) and (d) with digit specification as octal numbers, and transfer data. Ladder diagram Structured text ENO:=PRUN(EN,s,d); ENO:=PRUNP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 423 • Decimal bit device  Octal bit device Command input M0 to M7, M10 to M17 → Y0 to Y17 PRUN K4M0 K4Y0 Not transferred Decimal bit device (M) Octal bit device (X) Operation error Error code Description (SD0/SD8067) 2820H The devices specified by (s) and (d) exceed the range of the corresponding device.
  • Page 424: Transferring Octal Bits (32-Bit Data)

    Transferring octal bits (32-bit data) DPRUN(P) FX5S FX5UJ FX5U FX5UC These instructions handle the device number of (s) and (d) with digit specification as octal numbers, and transfer data. Ladder diagram Structured text ENO:=DPRUN(EN,s,d); ENO:=DPRUNP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 425 • Decimal bit device  Octal bit device Command input M0 to M7, M10 to M17,M20 to M27 → Y0 to Y27 DPRUN K6M0 K6Y0 Decimal bit device (M) Not transferred Not transferred Octal bit device (X) Operation error Error code Description (SD0/SD8067) 2820H...
  • Page 426: Transferring N-Bit Data

    Transferring n-bit data BLKMOVB(P) FX5S FX5UJ FX5U FX5UC These instructions block transfer the bit data of (n) point(s) from the device specified by (s) to the bit data of (n) point(s) from the device specified by (d). Ladder diagram Structured text ENO:=BLKMOVB(EN,s,n,d);...
  • Page 427 Processing details • These instructions block transfer the bit data of (n) point(s) from the device specified by (s) to the bit data of (n) point(s) from the device specified by (d). • Data can be transferred even when the device range of the transfer-source device and transfer-destination device is overlapping.
  • Page 428: Chapter 8 Application Instruction

    APPLICATION INSTRUCTION Rotation Instruction Rotating 16-bit data to the right ROR(P), RCR(P) FX5S FX5UJ FX5U FX5UC • ROR(P): These instructions rotate the 16-bit binary data in the device specified by (d) to the right by (n) bit(s) (not including the carry flag). •...
  • Page 429 Processing details ROR(P) • These instructions rotate the 16-bit binary data in the device specified by (d) to the right by (n) bit(s) (not including the carry flag). The carry flag is on or off depending on the status prior to the execution of the instruction. (SM700, SM8022) Rotating 1-bit data to the right (SM700, SM8022)
  • Page 430 • When (d) is a bit device, bits are rotated to the right within the device range specified by digit specification. The number of bits actually to be rotated is the remainder of (n)(specified number of bits). For example, when (n) is 15 and the specified number of bits is 12, 3 bits are rotated because 15 divided by 12 equals 1 with a remainder of 3.
  • Page 431: Rotating 16-Bit Data To The Left

    Rotating 16-bit data to the left ROL(P), RCL(P) FX5S FX5UJ FX5U FX5UC • ROL(P): These instructions rotate the 16-bit binary data in the device specified by (d) to the left by (n) bit(s) (not including the carry flag). • RCL(P): These instructions rotate the 16-bit binary data in the device specified by (d) to the left by (n) bit(s) (including the carry flag).
  • Page 432 Processing details ROL(P) • These instructions rotate the 16-bit binary data in the device specified by (d) to the left by (n) bit(s) (not including the carry flag). The carry flag is on or off depending on the status prior to the execution of the instruction. (SM700, SM8022) b14 b13 b12 b11 b10 Rotating 1-bit data to the left...
  • Page 433 RCL(P) • These instructions rotate the 16-bit binary data in the device specified by (d) to the left by (n) bit(s) (including the carry flag). The carry flag is on or off depending on the status prior to the execution of the instruction. (SM700, SM8022) b14 b13 b12 b11 b10 Rotating 1-bit data to the left...
  • Page 434: Rotating 32-Bit Data To The Right

    Rotating 32-bit data to the right DROR(P), DRCR(P) FX5S FX5UJ FX5U FX5UC • DROR(P): These instructions rotate the 32-bit binary data in the device specified by (d) to the right by (n) bit(s) (not including the carry flag). • DRCR(P): These instructions rotate the 32-bit binary data in the device specified by (d) to the right by (n) bit(s) (including the carry flag).
  • Page 435 DRCR(P) • These instructions rotate the 32-bit binary data in the device specified by (d) to the right by (n) bit(s) (including the carry flag). The carry flag is on or off depending on the status prior to the execution of the instruction. (d)+1 (SM700, SM8022) b30 b29 b28 b27...
  • Page 436: Rotating 32-Bit Data To The Left

    Rotating 32-bit data to the left DROL(P), DRCL(P) FX5S FX5UJ FX5U FX5UC • DROL(P): These instructions rotate the 32-bit binary data in the device specified by (d) to the left by (n) bit(s) (not including the carry flag). • DRCL(P): These instructions rotate the 32-bit binary data in the device specified by (d) to the left by (n) bit(s) (including the carry flag).
  • Page 437 DRCL(P) • These instructions rotate the 32-bit binary data in the device specified by (d) to the left by (n) bit(s) (including the carry flag). The carry flag is on or off depending on the status prior to the execution of the instruction. (d)+1 (SM700, SM8022) b30 b29 b28 b27...
  • Page 438: Program Branch Instruction

    Program Branch Instruction Pointer branch CJ(P) FX5S FX5UJ FX5U FX5UC These instructions execute the program specified by the pointer number within the same program file when the jump command is on. Ladder diagram Structured text Not supported FBD/LD Not supported. Setting data Descriptions, ranges, and data types Operand...
  • Page 439 • These instructions can specify and jump from the current step to a smaller step number. In this case, consider a method to exit a loop so that the watchdog timer does not time out. (1) While X3 is on, the loop is repeated. (2) To exit the loop, turn on X7.
  • Page 440 • When the pointer number in operands is same and there is one label, the following operation is caused: (1) When X20 turns ON, the program execution jumps from CJ instruction corresponding to X20 to the label P9. (2) When X20 turns OFF and X21 turns ON, the program execution jumps from CJ instruction corresponding to X21 to the label P9.
  • Page 441 • In one operation cycle after X23 changes from OFF to ON, the CJ instruction becomes valid. By using this method, jump can be executed after all outputs between the CJ instruction and the label P7 turn OFF. INCP Operation error Error code Description (SD0/SD8067)
  • Page 442: Jump To End

    Jump to END GOEND FX5S FX5UJ FX5U FX5UC This instruction moves the program execution to the FEND or END instruction in the same program file. Ladder diagram Structured text Not supported FBD/LD Not supported. Processing details • This instruction moves the program execution to the FEND or END instruction in the same program file. Precautions •...
  • Page 443: Program Execution Control Instruction

    Program Execution Control Instruction Disabling/enabling interrupt programs DI, EI FX5S FX5UJ FX5U FX5UC Interrupts are usually disabled in CPU module. These instructions enable interrupts in CPU module (EI instruction) or disable interrupts again (DI instruction). • DI: Disables the execution of the interrupt program. •...
  • Page 444 • An interrupt pointer occupies two steps. (In (1) below, I10 is the step 50, X2 is the step 52, and Y10 is the step 54.) IRET • If the master control contains the EI or DI instruction, such an instruction is executed regardless of the execution of the MC instruction.
  • Page 445: Disabling The Interrupt Program With Specified Priority Or Lower

    Disabling the interrupt program with specified priority or lower FX5S FX5UJ FX5U FX5UC This instruction disables the execution of the interrupt program with a priority specified by (s) or lower until the EI instruction is executed, even if the interrupt cause occurs. Ladder diagram Structured text ENO:=DI_1(EN,s);...
  • Page 446 • By executing the EI instruction, the interrupt with the priority disabled by the counterpart DI instruction is enabled. However, when interrupts are disabled only with the DI instruction without an argument, interrupts with all the priorities are enabled by executing the EI instruction once.
  • Page 447 • When the DI instruction is executed in an interrupt program DI K2 IRET DI K3 A: Scan execution type program B: Interrupt Program (1): Interrupt-enabled section for all priority (2): Interrupt-disabled section for the priority 3 or lower (interrupt-enabled section for the priority 2 or higher) (3): Interrupt-disabled section for the priority 2 or lower (interrupt-enabled section for the priority 1 or higher) •...
  • Page 448 Operation error Error code Description (SD0/SD8067) 3405H The value specified by (s) is other than the following. 1 to 3 3362H Nesting of the DI instruction exceeds 16 levels. 8 APPLICATION INSTRUCTION 8.3 Program Execution Control Instruction...
  • Page 449: Interrupt Program Mask

    Interrupt program mask IMASK FX5S FX5UJ FX5U FX5UC This instruction enables or disables the execution of the interrupt program with the specified interrupt pointer number according to the 16-point bit pattern starting from the device specified in (s). Ladder diagram Structured text ENO:=IMASK(EN,s);...
  • Page 450 • The following shows the assignment of the interrupt pointer numbers to each bit. b14 b13 b12 b11 b10 b9 b6 b5 b4 b3 b2 b1 I14 I13 I12 I11 I10 I9 (s)+1 I30 I29 I28 I22 I21 I20 I19 I18 I17 (s)+2 (s)+3 I62 I61 I60 I59 I58 I57...
  • Page 451: Disabling/Enabling The Specified Interrupt Pointer

    Disabling/enabling the specified interrupt pointer SIMASK FX5S FX5UJ FX5U FX5UC This instruction enables or disables the interrupt pointer number specified by (I) according to the value of (s). Ladder diagram Structured text ENO:=SIMASK(EN,In,s); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 452 • The execution-enabled/disabled states of interrupt pointers are stored in the IMASK instruction mask pattern. FX5S CPU module IMASK instruction mask pattern: SD1400 to SD1401 FX5UJ/FX5U/FX5UC CPU module IMASK instruction mask pattern: SD1400 to SD1411 Operation error Error code Description (SD0/SD8067) 3405H The interrupt pointer number specified by (I) exceeds the range of the interrupt pointer number (I0 to I177).
  • Page 453: Returning From The Interrupt Program

    Returning from the interrupt program IRET FX5S FX5UJ FX5U FX5UC This instruction indicates an end of the processing of an interrupt program. Ladder diagram Structured text Not supported FBD/LD Not supported. Processing details When an interrupt (input or timer) is generated while the main program is executing, the program execution jumps to an interrupt (I) routine.
  • Page 454 [high-speed comparison match interrupt] Navigation window  [Parameter]  Module model name  [Module Parameter]  [High Speed I/O]  "Input Function"  "High Speed Counter"  "Detailed Setting"  "Basic Settings" Navigation window  [Parameter]  Module model name  [Module Parameter]  [High Speed I/O]  "Input Function" ...
  • Page 455 • Program SM402 HIOEN Interrupts are usually disabled in CPU modules. C255 HIOEN Turn ON X7 and use EI instruction to enable interrupts. C255EI Main When X0 turns ON while the main program program is executed, instructions after the input SM400 interrupt routine pointer I0 are executed, and the program execution returns to the...
  • Page 456: Resetting The Watchdog Timer

    Resetting the watchdog timer WDT(P) FX5S FX5UJ FX5U FX5UC These instructions reset the watchdog timer in a program. Ladder diagram Structured text ENO:=WDT(EN); ENO:=WDTP(EN); FBD/LD Processing details • These instructions reset the watchdog timer in a program. • These instructions are used when the scan time exceeds the value set for the watchdog timer depending on the condition. If the scan time exceeds the value set for the watchdog timer every scan, change the setting of the watchdog timer in the parameter setting of the engineering tool.
  • Page 457: Structuring Instruction

    Structuring Instruction FOR to NEXT FOR, NEXT FX5S FX5UJ FX5U FX5UC When the processing between the FOR and NEXT instructions is executed (n) times without any condition, the processing of the step following the NEXT instruction is executed. Ladder diagram Structured text Not supported NEXT...
  • Page 458 Precautions • The FOR-NEXT loop can be nested up to 16 levels. 3rd level 2nd level 2nd level 1st level NEXT 1st level NEXT 1st level NEXT NEXT NEXT NEXT • The FOR-NEXT loop cannot be interrupted by the I, IRET, SRET, RET, FEND, or END instruction. •...
  • Page 459 Program example • Program with three FOR-NEXT loops The loop (3) is repeated 4 times. SM402 D0Z0 When the data value (current value) of D0Z0 (D4 when Z0 is "4") is "6", the loop (2) is repeated 6 times. SM402 K1X0 •...
  • Page 460: Forcibly Terminating The For To Next Instruction Loop

    Forcibly terminating the FOR to NEXT instruction loop BREAK(P) FX5S FX5UJ FX5U FX5UC This instruction forcibly terminates the FOR to NEXT instruction loop and shifts the program execution to the pointer specified by (P). Ladder diagram Structured text Not supported FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 461 • The BREAK(P) instructions can be used for only one nesting level. To forcibly terminate multiple nesting levels, execute as many BREAK(P) instructions as the number of nesting levels. Precautions • If the branch pointer number of the BREAK instruction outside two nesting levels or more is specified, an operation error occurs and the program execution stops when the BREAK instruction is executed.
  • Page 462: Calling A Subroutine Program

    Calling a subroutine program CALL(P) FX5S FX5UJ FX5U FX5UC This instruction executes the subroutine program specified by (P). Ladder diagram Structured text Not supported FBD/LD Not supported. Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 463 • While the command input is ON, the CALL instruction is executed and the program execution jumps to a step with a label (Pn). Then, a subroutine program with the label (Pn) is executed. When the RET (SRET) instruction is executed, the program execution returns to the step following the CALL instruction.
  • Page 464 • Devices which were set to ON in a subroutine (or interrupt routine) are latched in the ON status even after the subroutine is finished. (Refer to the program example shown below). When the RST instruction for a timer or counter is executed, the reset status of the timer or counter is latched also.
  • Page 465 Example in which latched outputs are reset (countermeasures) [Program example] (1): Program to reset Y7 at an arbitrary timing (2): Program to reset the preceding C0 reset CALLP instruction inside the subroutine FEND SM401 RUN Monitor (normally OFF) [Timing chart] A: Execution of subroutine P0 triggered by X0 Subroutine is executed.
  • Page 466 Program example • Example of fundamental use (no nesting) CALL SM400 Main program While X0 is ON, the program execution jumps to a step with the label P10. FEND SM400 Subroutine program When RET instruction is executed after the subroutine program has executed, the program execution returns to the original step +1.
  • Page 467: Returning From The Subroutine Program

    Returning from the subroutine program RET/SRET FX5S FX5UJ FX5U FX5UC These instructions indicate an end of a subroutine program. The RET instruction can be used as SRET. Ladder diagram Structured text Not supported FBD/LD Not supported. Processing details • These instructions indicate an end of a subroutine program. •...
  • Page 468: Calling A Subroutine Program

    Calling a subroutine program XCALL FX5S FX5UJ FX5U FX5UC This instruction executes CALL for (turns on and executes) the subroutine program specified by (P) when the execution condition is established. When the condition is turned off, this instruction executes turns off and terminates for the subroutine program.
  • Page 469 • The XCALL instruction can be nested up to 16 levels. However, the 16 levels are the total of the CALL(P) and XCALL instructions. XCALL XCALL XCALL FEND Operation error Error code Description (SD0/SD8067) 3360H The 17th level of the nesting is executed. 3380H The subroutine program specified by the pointer in the XCALL instruction does not exist.
  • Page 470: Data Table Operation Instruction

    Data Table Operation Instruction Reading the oldest data from the data table SFRD(P) FX5S FX5UJ FX5U FX5UC These instructions read data for first-in first-out control. Ladder diagram Structured text ENO:=SFRD(EN,s,n,d); ENO:=SFRDP(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type...
  • Page 471 Processing details • These instructions transfer (read) (s)+1, which was sequentially written by the SFWR instruction, to (d), and shift the word data of (n)-1 points starting from (s)+1 upward by 1 word. Then, these instructions decrease the number of data points stored in (s) by 1.
  • Page 472 Program example Button for request to put a product into warehouse The product number is input from X0 to X17, and MOVP K4X0 D256 transferred to D256. Pointer SFWRP D257: Data register for storing the product number D256 D257 K100 D258 to D356 (99 points) Button for request to take a product out of warehouse...
  • Page 473: Reading The Newest Data From The Data Table

    Reading the newest data from the data table POP(P) FX5S FX5UJ FX5U FX5UC These instructions read the latest data written by a shift write (SFWR) instruction for FIFO/FILO control. Ladder diagram Structured text ENO:=POP(EN,s,n,d); ENO:=POPP(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 474 Processing details • Every time the instruction is executed for the word devices (s) to (s)+(n)-1, a device "(s) + Pointer data (s)" is read to (d). (The last data entry written by the shift write (SFWR) instruction for first-in first-out control is read to (d).) Specify any value between 2 and 32767 for (n).
  • Page 475 Program example Among values stored in D20 input first to D101 to D106, the last value input is stored to D10, and "1" is subtracted from the number of stored data (pointer D100) every time X0 turns ON. First-in command SFWR D100 Last-in read command...
  • Page 476: Writing Data To The Data Table

    Writing data to the data table SFWR(P) FX5S FX5UJ FX5U FX5UC These instructions write data for first-in first-out (FIFO) and last-in first-out (LIFO) control. Ladder diagram Structured text ENO:=SFWR(EN,s,n,d); ENO:=SFWRP(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 477 Processing details • The contents of (s) are written to "(n)-1" devices from (d)+1, and "1" is added to the number of data stored in (d). For example, for (d)=0, the contents are written to (d)+1, and for (d)=1, to (d)+2. Pointer Pointer (d)+1 →...
  • Page 478: Inserting Data To The Data Table

    Inserting data to the data table FINS(P) FX5S FX5UJ FX5U FX5UC These instructions insert 16-bit data specified by (s) to the data table specified by (d) as the (n)th data. After these instructions are executed, the data after the (n)th data in the data table is moved down by one data point. Ladder diagram Structured text ENO:=FINS(EN,s,n,d);...
  • Page 479 Precautions • The device range used in a data table should be controlled by the user. • The data table has (d) number of stored data starting from ((d)+1). Program example In the program shown below, data stored in D100 is inserted into the 3rd position of the data table stored in D0 to D4 when X10 is set to ON.
  • Page 480: Deleting Data From The Data Table

    Deleting data from the data table FDEL(P) FX5S FX5UJ FX5U FX5UC These instructions remove the (n)th data in the data table specified by (d) and store the data in the device specified by (s). After these instructions are executed, the data after the (n)+1th data in the data table is moved up by one data point. Ladder diagram Structured text ENO:=FDEL(EN,s,n,d);...
  • Page 481 Precautions • The device range used in a data table should be controlled by the user. • The data table has (d) number of stored data starting from ((d)+1). Program example In the program shown below, the 2nd data value entry is deleted from the data table stored in D100 to D105 when X10 is set to ON, and the deleted data is stored in D0.
  • Page 482: Reading/Writing Data Instructions

    Reading/writing Data Instructions Reading/Writing data to data memory The data write instruction is an instruction to write arbitrary device data to data memory. Writing the fixed values used for operation and operation results to data memory can prevent data loss when the battery is low.
  • Page 483: Reading Data From The Data Memory

    Reading data from the data memory S(P).DEVLD FX5S FX5UJ FX5U FX5UC Reads data from the device data storage file in data memory. Ladder diagram Structured text ENO:=S_DEVLD(EN,s,n,d); ENO:=SP_DEVLD(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Read offset of device data storage file (specified in units of 0 to 63...
  • Page 484 Processing details • These instructions read device data by the number of points specified by (n) from the read offset specified by (s) in the device data storage file in data memory, and store it in the device specified by (d). (s) indicates the offset from the start of the device data storage file and can be specified by word offsets (incremented by 1 every 16 bits).
  • Page 485: Writing Data To The Data Memory

    Writing data to the data memory SP.DEVST FX5S FX5UJ FX5U FX5UC This instruction writes the specified number of points of data to the device data storage file in data memory. Ladder diagram Structured text ENO:=SP_DEVST(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 486 Processing details • These instructions retrieves the specified number of points of data specified by (n) from the device specified by (s2) and write it to the write offset in the device specified by (s1) in the device data storage file in data memory. (s1) indicates the offset from the start of the device data storage file and can be specified by word offsets (incremented by 1 every 16 bits).
  • Page 487 Operation error Error code Description (SD0/SD8067) 2820H • The value specified by (s1), and (s1)+(n) are out of range of the device data storage file. • Any of the device area ranges specified in (s2) and (d) exceed the corresponding device range. 2822H Device that cannot be specified is specified.
  • Page 488: File Operation Instructions

    File Operation Instructions Reading data from the specified file SP.FREAD FX5S FX5UJ FX5U FX5UC This instruction reads device data from the specified file in an SD memory card. Ladder ENO:=SP_FREAD(EN,U,s1,s2,d1,d2,d3); (s1) (d1) (s2) (d2) (d3) FBD/LD Setting data Description, range, data type Operand Description Range...
  • Page 489 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 490 Operand: (d1) Device Item Description Setting range Set by Number of columns When "Reading binary data" is specified by (d1)+0, set 0. 0000H to FFFFH User When "Reading data after converted to CSV format" is specified by (d1)+0, set the (0 to 65535) number of read-target columns.
  • Page 491 Read data (d2) For the combination of processing units, refer to Page 490 Combination of processing units. Operand: (d2) Device Item Description Setting range Set by Number of data actually The number of data actually read is set.  System read The data unit is determined by (d1)+7 (Data type specification).
  • Page 492 Combination of processing units Specify data in (d1)+2, (d1)+4, (d1)+5, and (d2)+0 depending on the combination of (d1)+0 and (d1)+7. Execution/completion type Data type Processing unit and setting range (d1)+0 specification Number of read- File position Number of data (d1)+7 target data (d1)+4, (d1)+5 actually read...
  • Page 493 Execution/completion type Data type Processing unit and setting range (d1)+0 specification Number of read- File position Number of data (d1)+7 target data (d1)+4, (d1)+5 actually read (d1)+2 (d2)+0 Reading data after 0100H: Decimal (16- 0: Word Number of elements (1 to Number of lines Word converted to CSV...
  • Page 494: Timing Chart

    Timing chart Below is shown the timing chart (flag updating timing) from the execution of the SP.FREAD instruction to the completion. (1) No processing during scanning except Scan Scan Scan Scan when the instruction is turned OFF and ON processing processing processing processing...
  • Page 495 When reading data after converted to CSV format  • Elements in the CSV format file (cells in Excel ) are read by each row and stored in the device. • If the extension of the target file is omitted, the extension will be ".CSV". •...
  • Page 496 Execution/ Data type Data (one element) in the Value stored in the Remarks completion type specification CSV file device 0120H:  0H to FFFFH 0H to FFFFH  Hexadecimal (16-bit • Numeric values other than 0000H Filled with 0 since it cannot be converted. data) above •...
  • Page 497 D99: Number of data actually read [Loaded data] D100 to D103: String in the 1st column of SD memory card the 2nd line PARTS.CSV D104 to D107: String in the 2nd column of the 2nd line Name Value1 Value2 CR LF D108, D109: String in the 3rd column of AA_0001 Prts_A...
  • Page 498 When "Reading data after converted to CSV format" (Decimal (16-bit data)) is specified and the number of columns is set to 0 [Data created in Excel] [Data saved in CSV format] ABCD.CSV Main/sub item Measured value CR LF Length 3 CR LF Temperature , CR LF (1) Start device for storing the data that has been read...
  • Page 499 • When the number of columns differs in each row, the data are also read by ignoring the rows. When the number of columns differs in each row [Data saved in CSV format] ABCD.CSV Main/sub item Measured value Excess CR LF Length CR LF Temperature...
  • Page 500 • When the specified number of columns is set to a value other than 0, a CSV format file is read as the table with the specified number of columns. The elements outside the specified number of columns are ignored. When "Reading data after converted to CSV format"...
  • Page 501 • When the number of columns differs in each row, the elements outside the specified number of columns are ignored and 0 is added to the cells where no element exists. When the number of columns differs in each row (1) Columns out of the specified range are ignored.
  • Page 502 • When "Reading data after converted to CSV format" is specified, data can be divided and read. [Specify the row to start reading] • Execution/completion type: Reading data after converted to CSV format (Decimal (16-bit data)) • Number of read-target data: K6 •...
  • Page 503 [Continuing from the last read position] • Execution/completion type: Reading data after converted to CSV format (Decimal (16-bit data)) • Number of read-target data: K5 • File position: FFFFFFFFH (continuing from the position where the previous reading ends) • Number of columns specification: 4H •...
  • Page 504 When out-of-range value or string data is read [Data to be read into devices] (1): Start device for storing the data that has been read • D100: Number of data actually read SP.FREAD D0 "sample.csv" D100 M0 • D101 to D120: Read data (2): File name •...
  • Page 505 Program example An example of a program for reading binary data/CSV data from the SD memory card by using the SP.FREAD instruction is shown below. Reading binary data When X0 is turned ON, 100 data starting from the 16th word from the beginning of the "sample.bin" file stored in the SD memory card are stored in D101 to D200.
  • Page 506 [Ladder program] Creation of control data for file read instruction SM402 After RUN, Start device where the ON for one control data is stored (Execution/ scan only completion type) Completion status K100 Number of read-target data DMOV File position Data type specification Execution of file read instruction SM753...
  • Page 507 [ST program] //(1) Creation of control data for file read instruction IF SM402 THEN D0 := H0; //Execution/completion type (Control data start device) D1 := H0; //Completion status D2 := 100; //Number of read-target data D4:UD := H10; //File position D7 := 2;...
  • Page 508 [Execution result] When the target binary data is read by using the program example, the results are as shown below. (1) 100 words from 03E9 to 044C are described. In the [Read target (sample.bin)] program example, the data is read starting from the sample.bin 16th word, and so 03E9 (boxed) is stored in D101.
  • Page 509 Reading data after converted to CSV format When X0 is turned ON, 20 words of data in the five columns in the second to fifth rows in the "sample.csv" file stored in the SD memory card are stored in D101 to D120. [Program operation] Control data is created during RUN.
  • Page 510 [Ladder program] Creation of control data for file read instruction SM402 H100 After RUN, Start device where the ON for one control data is stored (Execution/completion type) scan only Completion status Number of read-target data DMOV File position Number of columns Data type specification...
  • Page 511 [ST program] //(1) Creation of control data for file read instruction IF SM402 THEN D0 := H100; //Execution/completion type (Control data start device) D1 := H0; //Completion status D2 := 20; //Number of read-target data D4:UD := 2; //File position D6 := 5;...
  • Page 512 [[Execution result] When the target CSV data is read by using the program example, the results are as shown below. (1) In the program example, five columns in each row from [Read target (sample.bin)] the second row are read, and so 1 (boxed) is stored in D101.
  • Page 513 Operation error Error code Description (SD0/SD8067) 2820H The storage device of the control data (d1) exceeds the end of the device range. The bit label digits specified in (s2) and (d2) are unacceptable settings (the number of digits is not K4). The size of the read data exceeds the read device size.
  • Page 514: Writing Data To The Specified File

    Writing data to the specified file SP.FWRITE FX5S FX5UJ FX5U FX5UC This instruction writes device data to the specified file in an SD memory card. Ladder ENO:=SP_FWRITE(EN,U,s1,s2,s3,d1,d2); (s1) (d1) (s2) (s3) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 515: Applicable Devices

    Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 516 Operand: (d1) Device Item Description Setting range Set by Data type specification • 0: Word 0, 1, 2, 3 User • 1: Even number of bytes • 2: Unit of the data type specified by (d1)+0 *2*3 • 3: Odd number of bytes "0: Word", "1: Even number of bytes", and "3: Odd number of bytes"...
  • Page 517 Write data (s3) Operand: (s3) Device Item Description Setting range Set by Number of request Specify the number of data to be requested to write. 1 to 65535, 0 User write data The processing unit and setting range vary depending on Execution/completion type set in (d1)+0 and data type specification in (d1)+7.
  • Page 518: Processing Details

    Processing details • This instruction writes the specified number of data to the specified file. Set the execution/completion type in the control data to specify the file write-target format. • The write target is the SD memory card only. • The processing completion bit device (d2) automatically turns on at the execution of the END instruction in the scan in which the completion of processing of the SP.FWRITE instruction is detected.
  • Page 519 Execution/completion type Data type Processing unit and setting range (d1)+0 specification Number of request File position Number of data (d1)+7 write data (d1)+4, (d1)+5 actually written (s3)+0 (d1)+2 Writing 0100H: Decimal (signed 16- 0: Word Word (0 , 1 to 65535) Head/end Word data after...
  • Page 520: Timing Chart

    Timing chart Below is shown the timing chart (flag updating timing) from the execution of the SP.FWRITE instruction to the completion. (1) No processing during scanning except Scan Scan Scan Scan when the instruction is turned OFF and ON processing processing processing processing...
  • Page 521 Writing binary data • If the extension of the target file is omitted, the extension will be ".BIN". • If a file that does not exist is specified, it will be created and data will be saved to the beginning of the file. The newly created file has the archive attribute.
  • Page 522 Converting and writing data in CSV format • If the extension is omitted, the extension will be ".CSV". • When an existing file is specified, the following occurs. - When a value specified by (d1)+4 and (d1)+5 is other than FFFFFFFFH, data is saved to the file after deleting all the existing data in the file. - When a value specified by (d1)+4 and (d1)+5 is FFFFFFFFH, data is added and saved to the end of the file.
  • Page 523 • When the specified number of columns is set to a value other than 0, a CSV format file is stored as the table with the specified number of columns. The number of columns is set to a value other than 0 when writing data after conversion to the CSV format. "ABCDE"...
  • Page 524 • The following figure shows how data is added. [Specify the file to which data will be written.] (Even if the file exists, it is deleted and re-created.) • Execution/completion type: Writing data after converted to CSV format (Decimal (signed 16-bit data)) •...
  • Page 525 [Added to the end of the file] • Execution/completion type: Writing data after converted to CSV format (Decimal (signed 16-bit data)) • Number of request write data: 8H • File position: FFFFFFFFH (added to the end of the file) • Number of columns specification: 3H •...
  • Page 526 • The following figures show an example of specifying "String (ASCII data)" for the execution/completion type. Writing data after converted to CSV format (string (ASCII data)) [Data to be written to a file] (1) Data to be written (2) File name SP.FWRITE "ABCD"...
  • Page 527 • The following table lists values to set in (s3)+1 and later and data to be written in a CSV file when "0140H: Floating point real number (single-precision real number)" is set to (d1)+0. Execution/completion type Value to set in the write data Data to be written in a CSV file ((d1)+0) ((s3)+1 and later)
  • Page 528: Program Example

    Program example An example of a program for writing binary data/CSV data to the SD memory card by using the SP.FWRITE instruction is shown below. Writing binary data When X0 is turned ON, the data in D101 to D200 are written starting from the 16th word from the beginning of the "sample.bin"...
  • Page 529 [Ladder program] Creation of control data for file write instruction SM402 After RUN, Start device where the control data is stored ON for one (Execution/completion scan only type) Completion status Number of data actually written DMOV File position Data type specification Creation of data to be written (Store the data to be written in D101 and following devices as needed.) SM402...
  • Page 530 [ST program] //(1) Creation of control data for file write instruction IF SM402 THEN D0 := H0; //Execution/completion type (Control data start device) D1 := H0; //Completion status D2 := 0; //Number of data actually written D4:UD := H10; //File position D7 := 2;...
  • Page 531 [Execution result] When the target device data is written by using the program example, the results are as shown below. (1) In the program example, 100 words of data are written. [Write target] Accordingly, the number of request write data is stored Device Name Current Value String...
  • Page 532 Converting and writing data in CSV format When X0 is turned on, the data in D101 to D115 are written to the end of the "sample.csv" file stored in the SD memory card. [Program operation] Control data is created during RUN. Set the number of request write data.*1 The drive contact of X0 is held in M0.
  • Page 533 [Ladder program] Creation of control data for file write instruction SM402 H100 After RUN, ON Start device where the for one scan control data is stored (Execution/completion type) only Completion status Number of data actually written Application setting area DMOV HFFFFFFFF File position Number of columns...
  • Page 534 [ST program] //(1) Creation of control data for file write instruction IF SM402 THEN D0 := H100; //Execution/completion type (Control data start device) D1 := H0; //Completion status D2 := 0; //Number of data actually written D3 := H0; //Application setting area D4:UD := HFFFFFFFF;...
  • Page 535 [Execution result] When the target device data is written by using the program example, the results are as shown below. (1) In the program example, 15 words of data are written. [Write target] Accordingly, the number of request write data is stored Device Name F F E D C F B A 9 8 F 7 6 5 4 F 3 2 1 0 Current Value...
  • Page 536: Operation Error

    Operation error Error code Description (SD0/SD8067) 2820H The bit label digits specified in (s2) and (s3) are unacceptable settings (the number of digits is not K4). The storage device of the control data (d1) exceeds the end of the device range. The value in the device specified by (s3)+0 is out of the range (1 to 65535), or exceeds the setting area specified by (s3)+1 and later in the device/label memory.
  • Page 537: Deleting The Specified File

    Deleting the specified file SP.FDELETE FX5S FX5UJ FX5U FX5UC This instruction deletes the specified file or folder in an SD memory card. Ladder ENO:=SP_FDELETE(EN,U,s1,s2,d1,d2); (s1) (d1) (s2) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) FX5S CPU module Dummy...
  • Page 538 Control data (d1) Operand: (d1) Device Item Description Setting range Set by Application setting area Refer to the User … b1 b0 "Description" 1/0 1/0 column. b0: Target type setting Specify the type of data (file or folder) to delete. •...
  • Page 539 Operand: (s2) Device Item Description Setting range Set by +0 to + Folder name character When specifying a folder, specify the folder path of the folder to be deleted. Unicode string User string • The folder path must be within 244 characters. (Delimiters at the end of the folder path are not included.) •...
  • Page 540: Processing Details

    Processing details • This instruction deletes the file or folder specified by (s2) in the drive specified by (s1). • SM753 (File being accessed) turns on while the SP.FDELETE instruction is being executed. While SM753 is on, the SP.FDELETE instruction cannot be executed. (If the instruction is executed, no processing is performed.) •...
  • Page 541 Program example When X0 is turned ON, the "\sample\sample.csv" file stored in the SD memory card is deleted. [Program operation] Control data is created during RUN. The drive contact of X0 is held in M0. When the drive contact is turned ON, the instruction execution complete flag and instruction error completion flag are initialized.
  • Page 542 [Ladder program] Creation of file operation instruction control data SM402 After RUN, ON Start device where for one scan the control data is only stored Completion status Execution of file delete instruction SM753 Trigger of drive File being SP.FDELETE SP.FDELETE accessed instruction execution instruction...
  • Page 543 [ST program] //(1) Creation of file delete instruction control data IF SM402 THEN D0:=H0; //Application setting area (File) D1:=H0; //Completion status END_IF; //(2) Processing to start up the drive contact (X0) IF LDP(TRUE,X0) THEN; //Checking that the file being accessed flag is OFF IF (SM753 <>...
  • Page 544 Precautions • The SP.FDELETE instruction cannot be performed in user interrupt programs. An error (3582H) will occur. • The SP.FDELETE instruction cannot be executed while SM606 (Memory card disable request) is ON. If SM606 is turned ON after the instruction is executed, the program will terminate abnormally. (The data deleted before SM606 is turned ON will not be restored.) •...
  • Page 545: Copying The Specified File

    Copying the specified file SP.FCOPY FX5S FX5UJ FX5U FX5UC This instruction copies the specified file or folder in an SD memory card. When a folder is specified, the specified folder is copied in its entirety, or all the files and subfolders in the specified folder are copied. Ladder ENO:=SP_FCOPY(EN,U,s1,s2,s3,s4,d1,d2);...
  • Page 546: Specification

    Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 547 Operand: (d1) Device Item Description Setting Set by range Application [Operation when b2 is set to 1 (Copy all the files and subfolders in the folder), and the Refer to the User setting area specified folder includes files and a subfolder] "Description"...
  • Page 548 Copy source file name/folder name (s2) Operand: (s2) Device Item Description Setting range Set by +0 to + File name character When specifying a file, specify the folder path where the copy source file is stored Unicode string User string and the file name.
  • Page 549 Copy destination folder path (s4) Operand: (s4) Device Item Description Setting range Set by +0 to + Folder path Specify the copy destination folder path. Unicode string User • The folder path must be within 244 characters. (Delimiters at the end of the folder path are not included.) •...
  • Page 550 [In SD memory card] When application setting area is 0H (File) Before execution of instruction After execution of instruction $MELPRJ$ $MELPRJ$ folder1 user1.csv folder1 user1.csv folder2 folder2 user1.csv The folder1/user1.csv file is copied into folder2. When application setting area is 1H ("Folder", "Copy the folder in its entirety.") Before execution of instruction After execution of instruction $MELPRJ$...
  • Page 551 When application setting area is 7H ("Folder", "Copy all the files and subfolders in the folder.", "Overwrite the file or folder.") Before execution of instruction After execution of instruction $MELPRJ$ $MELPRJ$ folder1 user1.csv folder1 user1.csv folder2 user1.csv folder2 user1.csv folder2/user1.csv is copied overwriting the folder1/user1.csv file. *1 Root folder *2 File name of the copy source *3 Copy destination folder...
  • Page 552 Program example When X0 is turned ON, the "sample.bin" file stored in the SD memory card is copied into the "sample1" folder. [Program operation] Control data is created during RUN. The drive contact of X0 is held in M0. When the drive contact is turned ON, the instruction execution complete flag and instruction error completion flag are initialized.
  • Page 553 Execution of file copy instruction SM753 Trigger of drive File being SP.FCOPY instruction SP.FCOPY accessed execution latched device instruction M100 SP.FCOPY instruction execution complete flag M101 SP.FCOPY instruction execution error completion flag SM606 "sample.bin" "sample1" SP.FCOPY M100 SP.FCOPY Memory card Start device where SP.FCOPY instruction instruction...
  • Page 554 Precautions • Do not execute the SP.FCOPY instruction in an interrupt program. Doing so may cause malfunction of the module. • The SP.FCOPY instruction cannot be executed while SM606 (Memory card disable request) is ON. If SM606 is turned ON after the completion of the initial END processing during execution of the instruction, the program will terminate abnormally upon detection of turning ON.
  • Page 555: Moving The Specified File

    Moving the specified file SP.FMOVE FX5S FX5UJ FX5U FX5UC This instruction moves the specified file or folder in an SD memory card. When a folder is specified, the specified folder is moved in its entirety, or all the files and subfolders in the specified folder are moved. Ladder ENO:=SP_FMOVE(EN,U,s1,s2,s3,s4,d1,d2);...
  • Page 556 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 557 Operand: (d1) Device Item Description Setting Set by range Application [Operation when b2 is set to 1 (Move all the files and subfolders in the folder), and the Refer to the User setting area specified folder includes files and a subfolder] "Description"...
  • Page 558 File name/folder name (s2) Operand: (s2) Device Item Description Setting range Set by +0 to + File name character When specifying a file, specify the folder path where the file to move is stored and the Unicode string User string file name.
  • Page 559 Destination folder path (s4) Operand: (s4) Device Item Description Setting range Set by +0 to + Folder path Specify the destination folder path. Unicode string User • The folder path must be within 244 characters. (Delimiters at the end of the folder path are not included.) •...
  • Page 560 Timing chart The operation specifications of the file move function are shown below. Command input SP.FMOVE (d1) (s1) (s2) (s3) (s4) (d2) Application setting area (d1)+0 File name/folder name (s2) Destination folder path (s4) 0H, 1H, 5H, 7H [When a file is specified] folder2 user1.csv [When a folder is specified]...
  • Page 561 When application setting area is 5H ("Folder", "Move all the files and subfolders in the folder.", "Do not overwrite the file or folder.") Before execution of instruction After execution of instruction $MELPRJ$ $MELPRJ$ folder1 user1.csv folder1 user1.csv folder2 user1.csv folder2 user1.csv The file is not moved because a file with the same name exists in the destination.
  • Page 562 Program example When X0 is turned ON, the "sample" folder stored in the SD memory card is moved to the "sample1" folder. [Program operation] Control data is created during RUN. The drive contact of X0 is held in M0. When the drive contact is turned ON, the instruction execution complete flag and instruction error completion flag are initialized.
  • Page 563 Execution of file move instruction SM753 Trigger of drive File being SP.FMOVE SP.FMOVE accessed instruction execution instruction latched device M100 SP.FMOVE instruction execution complete flag M101 SP.FMOVE instruction execution error completion flag SM606 "sample" "sample1" SP.FMOVE M100 SP.FMOVE Memory card Start device where SP.FMOVE instruction...
  • Page 564 Precautions • Do not execute the SP.FMOVE instruction in an interrupt program. Doing so may cause malfunction of the module. • The SP.FMOVE instruction cannot be executed while SM606 (Memory card disable request) is ON. If SM606 is turned ON after the completion of the initial END processing during execution of the instruction, the program will terminate abnormally upon detection of turning ON.
  • Page 565: Renaming The Specified File

    Renaming the specified file SP.FRENAME FX5S FX5UJ FX5U FX5UC This instruction renames the specified file or folder in an SD memory card. Ladder ENO:=SP_FRENAME(EN,U,s1,s2,s3,d1,d2); (s1) (d1) (s2) (s3) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) FX5S CPU module...
  • Page 566 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 567 File name/folder name to be changed (s2) Operand: (s2) Device Item Description Setting range Set by +0 to + File name character When specifying a file, specify the folder path where the file to be renamed is stored Unicode string User string and the file name.
  • Page 568 File name/folder name after the change (s3) Operand: (s3) Device Item Description Setting range Set by +0 to + File name/folder name Specify the string of the file name/folder name after the change. Unicode string User • When the file name has an extension, specify the name without omitting the extension.
  • Page 569 Timing chart The operation specifications of the file rename function are shown below. Command input SP.FRENAME (s1) (d1) (s2) (s3) (d2) Application setting area (d1)+0 File name to be changed (s2) File name after the change (s3) sample/sample.bin sample_change.bin [In SD memory card] Before execution of instruction After execution of instruction sample.bin...
  • Page 570 Program example When X0 is turned ON, the file name of "sample.bin" stored in the SD memory card is changed to "sample_change.bin". [Program operation] Control data is created during RUN. The drive contact of X0 is held in M0. When the drive contact is turned ON, the instruction execution complete flag and instruction error completion flag are initialized.
  • Page 571 SM606 "sample.bin" "sample_change.bin" SP.FRENAME M100 SP.FRENAME Memory card Start device SP.FRENAME instruction disable where the instruction execution execution latched request control data is complete flag device (Drive 2) M101 stored M100 M150 SP.FRENAME SP.FRENAME Normal open instruction execution instruction indication error completion flag execution device...
  • Page 572 Precautions • Do not execute the SP.FRENAME instruction in an interrupt program. Doing so may cause malfunction of the module. • The SP.FRENAME instruction cannot be executed while SM606 (Memory card disable request) is ON. When SM606 is turned ON during execution of the instruction, the program will terminate abnormally. (If the fine renaming has been completed before SM606 is turned ON, the file name will be changed.) •...
  • Page 573: Acquiring The Status Of The Specified File

    Acquiring the status of the specified file SP.FSTATUS FX5S FX5UJ FX5U FX5UC This instruction acquires the status of the specified file or folder in an SD memory card. Ladder ENO:=SP_FSTATUS(EN,U,s1,s2,d1,d2,d3); (s1) (d1) (s2) (d2) (d3) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 574 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 575 File name/folder name (s2) Operand: (s2) Device Item Description Setting range Set by +0 to + File name character When specifying a file, specify the folder path where the file whose status is to be Unicode string User string acquired is stored and the file name. •...
  • Page 576 File status (d2) Operand: (d2) Device Item Range Set by File attribute Refer to the "Item" column. System bit0: Turns on for a read-only file. bit1: Turns on for a hidden file. bit2: Turns on for a system file. bit3: Reserved (fixed to 0) bit4: Turns on for a directory.
  • Page 577 Timing chart The operation specifications of the file status acquisition function are shown below. Command input SP.FSTATUS (s1) (d1) (s2) (d2) (d3) Application setting area (d1)+0 File name (s2) File status (d2) sample.bin D100 to D109 [In SD memory card] [In CPU built-in memory] sample.bin Read result...
  • Page 578 Program example When X0 is turned ON, the status of the "sample.bin" file stored in the SD memory card is read to D100 to D109. [Program operation] Control data is created during RUN. The drive contact of X0 is held in M0. When the drive contact is turned ON, the instruction execution complete flag and instruction error completion flag are initialized.
  • Page 579 Execution of file status acquisition instruction SM753 Trigger of File being SP.FSTATUS instruction execution drive accessed SP.FSTATUS latched device instruction M100 SP.FSTATUS instruction execution complete flag M101 SP.FSTATUS instruction execution error completion flag SM606 "sample.bin" SP.FSTATUS D100 M100 SP.FSTATUS Memory card Start device where Start device SP.FSTATUS...
  • Page 580 Precautions • Do not execute the SP.FSTATUS instruction in an interrupt program. Doing so may cause malfunction of the module. • The SP.FSTATUS instruction cannot be executed while SM606 (Memory card disable request) is ON. When SM606 is turned ON during execution of the instruction, the program will terminate abnormally. •...
  • Page 581: Error Codes Generated For File Operation Instructions

    Error codes generated for file operation instructions The following table lists the error codes that could be stored in the completion status of file operation instructions. Error code Description Action 8000H SM606 (SD memory card forced disable instruction) is on. Turn off SM606 to cancel the SD memory card forced disable status.
  • Page 582: Extended File Register Operation Instruction

    Extended File Register Operation Instruction Reading extended file register ERREAD FX5S FX5UJ FX5U FX5UC Reads the current value of the extended file register (ER) to the file register (R) in the CPU built-in memory. Ladder diagram Structured text ENO:=ERREAD(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 583 Processing details The current value of the extended file register (ER) stored into the SD memory card is read for (n) points to the file register (R) in the CPU built-in memory specified with (s). The normal or abnormal completion of the ERREAD instruction can be confirmed with the instruction completion device (d) specified with the setting data.
  • Page 584: Related Devices

    Related devices Device Name Description SM8029 Instruction execution Turns on when an instruction is finished normally. complete SM8329 Instruction execution Turns on when an instruction is finished abnormally. abnormal end SM9366 Extended file register Turns on during access to extended file register (ER). (ER) access flag SM8029 and SM8329 are the flags shared by multiple instructions.
  • Page 585: Writing Extended File Register

    Writing extended file register ERWRITE FX5S FX5UJ FX5U FX5UC Writes the current value of the file register (R) in the CPU built-in memory to the extended file register (ER). Ladder diagram Structured text ENO:=ERWRITE(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 586 Processing details The current value of the file register (R) in the CPU built-in memory is written (transferred) for (n) points to the extended file register (ER) in the SD memory card specified with (s). The normal or abnormal completion of the ERWRITE instruction can be confirmed with the instruction completion device (d) specified with the setting data.
  • Page 587 Related devices Device Name Description SM8029 Instruction execution Turns on when an instruction is finished normally. complete SM8329 Instruction execution Turns on when an instruction is finished abnormally. abnormal end SM9366 Extended file register Turns on during access to extended file register (ER). (ER) access flag SM8029 and SM8329 are the flags shared by multiple instructions.
  • Page 588: Batch Initialization Function Of Extended File Register

    Batch initialization function of extended file register ERINIT FX5S FX5UJ FX5U FX5UC Initialize all the points of the extended file register (ER) in a batch. Ladder diagram Structured text ENO:=ERINIT(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 589 Processing details Initializes all the points of the extended file register (ER) in the SD memory card in a batch. The normal or abnormal completion of the ERINIT instruction can be confirmed with the instruction completion device (d) specified with the setting data. •...
  • Page 590: Error Code

    Precautions • If the ERINIT instruction is executed, an access to the SD memory card occurs and the scan time is extended. • This instruction cannot be executed with the extended file register operation instruction simultaneously. • When executing the following extended file register operation instruction, detect the extended file register (ER) access flag: SM9366 switching from ON to OFF, and turn on the drive contact of the extended file register operation instruction.
  • Page 591: Character String Operation Instruction

    Character String Operation Instruction Comparing character strings LD$, AND$, OR$ FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the character string data in the device specified by (s1) and later and the character string data in the device specified by (s2) and later. (Devices are used as a normally open contact.) Ladder diagram Structured text ENO:=LDSTRING_(EN,s1,s2);...
  • Page 592 Processing details • These instructions perform a comparison operation between the character string data specified by (s1) and the character string data specified by (s2). (Devices are used as a normally open contact.) • In the comparison operation, the ASCII codes of the character strings are compared one by one from the start of the strings.
  • Page 593 • When the length of the character string data differs for (s1) and (s2), the relative sizes of the character strings are determined based on the size of the first different character code. (s1) 32H (2) 31H (1) (s2) 32H (2) 31H (1) (s1)+1 33H (3)
  • Page 594: Concatenating Character Strings

    Concatenating character strings $+(P) [For 2 operands] FX5S FX5UJ FX5U FX5UC These instructions concatenate the character string data stored in the device specified by (s) and later to the end of the character string data stored in the device specified by (d) and later, and store the concatenated string in the device specified by (d) and later.
  • Page 595 Operation error Error code Description (SD0/SD8067) 2820H In the corresponding device range after the device specified by (s), "00H" does not exist. In the corresponding device range after the device specified by (d), "00H" does not exist. 3406H The whole concatenated character string cannot be stored in the devices from the device specified by (d) to the last device in the corresponding device range.
  • Page 596 $+(P) [For 3 operands] FX5S FX5UJ FX5U FX5UC These instructions concatenate the character string data stored in the device specified by (s2) and later to the end of the character string data stored in the device specified by (s1) and later, and store the concatenated string in the device specified by (d) and later.
  • Page 597 Processing details • These instructions concatenate the character string data stored in the device specified by (s2) and later to the end of the character string data stored in the device specified by (s1) and later, and store the concatenated string in the device specified by (d) and later.
  • Page 598: Transferring Character Strings

    Transferring character strings $MOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer the character string data specified by (s) to the device specified by (d) and later. Ladder diagram Structured text ENO:=STRINGMOV(EN,s,d); ENO:=STRINGMOVP(EN,s,d); FBD/LD ("STRINGMOV", "STRINGMOVP" enters .) *1 Supported by engineering tool version "1.035M" and later. Setting data Descriptions, ranges, and data types Operand...
  • Page 599: Program Example

    • Even though the device range of the data to be transferred (s) to (s)+n and the device range for storing the transferred data (d) to (d)+n overlap, the processing is performed normally. For example, when a character string stored in D10 to D13 is transferred to D11 to D14, the transfer is executed as shown below: 32H (2) 31H (1)
  • Page 600: Transferring Unicode String Data

    Transferring Unicode string data $MOV(P)_WS FX5S FX5UJ FX5U FX5UC These instructions transfer Unicode string data to the specified device number and later. Ladder ENO:=STRINGMOV_WS(EN,s,d); ENO:=STRINGMOVP_WS(EN,s,d); FBD/LD ( is replaced by STRINGMOV_WS or STRINGMOVP_WS.) Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 601 Processing details • These instructions transfer the Unicode character string data in the device specified by (s) to the device number specified by (d) and later. The Unicode character strings specified by (s) or the Unicode character strings from the device number specified by (s) to the device number containing 0000H are transferred all at once.
  • Page 602: Converting 16-Bit Binary Data To Decimal Ascii

    Converting 16-bit binary data to decimal ASCII BINDA(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert 16-bit binary data specified by (s) into decimal ASCII codes, and store the converted data in the device specified by (d) and later. Ladder diagram Structured text ENO:=BINDA(EN,s,d);...
  • Page 603: Operation Overview

    Processing details • These instructions convert 16-bit binary data specified by (s) into decimal ASCII codes, and store the converted data in the device specified by (d) and later. • The format of the decimal ASCII data to be stored in (d) depends on the status of SM705 (Number of conversion digits selection).
  • Page 604 Operation of when SM705 (Number of conversion digits selection) is off Decimal ASCII data is stored in a fixed number of digits in (d) to (d)+2. ASCII code for ten-thousands place ASCII code for sign (d)+1 ASCII code for hundreds place ASCII code for thousands place (d)+2 ASCII code for ones place...
  • Page 605 Precautions • The number of occupied points of (d) is 3 when SM701 is on, and 4 when SM701 is off. • When SM705 (Number of conversion digits selection) is on, the operation result is stored in (d) for the effective number of digits.
  • Page 606 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (d) exceeds the corresponding device range. 8 APPLICATION INSTRUCTION 8.9 Character String Operation Instruction...
  • Page 607: Converting 32-Bit Binary Data To Decimal Ascii

    Converting 32-bit binary data to decimal ASCII DBINDA(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions convert 32-bit binary data specified by (s) into decimal ASCII codes, and store the converted data in the device specified by (d) and later. Ladder diagram Structured text ENO:=DBINDA(EN,s,d);...
  • Page 608 Processing details • These instructions convert 32-bit binary data specified by (s) into decimal ASCII codes, and store the converted data in the device specified by (d) and later. • The format of the decimal ASCII data to be stored in (d) depends on the status of SM705 (Number of conversion digits selection).
  • Page 609 Operation of when SM705 (Number of conversion digits selection) is off Decimal ASCII data is stored in a fixed number of digits in (d) to (d)+5. ASCII code for billions place ASCII code for sign (d)+1 ASCII code for ten-millions place ASCII code for hundred-millions place (s)+1 (d)+2...
  • Page 610 Operation of when SM705 (Number of conversion digits selection) is on Decimal ASCII data is stored right-justified in (d). The following figures show an example of a value of (s) and a value stored in (d). Value of (s) Data of (d) to (d)+5 Value of (s) Data of (d) to (d)+5 •...
  • Page 611 Precautions • (d) occupies six points. • When SM705 (Number of conversion digits selection) is on, the operation result is stored in (d) for the effective number of digits. Therefore, when the DBINDA(P)(_U) instruction is executed successively and the operation result for each execution is stored in the same device, a part of the previous operation result may not be overwritten by the succeeding result and can remain in (d).
  • Page 612 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (d) exceeds the corresponding device range. 8 APPLICATION INSTRUCTION 8.9 Character String Operation Instruction...
  • Page 613: Converting Hex Code Data To Ascii

    Converting HEX code data to ASCII ASCI(P) FX5S FX5UJ FX5U FX5UC These instructions convert the (n) characters (digits) within the hexadecimal code data specified by (s) to ASCII, and store the converted data in the device specified by (d) and later. Ladder diagram Structured text ENO:=ASCI(EN,s,n,d);...
  • Page 614 Processing details • These instructions convert the (n) characters (digits) within the hexadecimal code data specified by (s) to ASCII, and store the converted data in the device specified by (d) and later. • The 16-bit mode and 8-bit mode options are available for the ASCI(P) instructions. For the operation in each mode, refer to the proceeding pages.
  • Page 615 • 8-bit conversion mode (while SM8161 is ON) Each digit of hexadecimal data stored in the device specified by (s) and later is converted into ASCII code, and transferred to the lower 8 bits of each device specified by (d) and later. SM8161 must always be on in the 8-bit conversion mode. In the following program, conversion is executed as follows: SM400 Devices specified by (s) and later...
  • Page 616 Precautions • When outputting data in the BCD format for a printer, for example, it is necessary to convert binary data into BCD data before executing the ASCI(P) instructions. • Whether NULL (00H) is stored after the last character or not depends on the ON/OFF status of the output character number selector signal SM701.
  • Page 617: Converting 16-Bit Binary Data To Character String

    Converting 16-bit binary data to character string STR(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add a decimal point to the 16-bit binary data in the device specified by (s2) at the location specified by (s1), convert the data to character string data, and store the converted data in the device areas specified by (d) and later. Ladder diagram Structured text ENO:=STR(EN,s1,s2,d);...
  • Page 618 Processing details • These instructions add a decimal point to the 16-bit binary data in the device specified by (s2) at the location specified by (s1), convert the data to character string data, and store the converted data in the device areas specified by (d) and later. (s1) b8 b7 (s1)+1...
  • Page 619 Program example In the program below, the 16-bit binary data stored in D10 is converted into a character string in accordance with the digit specification by D0 and D1 when X0 is set to ON, and then stored in D20 to D23. MOVP K12672 Data to be converted is set.
  • Page 620: Converting 32-Bit Binary Data To Character String

    Converting 32-bit binary data to character string DSTR(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add a decimal point to the 32-bit binary data in the device specified by (s2) at the location specified by (s1), convert the data to character string data, and store the converted data in the device areas specified by (d) and later. Ladder diagram Structured text ENO:=DSTR(EN,s1,s2,d);...
  • Page 621 Processing details • These instructions add a decimal point to the 32-bit binary data in the device specified by (s2) at the location specified by (s1), convert the data to character string data, and store the converted data in the device areas specified by (d) and later. (s1) b8 b7 (s1)+1...
  • Page 622: Error Code

    • If the total number of digits excluding the sign and the decimal point is greater than the number of digits of the 32-bit binary data, "20H" (space) is stored between the sign and the numeric value. If the number of digits of the 32-bit binary data is greater, an error occurs. (s1) (s1)+1 4 3 2 .
  • Page 623: Converting Single-Precision Real Number To Character String

    Converting single-precision real number to character string ESTR(P)/DESTR(P) FX5S FX5UJ FX5U FX5UC These instructions convert the single-precision real number data stored in the device specified by (s1) into a character string according to the display specification stored in the device specified by (s2) and later, and store the string in the device specified by (d) and later.
  • Page 624 Processing details • These instructions convert the single-precision real number data stored in the device specified by (s1) into a character string according to the display specification stored in the device specified by (s2) and later, and store the string in the device specified by (d) and later.
  • Page 625 • When the number of decimal part digits is 0, the number of digits that can be specified by (s2)+1 is "the number of digits (24 at a maximum)  2". For other than 0, the number of digits that can be specified by (s2)+1 is "the number of digits (24 at a maximum) ...
  • Page 626 Exponent format • When 1 is specified in (s2), the exponent format is applied. b8 b7 (s2) ASCII code in "(Value specifying number (s2)+1 ASCII code for sign (integral part) of all digits - 1)"th digit (s2)+2 ASCII code in "(Value specifying number ASCII code (2EH) for decimal point (.) (d)+1 of all digits - 2)"th digit...
  • Page 627 • The converted character string data are stored in the device areas specified by (d) and later as shown below. • As sign data of the integral part, "20H" (space) is stored if the single-precision real number is positive, and "2DH" (-) is stored if the data is negative. •...
  • Page 628 Program example In the program example shown below, the contents (single-precision real number data) of R0 and R1 are converted according to the contents specified by R10 to R12, and then stored to D0 and later when X0 turns ON. DESTRP Conversion …...
  • Page 629 Operation error Error code Description (SD0/SD8067) 2820H The device specified by (s2) exceeds the corresponding device range. 3401H The number of total digits specified by (s1)+1 exceeds 24. The format specified by (s2) is any value other than "0" or "1". The total number of digits specified by (s2)+1 is not within the following range in the decimal point format.
  • Page 630: Converting Unicode Character String To Shift Jis Character String

    Converting Unicode character string to Shift JIS character string WS2SJIS(P) FX5S FX5UJ FX5U FX5UC These instructions convert a Unicode character string to a Shift JIS character string. Ladder ENO:=WS2SJIS(EN,s,d); ENO:=WS2SJISP(EN,s,d); FBD/LD Setting data Description, range, data type Operand Description Range Data type Data type (label) ...
  • Page 631 • The shift JIS string in (d) is stored in big endian. A shift JIS string "95B6H" is specified with "B695H". 95 B6 ∙∙∙ ∙∙∙ • When a byte order mark is not used, conversion from Unicode to shift JIS occurs as follows. ∙∙∙...
  • Page 632 Precautions • If the Unicode string specified in (s) contains a character code that cannot be converted, the string to the character causing the error is written to the device No. specified in (d). • 32-bit Unicode strings cannot be converted to shift JIS. •...
  • Page 633: Converting Shift Jis Character String To Unicode Character String (Without Byte Order Mark)

    Converting shift JIS character string to Unicode character string (without byte order mark) SJIS2WS(P) FX5S FX5UJ FX5U FX5UC These instructions convert a Shift JIS character string to a Unicode character string. Ladder ENO:=SJIS2WS(EN,s,d); ENO:=SJIS2WSP(EN,s,d); FBD/LD Setting data Description, range, data type Operand Description Range...
  • Page 634 • The Unicode string in (d) is stored in little endian. A Unicode string "6587H" is specified. 65 87 ∙∙∙ ∙∙∙ • The SJIS2WS(P) instruction does not add a byte order mark to the beginning of the data in the device specified by (d). To add a byte order mark, use the SJIS2WSB(P) instruction.
  • Page 635 Operation error Error code Description (SD0/SD8067) 2820H 0000H does not exist between setting areas in the device/label memory after the device No. specified in (s). 2821H The ranges of data in the devices specified by (s) and (d) are overlapping. 3401H The range of data in the device specified by (s) includes a character code that cannot be converted.
  • Page 636: Converting Shift Jis Character String To Unicode (With Byte Order Mark)

    Converting shift JIS character string to Unicode (with byte order mark) SJIS2WSB(P) FX5S FX5UJ FX5U FX5UC These instructions convert a shift JIS character string to a Unicode character string, and adds a byte order mark to the start of the converted data. Ladder ENO:=SJIS2WSB(EN,s,d);...
  • Page 637 • The Unicode string in (d) is stored in little endian. A Unicode string "6587H" is specified. 65 87 ∙∙∙ ∙∙∙ • The following figure shows the operation for converting shift JIS to Unicode. SM402 ∙∙∙ b8 b7 ∙∙∙ ∙∙∙ Byte order $MOVP "123"...
  • Page 638: Error Code

    Operation error Error code Description (SD0/SD8067) 2820H 0000H does not exist between setting areas in the device/label memory after the device No. specified in (s). 2821H The ranges of data in the devices specified by (s) and (d) are overlapping. 3401H The range of data in the device specified by (s) includes a character code that cannot be converted.
  • Page 639: Detecting A Character String Length

    Detecting a character string length LEN(P) FX5S FX5UJ FX5U FX5UC These instructions detect the length of the character string specified by (s), and store the length in the device specified by (d) and later. These instructions handle data stored in the device specified by (s) to the device storing 00H as a character string. Ladder diagram Structured text ENO:=LENP(EN,s,d);...
  • Page 640 Processing details • These instructions detect the length of the character string specified by (s), and store the length in the device specified by (d) and later. • These instructions handle data stored in the device specified by (s) to the device storing 00H as a character string. 2nd character 1st character (s)+1...
  • Page 641: Extracting Character String Data From The Right

    Extracting character string data from the right RIGHT(P) FX5S FX5UJ FX5U FX5UC These instructions extract "n" characters of the character string data stored in the device specified by (s) and later from the right end (from the end), and store the extracted characters in the device specified by (d) and later. Ladder diagram Structured text ENO:=RIGHTP(EN,s,n,d);...
  • Page 642 Processing details • These instructions extract "n" characters of the character string data stored in the device specified by (s) and later from the right end (from the end), and store the extracted characters in the device specified by (d) and later. ASCII code for 2nd character ASCII code for 1st character (s)+1...
  • Page 643 Operation error Error code Description (SD0/SD8067) 2820H In the corresponding device range of the device specified by (s) and later, "00H" does not exist. 3405H (n) is not within the following range 0 to 16383 The character string specified by (s) has more than 16383 characters. "n"...
  • Page 644: Extracting Character String Data From The Left

    Extracting character string data from the left LEFT(P) FX5S FX5UJ FX5U FX5UC These instructions extract "n" characters of the character string data stored in the device specified by (s) and later from the left end (from the start), and store the extracted characters in the device specified by (d) and later. Ladder diagram Structured text ENO:=LEFTP(EN,s,n,d);...
  • Page 645 Processing details • These instructions extract "n" characters of the character string data stored in the device specified by (s) and later from the left end (from the start), and store the extracted characters in the device specified by (d) and later. ASCII code for 2nd character ASCII code for 1st character (s)+1...
  • Page 646 Operation error Error code Description (SD0/SD8067) 2820H In the corresponding device range of the device specified by (s) and later, "00H" does not exist. 3405H (n) is not within the following range 0 to 16383 The character string specified by (s) has more than 16383 characters. "n"...
  • Page 647: Storing The Specified Number Of Character Strings

    Storing the specified number of character strings MIDR(P) FX5S FX5UJ FX5U FX5UC These instructions extract the number of characters specified by (s2)+1 of the character string data stored in the device specified by (s1) and later from the position specified by (s2), and store the extracted characters in the device specified by (d) and later.
  • Page 648 Processing details • These instructions extract the number of characters specified by (s2)+1 of the character string data stored in the device specified by (s1) and later from the position specified by (s2), and store the extracted characters in the device specified by (d) and later.
  • Page 649 Precautions When handling character codes other than ASCII codes, note the following points: • The number of characters is handled in byte units (8 bits). Accordingly, in the case of character codes in which 2 bytes express 1 character such as shift JIS codes, 1 character is detected as "2". •...
  • Page 650: Replacing The Specified Number Of Character Strings

    Replacing the specified number of character strings MIDW(P) FX5S FX5UJ FX5U FX5UC These instructions extract the number of characters specified by (s2)+1 from the character string data stored in the device specified by (s1) and later, and store the extracted data in the position specified by (s2) and later of the character string data stored in the device specified by (d) and later.
  • Page 651 Processing details • These instructions extract the number of characters specified by (s2)+1 from the character string data stored in the device specified by (s1) and later, and store the extracted data in the position specified by (s2) and later of the character string data stored in the device specified by (d) and later.
  • Page 652 • When (s2)+1 (the number of characters to be extracted) is "-1", the entire character string stored in (s1) and later is stored to (d) and later. Before execution 42H (B) 41H (A) (d)+1 44H (D) 43H (C) (d)+2 46H (F) 45H (E) (s1) 31H (1)
  • Page 653 Program example In the program example shown below, 4 characters are extracted from the character string data stored in D0 and later, and stored to the 3rd character (from the left end) and later for the character string data stored in D100 and later when X10 turns MIDWP D100 Before execution...
  • Page 654: Searching Character String

    Searching character string INSTR(P) FX5S FX5UJ FX5U FX5UC These instructions search the character string data stored in the device specified by (s2) and later starting from the (s3)th character from the left, for the character string data stored in the device specified by (s1) and later and store the search result in the device specified by (d).
  • Page 655 Processing details • These instructions search the character string data stored in the device specified by (s2) and later starting from the (s3)th character from the left, for the character string data stored in the device specified by (s1) and later and store the search result in the device specified by (d).
  • Page 656 Program example In the program shown below, the character string stored in D0 and later is searched from the 5th character of the character string "CI2312CIM" stored in R0 and later when X0 is set to ON. The search results are stored in D100. INSTR D100 When character string to be...
  • Page 657: Inserting Character String

    Inserting character string STRINS(P) FX5S FX5UJ FX5U FX5UC These instructions insert the character string specified by (s1) at the (s2)th character from the start of the character string specified by (d). Ladder diagram Structured text ENO:=STRINS(EN,s1,s2,d); ENO:=STRINSP(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 658 Processing details • These instructions insert the character string specified by (s1) at the (s2)th character from the start of the character string specified by (d). (s1) 31H (1) 30H (0) (s1)+1 33H (3) 32H (2) 42H (B) 41H (A) The character string data of the (s1)+2 34H (4)
  • Page 659: Deleting Character String

    Deleting character string STRDEL(P) FX5S FX5UJ FX5U FX5UC These instructions delete (n) characters starting from the (s)th character (deletion start position) from the start of the character string data specified by (d). Ladder diagram Structured text ENO:=STRDEL(EN,s,n,d); ENO:=STRDELP(EN,s,n,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 660: Error Code

    Processing details • These instructions delete (n) characters starting from the (s)th character (deletion start position) from the start of the character string data specified by (d). The character string data of the deleted character After shifting, "00H" is stored and later is shifted rightward by 5 characters.
  • Page 661: 8.10 Real Number Instruction

    8.10 Real Number Instruction Comparing single-precision real numbers LDE, ANDE, ORE FX5S FX5UJ FX5U FX5UC These instructions perform a comparison operation between the single-precision real number in the device specified by (s1) and the single-precision real number in the device specified by (s2). (Devices are used as a normally open contact.) Ladder diagram Structured text ENO:=LDE_(EN,s1,s2);...
  • Page 662 Processing details • These instructions perform a comparison operation between the single-precision real number in the device specified by (s1) and the single-precision real number in the device specified by (s2). (Devices are used as a normally open contact.) • The following table lists the comparison operation results of each instruction. Instruction symbol Condition Result...
  • Page 663: Single-Precision Real Number Comparison

    Single-precision real number comparison DECMP(P) FX5S FX5UJ FX5U FX5UC These instructions compare two data values (single-precision real number), and output the result (larger, same or smaller) to three consecutive bit devices. Ladder diagram Structured text ENO:=DECMP(EN,s1,s2,d); ENO:=DECMPP(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 664 Processing details • These instructions compare the comparison value (s1) with the comparison source (s2) as floating point data, and one of the bits among (d), (d)+1, and (d)+2 turns on according to the result (smaller, same or larger). DECMP (s1) (s2) Turns on in the case of [(s1)+1, (s1)] >...
  • Page 665: Single-Precision Real Number Data Band Comparison

    Single-precision real number data band comparison DEZCP(P) FX5S FX5UJ FX5U FX5UC These instructions compare the comparison range of two points, upper and lower, with the binary floating point, and output the result to three consecutive bit devices in accordance with the larger, smaller, and band. Ladder diagram Structured text ENO:=DEZCP (EN, s1, s2, s3, d);...
  • Page 666 Processing details • These instructions compare the comparison values (s1) and (s2) with the comparison source (s3) as floating point data, and one of the bits among (d), (d)+1, and (d)+2 turns on according to the result (smaller, within the range or larger). DEZCP (s1) (s2)
  • Page 667: Adding Single-Precision Real Numbers

    Adding single-precision real numbers E+(P) [For 2 operands] FX5S FX5UJ FX5U FX5UC These instructions add the single-precision real number in the device specified by (s) to the single-precision real number in the device specified by (d), and store the result in the device specified by (d). Ladder diagram Structured text Not supported.
  • Page 668 Processing details • These instructions add the single-precision real number in the device specified by (s) to the single-precision real number in the device specified by (d), and store the result in the device specified by (d). (d)+1 (s)+1 (d)+1 Single-precision real number Single-precision real number Single-precision real number -126 ...
  • Page 669 E+(P) [For 3 operands] FX5S FX5UJ FX5U FX5UC These instructions add the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=EPLUS(EN, s1, s2, d);...
  • Page 670 Processing details • These instructions add the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 Single-precision real number...
  • Page 671: Subtracting Single-Precision Real Numbers

    Subtracting single-precision real numbers E-(P) [For 2 operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the single-precision real number in the device specified by (s) from the single-precision real number in the device specified by (d), and store the result in the device specified by (d). Ladder diagram Structured text Not supported.
  • Page 672 Operation error Error code Description (SD0/SD8067) The specified device value is -0, denormalized number, NaN (not a number), or . 3402H The value stored in specified device is outside the following range -126 |specified device value|<2 0, 2 8 APPLICATION INSTRUCTION 8.10 Real Number Instruction...
  • Page 673 E-(P) [For 3 operands] FX5S FX5UJ FX5U FX5UC These instructions subtract the single-precision real number in the device specified by (s2) from the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=EMINUS(EN, s1, s2, d);...
  • Page 674 Processing details • These instructions subtract the single-precision real number in the device specified by (s2) from the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 Single-precision real number...
  • Page 675 Adding single-precision real numbers DEADD(P) FX5S FX5UJ FX5U FX5UC These instructions add the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DEADD(EN,s1,s2,d);...
  • Page 676 Processing details • These instructions add the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 Single-precision real number...
  • Page 677 Subtracting single-precision real numbers DESUB(P) FX5S FX5UJ FX5U FX5UC These instructions subtract the single-precision real number in the device specified by (s2) from the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DESUB(EN,s1,s2,d);...
  • Page 678 Processing details • These instructions subtract the single-precision real number in the device specified by (s2) from the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 Single-precision real number...
  • Page 679: Multiplying Single-Precision Real Numbers

    Multiplying single-precision real numbers E*(P) FX5S FX5UJ FX5U FX5UC These instructions multiply the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=EMULTI(EN,s1,s2,d);...
  • Page 680 Processing details • These instructions multiply the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 ×...
  • Page 681: Dividing Single-Precision Real Numbers

    Dividing single-precision real numbers E/(P) FX5S FX5UJ FX5U FX5UC These instructions divide the single-precision real number in the device specified by (s1) by the single-precision real number in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=EDIVISION(EN,s1,s2,d);...
  • Page 682 Processing details • These instructions divide the single-precision real number in the device specified by (s1) by the single-precision real number in the device specified by (s2), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 ÷...
  • Page 683 Multiplying single-precision real numbers DEMUL(P) FX5S FX5UJ FX5U FX5UC These instructions multiply the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DEMUL(EN,s1,s2,d);...
  • Page 684 Processing details • These instructions multiply the single-precision real number in the device specified by (s2) to the single-precision real number in the device specified by (s1), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 ×...
  • Page 685 Dividing single-precision real numbers DEDIV(P) FX5S FX5UJ FX5U FX5UC These instructions divide the single-precision real number in the device specified by (s1) by the single-precision real number in the device specified by (s2), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DEDIV(EN,s1,s2,d);...
  • Page 686 Processing details • These instructions divide the single-precision real number in the device specified by (s1) by the single-precision real number in the device specified by (s2), and store the result in the device specified by (d). (s1)+1 (s1) (s2)+1 (s2) (d)+1 ÷...
  • Page 687: Converting 16-Bit Signed Binary Data To Single-Precision Real Number

    Converting 16-bit signed binary data to single-precision real number INT2FLT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit signed binary data in the device specified by (s) to single-precision real number, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=INT2FLT(EN,s,d);...
  • Page 688: Converting 16-Bit Unsigned Binary Data To Single-Precision Real Number

    Converting 16-bit unsigned binary data to single-precision real number UINT2FLT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit unsigned binary data in the device specified by (s) to single-precision real number, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UINT2FLT(EN,s,d);...
  • Page 689: Converting 32-Bit Signed Binary Data To Single-Precision Real Number

    Converting 32-bit signed binary data to single-precision real number DINT2FLT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit signed binary data in the device specified by (s) to single-precision real number, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DINT2FLT(EN,s,d);...
  • Page 690: Converting 32-Bit Unsigned Binary Data To Single-Precision Real Number

    Converting 32-bit unsigned binary data to single-precision real number UDINT2FLT(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit unsigned binary data in the device specified by (s) to single-precision real number, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=UDINT2FLT(EN,s,d);...
  • Page 691: Converting Character String To Single-Precision Real Number

    Converting character string to single-precision real number EVAL(P)/DEVAL(P) FX5S FX5UJ FX5U FX5UC These instructions convert the character strings in the device areas specified by (s) and later to single-precision real number, and store the converted data in the device specified by (d). The EVAL(P) instructions can also be used as DEVAL(P).
  • Page 692 Processing details • These instructions convert the character strings in the device areas specified by (s) and later to single-precision real number, and store the converted data in the device specified by (d). • A specified character string may be in the decimal point format or exponent format. A character string in either format can be converted into single-precision real number.
  • Page 693 Decimal point format • When the character string specified by (s) is decimal point format, the operation is executed as follows. 31H (1) 2DH (-) (s)+1 30H (0) 2EH (.) (d)+1 (s)+2 38H (8) 37H (7) (s)+3 32H (2) 31H (1) (s)+4 0 7 8 1 2 (1): Single-precision real number...
  • Page 694: Program Example

    • With regard to character string, six digits excluding the sign, decimal point and exponent part are valid, and the 7th and later digits are discarded during conversion. 20H (SP) 2DH (-) (s)+1 2EH (.) 31H (1) (d)+1 (s)+2 35H (5) 33H (3) - .
  • Page 695 Operation error Error code Description (SD0/SD8067) 2820H 00H does not exist in the corresponding device range starting from (s) 3401H Characters other than 30 (0) to 39 (9) exist in a character string specified by (s) 2EH (.) exists in two or more positions in a character string specified by (s) Any character other than 45H (E), 2BH (+), or 2DH (-) exists in the exponent part specified by (s), or two or more exponent parts exist 3405H The number of characters after (s) is 0 or more than 24...
  • Page 696: Converting Binary Floating Point To Decimal Floating Point

    Converting binary floating point to decimal floating point DEBCD(P) FX5S FX5UJ FX5U FX5UC These instructions convert the binary floating point specified by (s) to decimal floating point, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DEBCD(EN,s,d);...
  • Page 697 Precautions In floating point operations, all data is handled in binary floating point. Because binary floating point is difficult to understand (requiring a dedicated monitoring method), it is converted into scientific notation (decimal floating point) so that monitoring can be easily executed by peripheral equipment. Operation error Error code Description...
  • Page 698: Converting Decimal Floating Point To Binary Floating Point

    Converting decimal floating point to binary floating point DEBIN(P) FX5S FX5UJ FX5U FX5UC These instructions convert the decimal floating point specified by (s) to the binary floating point, and store the converted data in the device specified by (d). Ladder diagram Structured text ENO:=DEBIN(EN,s,d);...
  • Page 699 • The table below shows the related devices. Device Name Description Condition Operation SM700 Carry The absolute value of the The value of (d) is the maximum value (2 ) of 32-bit real numbers and the carry flag operation result  2 SM700 turns on.
  • Page 700: Inverting The Sign Of Single-Precision Real Number

    Inverting the sign of single-precision real number ENEG(P)/DENEG(P) FX5S FX5UJ FX5U FX5UC These instructions invert the sign of the single-precision real number specified by (d), and store the data of the device specified by (d). The ENEG(P) instructions can also be used as DENEG(P). Ladder diagram Structured text ENO:=ENEG(EN,d);...
  • Page 701 Operation error There is no operation error. 8 APPLICATION INSTRUCTION 8.10 Real Number Instruction...
  • Page 702: Transferring Single-Precision Real Number Data

    Transferring single-precision real number data EMOV(P)/DEMOV(P) FX5S FX5UJ FX5U FX5UC These instructions transfer the single-precision real number data stored in the device specified by (s) to the device specified by (d). The EMOV(P) instructions can also be used as DEMOV(P). Ladder diagram Structured text ENO:=EMOV(EN,s,d);...
  • Page 703 Program example In the program example shown below, a single-precision real number stored in D11 and D10 is transferred to D1 and D0 when X7 turns ON. DEMOVP 36.475 36.475 In the program shown below, a single-precision real number "-1.23" is transferred to D11 and D10 when X7 turns ON. DEMOVP E-1.23 -1.23...
  • Page 704: Calculating The Sine Of Single-Precision Real Number

    Calculating the sine of single-precision real number SIN(P)/DSIN(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the sine of the angle specified by (s), and store the operation result in the device specified by (d). The SIN(P) instructions can also be used as DSIN(P). Ladder diagram Structured text ENO:=SINP(EN,s,d);...
  • Page 705 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 706: Calculating The Cosine Of Single-Precision Real Number

    Calculating the cosine of single-precision real number COS(P)/DCOS(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the cosine of the angle specified by (s), and store the operation result in the device specified by (d). The COS(P) instructions can also be used as DCOS(P). Ladder diagram Structured text ENO:=COSP(EN,s,d);...
  • Page 707 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 708: Calculating The Tangent Of Single-Precision Real Number

    Calculating the tangent of single-precision real number TAN(P)/DTAN(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the tangent of the angle specified by (s), and store the operation result in the device specified by (d). The TAN(P) instructions can also be used as DTAN(P). Ladder diagram Structured text ENO:=TANP(EN,s,d);...
  • Page 709 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 710: Calculating The Arc Sine Of Single-Precision Real Number

    Calculating the arc sine of single-precision real number ASIN(P)/DASIN(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the angle from the sine of the angle specified by (s), and store the operation result in the word device specified by (d). The ASIN(P) instructions can also be used as DASIN(P). Ladder diagram Structured text ENO:=ASINP(EN,s,d);...
  • Page 711 Processing details • These instructions calculate the angle from the sine of the angle specified by (s), and store the operation result in the device specified by (d). (s)+1 (d)+1 Single-precision real number Single-precision real number • The sine value specified by (s) can be set ranging from -1.0 to 1.0. •...
  • Page 712 For the radianangle conversion, refer to the DRAD(P) and DDEG(P) instructions. (Page 716 Converting single-precision real number angle to radian, Page 718 Converting single-precision real number radian to angle) 8 APPLICATION INSTRUCTION 8.10 Real Number Instruction...
  • Page 713: Calculating The Arc Cosine Of Single-Precision Real Number

    Calculating the arc cosine of single-precision real number ACOS(P)/DACOS(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the angle from the cosine of the angle specified by (s), and store the operation result in the word device specified by (d). The ACOS(P) instructions can also be used as DACOS(P). Ladder diagram Structured text ENO:=ACOSP(EN,s,d)
  • Page 714 Processing details • These instructions calculate the angle from the cosine of the angle specified by (s), and store the operation result in the device specified by (d). (s)+1 (d)+1 Single-precision real number Single-precision real number • The cosine value specified by (s) can be set ranging from -1.0 to 1.0 •...
  • Page 715 For the radianangle conversion, refer to the DRAD(P) and DDEG(P) instructions. (Page 716 Converting single-precision real number angle to radian, Page 718 Converting single-precision real number radian to angle) 8 APPLICATION INSTRUCTION 8.10 Real Number Instruction...
  • Page 716: Calculating The Arc Tangent Of Single-Precision Real Number

    Calculating the arc tangent of single-precision real number ATAN(P)/DATAN(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the angle from the tangent of the angle specified by (s), and store the operation result in the word device specified by (d). The ATAN(P) instructions can also be used as DATAN(P). Ladder diagram Structured text ENO:=ATANP(EN,s,d);...
  • Page 717 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 718: Converting Single-Precision Real Number Angle To Radian

    Converting single-precision real number angle to radian RAD(P)/DRAD(P) FX5S FX5UJ FX5U FX5UC These instructions convert a unit of angle from degrees (DEG.) specified by (s) into radians, and store the converted angle in the device specified by (d). The RAD(P) instructions can also be used as DRAD(P). Ladder diagram Structured text ENO:=RAD(EN,s,d);...
  • Page 719 Processing details • These instructions convert a unit of angle from degrees (DEG.) specified by (s) into radians, and store the converted angle in the device specified by (d). (s)+1 (d)+1 )° ) rad Single-precision real number Single-precision real number •...
  • Page 720: Converting Single-Precision Real Number Radian To Angle

    Converting single-precision real number radian to angle DEG(P)/DDEG(P) FX5S FX5UJ FX5U FX5UC These instructions convert a unit of angle from radians specified by (s) into degrees (DEG.), and store the converted angle in the device specified by (d). The DEG(P) instructions can also be used as DDEG(P). Ladder diagram Structured text ENO:=DEG(EN,s,d);...
  • Page 721 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 722: Calculating The Square Root Of Single-Precision Real Number

    Calculating the square root of single-precision real number DESQR(P)/ESQRT(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the square root of a value specified by (s), and store the operation result in the device specified by (d). The DESQR(P) instructions can also be used as ESQRT(P). Refer to Page 1454 Added and Changed Functions for details on the ESQRT(P) instruction.
  • Page 723 Processing details • These instructions calculate the square root of a value specified by (s), and store the operation result in the device specified by (d). (s)+1 (d)+1 Single-precision real number Single-precision real number • Only a positive value can be set in (s). (The square root operation cannot be executed for a negative value). •...
  • Page 724: Calculating The Exponent Of Single-Precision Real Number

    Calculating the exponent of single-precision real number EXP(P)/DEXP(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the exponent of a value specified by (s), and store the operation result in the device specified by (d). The EXP(P) instructions can also be used as DEXP(P). Ladder diagram Structured text ENO:=EXPP(EN,s,d);...
  • Page 725 Device Name Description Condition Operation -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result < 2 flag SM8021 turns on. SM8022 Carry The absolute value of the The value of (d) is the maximum value (2...
  • Page 726: Calculating The Natural Logarithm Of Single-Precision Real Number

    Calculating the natural logarithm of single-precision real number LOG(P)/DLOGE(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the logarithm whose base is natural logarithm e of a value specified by (s), and store the operation result in the device specified by (d). The LOG(P) instructions can also be used as DLOGE(P).
  • Page 727 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 728: Calculating The Exponentiation Of Single-Precision Real Number

    Calculating the exponentiation of single-precision real number POW(P) FX5S FX5UJ FX5U FX5UC These instructions raise float (single precision) data stored in a device specified by (s1) by the single-precision real number specified by (s2), and store the operation result in a device specified by (d). Ladder diagram Structured text ENO:=POW(EN,s1,s2,d);...
  • Page 729 Processing details • These instructions raise float (single precision) data stored in a device specified by (s1) by the single-precision real number specified by (s2), and store the operation result in a device specified by (d). Power data (s2)+1 (s2) (s1)+1 (s1) (d)+1...
  • Page 730: Calculating The Common Logarithm Of Single-Precision Real Number

    Calculating the common logarithm of single-precision real number LOG10(P)/DLOG10(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the common logarithm (the logarithm whose base is 10) of a value specified by (s), and store the operation result in the device specified by (d). The LOG10(P) instructions can also be used as DLOG10(P).
  • Page 731 Device Name Description Condition Operation SM8020 Zero The operation result is true The zero flag SM8020 turns on. "0". (The mantissa part is "0"). -126 SM8021 Borrow The absolute value of the The value of (d) is the minimum value (2 ) of 32-bit real numbers and the borrow -126 operation result <...
  • Page 732: Searching The Maximum Value Of Single-Precision Real Number

    Searching the maximum value of single-precision real number EMAX(P) FX5S FX5UJ FX5U FX5UC These instructions search for the maximum value in the (n) point(s) of single-precision real number block data in the device starting from the one specified by (s), and store the maximum value in the device areas specified by (d) and (d)+1. These instructions also store the location of the first maximum value from (s) in the device specified by (d)+2 and the number of maximum values in the device specified by (d)+3.
  • Page 733 Processing details • These instructions search for the maximum value in the (n) point(s) of single-precision real number block data in the device starting from the one specified by (s), and store the maximum value in the device areas specified by (d). These instructions also store the location of the first maximum value from (s) in the device specified by (d)+2 and the number of maximum values in the device specified by (d)+3.
  • Page 734: Searching The Minimum Value Of Single-Precision Real Number

    Searching the minimum value of single-precision real number EMIN(P) FX5S FX5UJ FX5U FX5UC These instructions search for the minimum value in the (n) point(s) of single-precision real number block data in the device starting from the one specified by (s), and store the minimum value in the device areas specified by (d) and (d)+1. These instructions also store the location of the first minimum value from (s) in the device specified by (d)+2 and the number of minimum values in the device specified by (d)+3.
  • Page 735 Processing details • These instructions search for the minimum value in the (n) point(s) of single-precision real number block data in the device starting from the one specified by (s), and store the minimum value in the device areas specified by (d) and (d)+1. These instructions also store the location of the first minimum value from (s) in the device specified by (d)+2 and the number of minimum values in the device specified by (d)+3.
  • Page 736: Generating Random Number

    8.11 Random Number Instruction Generating random number RND(P) FX5S FX5UJ FX5U FX5UC These instructions generate a pseudo-random number ranging from 0 to 32767, and store it as a random number to a device specified by (d). Ladder diagram Structured text ENO:=RND(EN,d);...
  • Page 737 Program example When the PLC mode switches from STOP to RUN, the time data converted into seconds and added by the value "(Year + Month)  Day" is written to SD8311 and SD8310. In the program example shown below, a random number is stored to D100 every time X10 turns ON. SM402 The clock data is read.
  • Page 738: Saving All Data Of The Index Register

    8.12 Index Register Operation Instruction Saving all data of the index register ZPUSH(P) FX5S FX5UJ FX5U FX5UC These instructions save the contents of index registers and long index registers in the devices specified by (d) and later. Ladder diagram Structured text ENO:=ZPUSH(EN,d);...
  • Page 739 • The following shows the areas of (d) and later to be used. (d)+0 (1): Number of times of batch-storage (2): 1st nesting (24 words for one nesting) (3): 2nd nesting Precautions • When a nesting structure is not adopted, clear (d) before executing the ZPUSH(P) instructions. •...
  • Page 740 Program example In the program shown below, the contents of the index register (Z) before execution of the subroutine program are batch- stored in D0 and later when index registers are used in the subroutine program after the pointer P0. SM402 MOVP MOVP...
  • Page 741: Returning All Data Of The Index Register

    Returning all data of the index register ZPOP(P) FX5S FX5UJ FX5U FX5UC These instructions read the data saved in the devices specified by (d) and later to index registers and long index registers. Ladder diagram Structured text ENO:=ZPOP(EN,d); ENO:=ZPOPP(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand...
  • Page 742: Saving The Selected Data Of The Index Register And Long Index Register

    Saving the selected data of the index register and long index register ZPUSH(P) FX5S FX5UJ FX5U FX5UC These instructions save the contents of index registers and long index registers within the range specified by (s) in the devices specified by (d) and later. Ladder diagram Structured text ENO:=ZPUSH_2(EN,s,d);...
  • Page 743 • When a nesting structure is adopted, the areas to be used are added to (d) and later every time the selected data of index register/long index register save instructions (ZPUSH(P) instructions) are executed. Check the number of index registers and long index registers by SD300 and SD302, and secure the areas for the number of instructions to be used in advance.
  • Page 744: Returning The Selected Data Of The Index Register And Long Index Register

    Returning the selected data of the index register and long index register ZPOP(P) FX5S FX5UJ FX5U FX5UC These instructions read the data saved in the devices specified by (d) and later to index registers and long index registers. Ladder diagram Structured text ENO:=ZPOP_2(EN,s,d);...
  • Page 745: Data Control Instruction

    8.13 Data Control Instruction Upper and lower limit control of 16-bit binary data LIMIT(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions control the output value to be stored in the device specified by (d) by checking the input value (16-bit binary data) in the device specified by (s3) with the upper and lower limit values specified by (s1) and (s2).
  • Page 746 Processing details • These instructions control the output value to be stored in the device specified by (d) by checking the input value (16-bit binary data) in the device specified by (s3) with the upper and lower limit values specified by (s1) and (s2). The output value is controlled as follows.
  • Page 747: Upper And Lower Limit Control Of 32-Bit Binary Data

    Upper and lower limit control of 32-bit binary data DLIMIT(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions control the output value to be stored in the device specified by (d) by checking the input value (32-bit binary data) in the device specified by (s3) with the upper and lower limit values specified by (s1) and (s2). Ladder diagram Structured text ENO:=DLIMITP(EN,s1,s2,s3,d);...
  • Page 748 Processing details • These instructions control the output value to be stored in the device specified by (d) by checking the input value (32-bit binary data) in the device specified by (s3) with the upper and lower limit values specified by (s1) and (s2). The output value is controlled as follows.
  • Page 749: Dead Band Control Of 16-Bit Binary Data

    Dead band control of 16-bit binary data BAND(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions control the output value to be stored in the device specified by (d) by checking the input value (16-bit binary data) in the device specified by (s3) with the upper and lower limit values of the dead band specified by (s1) and (s2). Ladder diagram Structured text ENO:=BAND(EN,s1,s2,s3,d);...
  • Page 750 Processing details • These instructions control the output value to be stored in the device specified by (d) by checking the input value (16-bit binary data) in the device specified by (s3) with the upper and lower limit values of the dead band specified by (s1) and (s2). The output value is controlled as follows.
  • Page 751: Dead Band Control Of 32-Bit Binary Data

    Dead band control of 32-bit binary data DBAND(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions control the output value to be stored in the device specified by (d) by checking the input value (32-bit binary data) in the device specified by (s3) with the upper and lower limit values of the dead band specified by (s1) and (s2). Ladder diagram Structured text ENO:=DBAND(EN,s1,s2,s3,d);...
  • Page 752 Processing details • These instructions control the output value to be stored in the device specified by (d) by checking the input value (32-bit binary data) in the device specified by (s3) with the upper and lower limit values of the dead band specified by (s1) and (s2). The output value is controlled as follows.
  • Page 753 Operation error Error code Description (SD0/SD8067) 3405H The lower limit value specified by (s1) is greater than the upper limit value specified by (s2). 8 APPLICATION INSTRUCTION 8.13 Data Control Instruction...
  • Page 754: Zone Control Of 16-Bit Binary Data

    Zone control of 16-bit binary data ZONE(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the bias value specified by (s1) or (s2) to the input value specified by (s3), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=ZONE(EN,s1,s2,s3,d);...
  • Page 755 Processing details • These instructions add the bias value specified by (s1) or (s2) to the input value (16-bit binary data) specified by (s3), and store the operation result in the device specified by (d). The bias value is controlled as follows. Condition Output value Input value (s3) <...
  • Page 756: Zone Control Of 32-Bit Binary Data

    Zone control of 32-bit binary data DZONE(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the bias value specified by (s1) or (s2) to the input value specified by (s3), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=DZONE(EN,s1,s2,s3,d);...
  • Page 757 Processing details • These instructions add the bias value specified by (s1) or (s2) to the input value (32-bit binary data) specified by (s3), and store the operation result in the device specified by (d). The bias value is controlled as follows. Condition Output value Input value ((s3), (s3)+1) <...
  • Page 758: Scaling 16-Bit Binary Data (Point Coordinates)

    Scaling 16-bit binary data (point coordinates) SCL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions process the scaling conversion data (in 16-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=SCL(EN,s1,s2,d);...
  • Page 759 Processing details • These instructions process the scaling conversion data (in 16-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device number specified by (d). The scaling conversion is performed based on the scaling conversion data stored in the device specified by (s2) and later.
  • Page 760 Setting item Setting device and setting contents When R0 is specified in (s2) Setting details Point 4 X coordinate (s2)+7 K200 Y coordinate (s2)+8 Point 5 X coordinate (s2)+9 K200 Y coordinate (s2)+10 Point 6 X coordinate (s2)+11 K200 Y coordinate (s2)+12 K250 Point 7...
  • Page 761: Scaling 32-Bit Binary Data (Point Coordinates)

    Scaling 32-bit binary data (point coordinates) DSCL(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions process the scaling conversion data (in 32-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=DSCL(EN,s1,s2,d);...
  • Page 762 Processing details • These instructions process the scaling conversion data (in 32-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device number specified by (d). The scaling conversion is performed based on the scaling conversion data stored in the device specified by (s2) and later.
  • Page 763 Setting item Setting device and setting contents When R0 is specified in (s2) Setting details Point 4 X coordinate (s2)+15, (s2)+14 R15, R14 K200 Y coordinate (s2)+17, (s2)+16 R17, R16 Point 5 X coordinate (s2)+19, (s2)+18 R19, R18 K200 Y coordinate (s2)+21, (s2)+20 R21, R20 Point 6...
  • Page 764: Scaling 16-Bit Binary Data (Xy Coordinates)

    Scaling 16-bit binary data (XY coordinates) SCL2(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions process the scaling conversion data (in 16-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=SCL2(EN,s1,s2,d);...
  • Page 765 Processing details • These instructions process the scaling conversion data (in 16-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device number specified by (d). The scaling conversion is performed based on the scaling conversion data stored in the device specified by (s2) and later.
  • Page 766 • Setting example of the conversion table for scaling In the case of the conversion characteristics for scaling shown in the figure below, set each value as shown in the following data table. Point 6 (200, 250) Point 3 Point 7 (50, 100) Point 5 (250, 90)
  • Page 767 Program example In the program example shown below, the value input to D0 is processed by scaling based on the conversion table for scaling set in R0 and later, and output to D10. It is assumed that the values for the conversion table for scaling are set in R0 and later beforehand.
  • Page 768: Scaling 32-Bit Binary Data (Xy Coordinates)

    Scaling 32-bit binary data (XY coordinates) DSCL2(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions process the scaling conversion data (in 32-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device specified by (d). Ladder diagram Structured text ENO:=DSCL2(EN,s1,s2,d);...
  • Page 769 Processing details • These instructions process the scaling conversion data (in 32-bit data units) specified by (s2) by scaling it based on the input value specified by (s1), and store the operation result in the device number specified by (d). The scaling conversion is performed based on the scaling conversion data stored in the device specified by (s2) and later.
  • Page 770 • Setting example of the conversion table for scaling In the case of the conversion characteristics for scaling shown in the figure below, set each value as shown in the following data table. Point 6 (200, 250) Point 3 Point 7 (50, 100) Point 5 (250, 90)
  • Page 771: Teaching Timer

    8.14 Special Timer Instruction Teaching timer TTMR FX5S FX5UJ FX5U FX5UC This instruction measures the period of time in which TTMR instruction is ON. Use this instruction to adjust the set value of a timer by a pushbutton switch. Ladder diagram Structured text ENO:=TTMR(EN,s,d);...
  • Page 772 Processing details • This instruction measures the period of time to press and hold the command input (pushbutton switch) in 1-second units, multiplies the measured value by the magnification (10 ) which is specified by (s), and stores it in the device specified by (d).
  • Page 773 Program example • Writing the teaching time to 10 types of data registers Suppose that the set value is written to D400 to D409 in advance. D400 D401 D402 D403 D404 10 timers to be set Because the timers T0 to T9 are set to 100 ms, the actual operating time (sec) is 1/10 of the teaching data.
  • Page 774: Special Function Timer

    Special function timer STMR FX5S FX5UJ FX5U FX5UC This instruction uses the four devices from the device specified by (d) to perform four types of timer output. Ladder diagram Structured text ENO:=STMR(EN,s1,s2,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 775 Processing details • This instruction uses the four devices from the device specified by (d) to perform four types of timer output. (d)+1 (d)+2 (d)+3 (1): Command of the STMR instruction (2): Setting value specified by (s2) • The flickering effect is produced using (d)+1 and (d)+2 with the following program (T10 is assigned to (s1), K100 is assigned to (s2), and M0 is assigned to (d)), which turns on/off the STMR instruction at the normally closed contact of (d)+3.
  • Page 776 8.15 Special Counter Instruction Signed 32-bit bi-directional counters UDCNTF FX5S FX5UJ FX5U FX5UC This instruction increments the current value of the counter specified by (d) by 1 when the operation result up to UDCNTF instruction changes from OFF to ON, and when the counter reaches the end of its count, NO contact becomes turns ON and NC contact becomes turns OFF.
  • Page 777 Processing details • This instruction increments the current value of the counter specified by (d) by 1 when the operation result up to UDCNTF instruction changes from OFF to ON, and when the counter reaches the end of its count, NO contact becomes turns ON and NC contact becomes turns OFF.
  • Page 778: Rotary Table Shortest Direction Control

    8.16 Shortcut Control Instruction Rotary table shortest direction control ROTC FX5S FX5UJ FX5U FX5UC This instruction is suitable for efficient control of the rotary table for putting/taking a product on/off the rotary table. Ladder diagram Structured text ENO:=ROTC(EN,s,n1,n2,d); (n1) (n2) FBD/LD Setting data Descriptions, ranges, and data types...
  • Page 779 Processing details • The table rotation is controlled by conditions of "n2", (s), and (d) so that a product can be efficiently put on or taken off the rotary table divided into "n1" (=10) sections as shown in the figure below. When the following conditions are specified, forward/backward rotation and high-speed/low-speed/stop are output to (d)+3 to (d)+7.
  • Page 780 Operation error Error code Description (SD0/SD8067) 1811H The number of the ROTC instructions which are used simultaneously exceeds four. 2820H The device range specified by (s) exceeds the corresponding device range. The device range specified by (d) exceeds the corresponding device range. 3405H The value specified by (n1) is outside the following range.
  • Page 781: Ramp Signal Instruction

    8.17 Ramp Signal Instruction Ramp signal RAMPF FX5S FX5UJ FX5U FX5UC This instruction obtains the data which changes between the start value (initial value) and the end value (target value) over the specified "n" times. Ladder diagram Structured text ENO:=RAMPF(EN,s1,s2,n,d); (s1) (s2) FBD/LD...
  • Page 782 Processing details • When the start value (s1) and the end value (s2) have been specified and the command input is set to ON, the value obtained by adding a value divided equally by "n" times to (s1) in the next operation cycle is stored to (d). By combining this instruction and an analog output, the cushion start/stop command can be output.
  • Page 783 • The contents of (d) are changed as follows depending on the ON/OFF status of the mode flag SM8026. When SM8026 is off When SM8026 is on Command Command (s2) (s2) (s1) (s1) (SM8029) (SM8029) Precautions To specify a latched (battery backed) type device as (d) when setting the CPU module to the RUN mode while the command input is ON, clear (d) in advance.
  • Page 784: Pulse Related Instruction

    8.18 Pulse Related Instruction Instruction correspondence table for CPU module built-in positioning and high-speed pulse input/output module The table for instructions corresponding to the CPU module and the high-speed pulse input/output module are shown below. : Supported, : Not supported Instruction CPU module High-speed pulse input/output module...
  • Page 785 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 786 [FX5S/FX5UJ CPU module] General-purpose input assignment of the 1-phase 1-input counter (switching S/W up or down) U/D: UP/DOWN pulse input, P: Preset input (reset), E: Enable input (start) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) General-purpose input assignment of the 1-phase 1-input counter (switching H/W up or down) C: Pulse input, D: Direction input, P: Preset input (reset), E: Enable input (start) C(A) D(B)
  • Page 787 [FX5U/FX5UC CPU module] General-purpose input assignment of the 1-phase 1-input counter (switching S/W up or down) U/D: UP/DOWN pulse input, P: Preset input (reset), E: Enable input (start) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) U/D(A) If one of X10 to X17 is specified as a device, an error occurs. General-purpose input assignment of the 1-phase 1-input counter (switching H/W up or down) C: Pulse input, D: Direction input, P: Preset input (reset), E: Enable input (start) C(A)
  • Page 788 General-purpose input assignment of the 2-phase 2-input counter A: A phase pulse input, B: B phase pulse input, P: Preset input (reset), E: Enable input (start) If one of X1, X3, X5, X7, X11, X13, X15, X17 is specified as a device, an error occurs. •...
  • Page 789 • When the SPD instruction is used, the UP/DOWN pulse input, preset input and enable input operate in accordance with the contents set by the parameters of the high-speed counter. • When the measurement time is changed while the SPD instruction is executed, the changed time is applied every time the measurement time ends.
  • Page 790: Measuring The Density Of 32 Bit Binary Pulses

    Measuring the density of 32 bit binary pulses DSPD FX5S FX5UJ FX5U FX5UC This instruction counts the number of times the device input specified by (s1) turns off  on only for the time (in 32-bit data units) specified by (s2)  1ms and stores the operation result in the device specified by (d). The high-speed pulse input/output module is not supported.
  • Page 791 Processing details • This instruction counts the number of times the device input specified by (s1) turns off  on only for the time (in 32-bit data units) specified by (s2)  1ms and stores the operation result in the device specified by (d). Counting start (s2)+1, (s2) ms (s2)+1, (s2) ms...
  • Page 792 General-purpose input assignment of the 1-phase 2-input counter U: UP pulse input, D: DOWN pulse input, P: Preset input (reset), E: Enable input (start) U(A) D(B) U(A) D(B) U(A) D(B) U(A) D(B) U(A) D(B) U(A) D(B) U(A) D(B) General-purpose input assignment of the 2-phase 2-input counter A: A phase pulse input, B: B phase pulse input, P: Preset input (reset), E: Enable input (start) If one of X1, X2, X4, X5, X7 is specified as a device, an error occurs.
  • Page 793 General-purpose input assignment of the 1-phase 1-input counter (switching H/W up or down) C: Pulse input, D: Direction input, P: Preset input (reset), E: Enable input (start) C(A) D(B) C(A) D(B) C(A) D(B) C(A) D(B) C(A) D(B) C(A) D(B) C(A) D(B) C(A) D(B)
  • Page 794 • The table below shows the related devices. Function Monitor in operation SM4500 SM4501 SM4502 SM4503 SM4504 SM4505 SM4506 SM4507 High-speed counter SD4507, SD4537, SD4567, SD4597, SD4627, SD4657, SD4687, SD4717, pulse density SD4506 SD4536 SD4566 SD4596 SD4626 SD4656 SD4686 SD4716 Measurement unit time SD4517, SD4547,...
  • Page 795: Bit Binary Pulse Output

    16 bit binary pulse output PLSY [For the FX3 compatible operand specification] FX5S FX5UJ FX5U FX5UC This instruction outputs 16-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 16-bit pulses specified by the positioning address (n). Only CPU module is supported. Ladder diagram Structured text ENO:=PLSY(EN,s,n,d);...
  • Page 796 Processing details • This instruction outputs 16-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 16-bit pulses specified by the positioning address (n). • Set the value from 0 to 65535 (in user unit) to the command speed (s), so that the command speed is 200 kpps or less when the command speed is converted to frequency.
  • Page 797 [Special registers (FX3 compatible area)] Axis number Name   SD8136, SD8137 Total number of outputs for axis 1 and 2 of PLSY instruction SD8140, SD8142,   Total number of output pulses of PLSY instruction SD8141 SD8143 SD8340, SD8350, SD8360, SD8370, Current address (in pulse unit)
  • Page 798 Operation error Error code Description (SD0/SD8067) Axis 1 Axis 2 Axis 3 Axis 4 SD5510 SD5550 SD5590 SD5630 1810H The axis number specified by (d) is used by another instruction. 3405H The value specified by (s) is outside the following range. 0 to 65535 The value specified by (n) is outside the following range.
  • Page 799 PLSY [For the FX5 operand specification] FX5S FX5UJ FX5U FX5UC This instruction outputs 16-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 16-bit pulses specified by the positioning address (n). Only CPU module is supported. Ladder diagram Structured text ENO:=PLSY(EN,s,n,d);...
  • Page 800 Processing details • This instruction outputs 16-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 16-bit pulses specified by the positioning address (n). • Set the value from 0 to 65535 (in user unit) to the command speed (s), so that the command speed is 200 kpps or less when the command speed is converted to frequency.
  • Page 801 Precautions • The operation cannot be performed normally in an environment such as user program where the instruction cannot be executed at each scan or if the instruction is jumped by the CJ(P) instruction. However, the pulse output is continued. •...
  • Page 802 Operation error Error code Description (SD0/SD8067) Axis 1 Axis 2 Axis 3 Axis 4 SD5510 SD5550 SD5590 SD5630 1810H The axis number specified by (d) is used by another instruction. 3405H The value specified by (s) is outside the following range. 0 to 65535 The value specified by (n) is outside the following range.
  • Page 803 32 bit binary pulse output DPLSY [For the FX3 compatible operand specification] FX5S FX5UJ FX5U FX5UC This instruction outputs 32-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 32-bit pulses specified by the positioning address (n). Only CPU module is supported. Ladder diagram Structured text ENO:=DPLSY(EN,s,n,d);...
  • Page 804 • Set the value from 0 to 2147483647 (in user unit) to the positioning address (n), so that the positioning address is within the range from 0 to 2147483647 when the positioning address is converted to number of pulses. • Specify the following Y device number in (d). - FX5S/FX5U/FX5UC CPU module: Y0 to Y3 - FX5UJ CPU module: Y0 to Y2 •...
  • Page 805 Precautions • The operation cannot be performed normally in an environment such as user program where the instruction cannot be executed at each scan or if the instruction is jumped by the CJ(P) instruction. However, the pulse output is continued. •...
  • Page 806 Operation error Error code Description (SD0/SD8067) Axis 1 Axis 2 Axis 3 Axis 4 SD5510 SD5550 SD5590 SD5630 1810H The axis number specified by (d) is used by another instruction. 3405H The value specified by (s) is outside the following range. 0 to 65535 The value specified by (n) is outside the following range.
  • Page 807 DPLSY [For the FX5 operand specification] FX5S FX5UJ FX5U FX5UC This instruction outputs 32-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 32-bit pulses specified by the positioning address (n). Only CPU module is supported. Ladder diagram Structured text ENO:=DPLSY(EN,s,n,d);...
  • Page 808 Processing details • This instruction outputs 32-bit pulse trains specified by the command speed (s) from the device specified by the output (d) for the amount of 32-bit pulses specified by the positioning address (n). [(n)+1, (n)] [(s)+1, (s)] • Set the value from 0 to 2147483647 (in user unit) to the command speed (s), so that the command speed is 200 kpps or less when the command speed is converted to frequency.
  • Page 809 Precautions • The operation cannot be performed normally in an environment such as user program where the instruction cannot be executed at each scan or if the instruction is jumped by the CJ(P) instruction. However, the pulse output is continued. •...
  • Page 810 Operation error Error code Description (SD0/SD8067) Axis 1 Axis 2 Axis 3 Axis 4 SD5510 SD5550 SD5590 SD5630 1810H The axis number specified by (d) is used by another instruction. 3405H The value specified by (s) is outside the following range. 0 to 65535 The value specified by (n) is outside the following range.
  • Page 811 16 bit binary pulse width modulation FX5S FX5UJ FX5U FX5UC This instruction outputs the pulse (in 16-bit data units) of the ON time (in 16-bit data units) specified by (s1) and the period specified by (s2) to the output destination specified by (d). Ladder diagram Structured text ENO:=PWM(EN,s1,s2,d);...
  • Page 812 Processing details • This instruction outputs the pulse of the ON time specified by (s1) and the period specified by (s2) to the output destination specified by (d). (s1) (s2) • Time with a unit selected on the parameter setting screen (s or ms) can be specified by (s1) and (s2). •...
  • Page 813 Pulse output Period Initial Timing of reflection on Timing of clearing to initial destination channel value operation value SD5305, SD5304 • When the DHCMOV instruction is STOP/PAUSERUN executed SD5321, SD5320 • When this instruction is executed SD5337, SD5336 • END processing SD5353, SD5352 SD5369, SD5368 SD5385, SD5384...
  • Page 814 • When the number of output pulses is specified, the output pulses are monitored. When the PWM output is executed several times, the monitor of the number of output pulses is an integrated value. • The monitor of the current number of output pulses can be changed during the pulse output. •...
  • Page 815 • Operations when the PWM output is stopped (while the output pulse is on) ON time ON time setting is 5 μs setting is 5 μs or less or less If an output stop command is issued while the ON time setting is 5 μs or less, outputting pulses stops after the set ON time elapses.
  • Page 816 • Operations when the PWM output is stopped (while the output pulse is off) Output stop command Period If an output stop command is issued while the OFF time setting is 5 μs or less, outputting pulses stops after the set OFF time elapses. OFF time setting OFF time setting is 5 μs or less...
  • Page 817 Operation error Error code Description (SD0/SD8067) 1810H The output destination specified by (d) is already used by another instruction (positioning instruction). (The PWM output is not executed.) A Y device is specified as the output destination specified by (d), and there is no unused channel number in the parameter setting. 2221H The parameter set value is out of range.
  • Page 818: Bit Binary Pulse Width Modulation

    32 bit binary pulse width modulation DPWM FX5S FX5UJ FX5U FX5UC This instruction outputs the pulse (in 32-bit data units) of the ON time (in 32-bit data units) specified by (s1) and the period specified by (s2) to the output destination specified by (d). Ladder diagram Structured text ENO:=DPWM(EN,s1,s2,d);...
  • Page 819 Processing details • This instruction outputs the pulse of the ON time specified by (s1) and the period specified by (s2) to the output destination specified by (d). (s1) (s2) • Time with a unit selected on the parameter setting screen (s or ms) can be specified by (s1) and (s2). •...
  • Page 820 Pulse output Period Initial Timing of reflection on Timing of clearing to initial destination channel value operation value SD5305, SD5304 • When the DHCMOV instruction is STOP/PAUSERUN executed SD5321, SD5320 • When the DPWM instruction is SD5337, SD5336 executed SD5353, SD5352 •...
  • Page 821 • When the number of output pulses is specified, the output pulses are monitored. When the DPWM output is executed several times, the monitor of the number of output pulses is an integrated value. • The monitor of the current number of output pulses can be changed during the pulse output. •...
  • Page 822 Precautions • Specify the ON time by (s1) and the period by (s2) so that [(s2)-(s1)] is equal to or larger than 3 s. • When a negative value is specified for the ON time by (s1) and the period by (s2), an operation error occurs. (In 16-bit instruction PWM, no error occurs.) •...
  • Page 823 • Operations when the DPWM output is stopped (while the output pulse is off) Output stop command Period If an output stop command is issued while the OFF time setting is 5 μs or less, outputting pulses stops after the set OFF time elapses. OFF time setting OFF time setting is 5 μs or less...
  • Page 824: Error Code

    Operation error Error code Description (SD0/SD8067) 1810H The output destination specified by (d) is already used by another instruction (positioning instruction). (The PWM output is not executed.) A Y device is specified as the output destination specified by (d), and there is no unused channel number in the parameter setting 2221H The parameter set value is out of range.
  • Page 825: Input Matrix

    8.19 Input Matrix Instruction Input matrix FX5S FX5UJ FX5U FX5UC Reads matrix input as 8-point input  "n"-point output (transistor) in the time division method. Ladder diagram Structured text ENO:=MTR(EN, s, n, d1, d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 826 Processing details • An input signal of 8 points x "n" columns is controlled in the time division method using 8 inputs specified in (s) and transistor outputs specified in (d1). Each column is read in turn, and then output to devices specified in (d2). •...
  • Page 827 • The table below shows the related devices. Device Name Description SM8029 Instruction execution ON: Turns ON after the matrix in the nth (last) column is input. complete OFF: Remains OFF while the matrix in the 1st to nth (last) columns is being input. Precautions •...
  • Page 828 • Because 64 input points (8 rows  8 columns) are received in a cycle of 80 or 160 ms, the ON/OFF duration of each input signal should be greater than or equal to the value shown below: 80ms 80ms 160ms 160ms FX5S/FX5UJ CPU module: When using X0 to X7...
  • Page 829: Initial State

    8.20 Initial State Initial State FX5S FX5UJ FX5U FX5UC Automatically controls the initial state and special relays in a step ladder program. Ladder diagram Structured text ENO:=IST(EN, s, d1, d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 830 • The switch functions shown in the table below are assigned to each of the devices specified for selector switches in the operation mode. When X20 is assigned, it is necessary to set X20 to X24 as rotary switches so that they do not turn ON at the same time.
  • Page 831 • While the command input is ON, the following devices are automatically switched and controlled. While the command input is OFF, the devices are not switched. Device number Descriptions ON/OFF condition SM8040 STL transfer disable ON condition Always remains ON in the individual operation. Always remains ON in the stepping operation except when the [START] button is pressed.
  • Page 832: Ist Instruction Equivalent Circuit

    Precautions • It is not necessary to use all switches for mode selection. When some switches are not used, leave the corresponding numbers in the unused status. Such numbers cannot be used for any other purpose. • The IST instruction should be programmed earlier than a series of STL circuit such as state relays S0 to S2. •...
  • Page 833: Example Of Ist Instruction Introduction (Example Of Workpiece Transfer Mechanism)

    • When the operation mode is switched among the individual operation, zero return operation and automatic operation, all outputs and conventional states are reset at one time unless the machine is located in the zero point. (Reset of all outputs is not executed when SM8045 is driven.) SM8043 Zero return...
  • Page 834 • Transfer mechanism Start Left limit X4 (4) Rightward Y3 Zero point (8) Leftward Y4 Upper limit Right limit (1) Moving down Upper limit X2 (1) Moving down (7) Moving up (3) Moving up Lower limit Lower limit What is the zero point condition? Upper limit X2 is ON, left limit Clamping Unclamping...
  • Page 835 • For using IST instruction, it is necessary to assign inputs having consecutive device numbers as shown below for mode inputs. When using non-consecutive inputs or omitting some modes, change the layout by using an auxiliary relay as the head input for mode specification as shown in the figure below. Input device Assignment Individual operation mode...
  • Page 836: Program Example

    • Special relay (SM) used in the IST instruction are classified into two types. Some special relays are automatically controlled by the IST instruction itself according to the situation. Other special relays should be controlled by a program for preparation of operation or for purpose of control. Special relay Description Remarks...
  • Page 837 • Programming is not required when the individual operation mode is not provided. Initial state for individual operation Clamping command Clamping Unclamping command Moving-up command Moving up Moving-down command Moving down Leftward travel command Leftward travel Rightward travel command Rightward travel Upper limit RETSTL •...
  • Page 838 • Automatic mode (stepping operation mode, cycle operation mode or continuous operation mode) Initial state for automatic mode SM8041 SM8044 Transfer Zero point start condition SM400 Moving down Down limit SM400 Clamping T0 K10 SM400 Moving up Upper limit SM400 Rightward travel Right limit SM400...
  • Page 839 Operation error Error code Description (SD0/SD8067) 1811H The number of times the IST instruction is simultaneously driven exceeds 1. 2820H The device numbers specified in (d1) and (d2) show the following relationship: (d1)  (d2) Eight points are not secured from the device specified in (s). An unavailable device is set in (s).
  • Page 840: Applicable Devices

    8.21 Drum Sequence 16-bit binary data absolute method ABSD FX5S FX5UJ FX5U FX5UC This instruction creates many output patterns corresponding to the current value (16-bit binary data) of a counter. Ladder diagram Structured text ENO:=ABSD(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 841: Processing Details

    Processing details • In this example, outputs are controlled to on or off by one table rotation (0 to 360 using the rotation angle signal of 1/ pulse). • The current value (s2) of the counter is compared with the data table with "n" lines starting from (s1) (which occupies "n" lines ...
  • Page 842 32-bit binary data absolute method DABSD FX5S FX5UJ FX5U FX5UC This instruction creates many output patterns corresponding to the current value (32-bit binary data) of a counter. Ladder diagram Structured text ENO:=DABSD(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 843 Processing details • In this example, outputs are controlled to on or off by one table rotation (0 to 360 using the rotation angle signal of 1/ pulse). • The current value (s2) of the counter is compared with the data table with "n" lines starting from (s1) (which occupies "n" lines ...
  • Page 844: Relative Method

    Relative method INCD FX5S FX5UJ FX5U FX5UC This instruction creates many output patterns using a pair of counters. Ladder diagram Structured text ENO:=INCD(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 845: Operation Example

    Operation example • The following ladder example shows the operation. (s2) occupies two points. In the following timing chart, C0 and C1 correspond to the two points. INCD D300 K9999 SM412 1 sec clock • Suppose that the following data is written in advance by a transfer instruction: Device storing data Output ...
  • Page 846: Error Code

    Operation error Error code Description (SD0/SD8067) 2820H The number of device points specified by (s1), (s2), or (d) is insufficient. 3405H The value specified by (n) is outside the following range. 1 to 64 8 APPLICATION INSTRUCTION 8.21 Drum Sequence...
  • Page 847: Check Code

    8.22 Check Code Check code CCD(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the horizontal parity value and sum check value in the error check methods used in communication. There is another check method, called CRC (cyclic redundancy check). For obtaining CRC value, use the CRC(P) instructions.
  • Page 848 Processing details • These instructions calculate the addition data and horizontal parity value of data stored in (s) to (s)+(n)-1. The addition data is stored to (d), and the horizontal parity value is stored to (d)+1. The 16-bit mode and 8-bit mode are available for these instructions.
  • Page 849 • 8-bit conversion mode (while SM8161 is ON) With regard to (n) data points starting from (s), the addition data and horizontal parity data of only low-order 8 bits are stored to (d) and (d)+1 respectively. SM8161 is shared with the ASCI(P), HEXA(P), and CRC(P) instructions. SM8161 must always be on in the 8-bit mode. SM8161 is cleared when the CPU module mode is changed from RUN to STOP.
  • Page 850: Searching 16-Bit Data

    8.23 Data Operation Instruction Searching 16-bit data SERMM(P) FX5S FX5UJ FX5U FX5UC These instructions search for the same data, maximum value and minimum value in a data table. Ladder diagram Structured text ENO:=SERMM(EN,s1,s2,n,d); ENO:=SERMMP(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 851 • The following table shows example of search result table configuration and data. (n=10) Searched device Searched data Comparison data Data position Search result (s1) (s1) value (s2) value Maximum Same (d) Minimum value (example) (example) value (d)+4 (d)+3  (First time) (s1) K100 K100...
  • Page 852: Searching 32-Bit Data

    Searching 32-bit data DSERMM(P) FX5S FX5UJ FX5U FX5UC These instructions search for the same data, maximum value and minimum value in a data table. Ladder diagram Structured text ENO:=DSERMM(EN,s1,s2,n,d); ENO:=DSERMMP(EN,s1,s2,n,d); (s1) (s2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 853 • The following table shows example of search result table configuration and data. (n=10) Searched device Searched data Comparison data Data position Search result (s1) (s1) value (s2) value Maximum value Same (d) Minimum value (example) (example) (d)+9, (d)+8 (d)+7, (d)+6 ...
  • Page 854: Bit Check Of 16-Bit Data

    Bit check of 16-bit data SUM(P) FX5S FX5UJ FX5U FX5UC These instructions store the total bits of 1 in the binary 16-bit data of the device specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=SUM(EN,s,d); ENO:=SUMP(EN,s,d);...
  • Page 855 Program example In the program example shown below, when X0 is ON, the number of bits in the ON status in D0 is counted, and stored to D2. The number of "1" in D0 is stored to D2. D0 = K0 D2 = K0 Zero flag D0 = K21847...
  • Page 856: Bit Check Of 32-Bit Data

    Bit check of 32-bit data DSUM(P) FX5S FX5UJ FX5U FX5UC These instructions store the total bits of 1 in the binary 32-bit data of the device specified by (s) to the device specified by (d). Ladder diagram Structured text ENO:=DSUM(EN,s,d); ENO:=DSUMP(EN,s,d);...
  • Page 857: Bit Judgment Of 16-Bit Data

    Bit judgment of 16-bit data BON(P) FX5S FX5UJ FX5U FX5UC These instructions check whether (n) bit(s) of binary 16-bit data of the device specified by (s) are on or off, and output the result to the device specified by (d). Ladder diagram Structured text ENO:=BON(EN,s,n,d);...
  • Page 858 Program example In the program example shown below, when the bit 9 (n = 9) in D10 is "1" (ON), M0 is set to "1" (ON). M0 = ON n = 9 M0 = OFF n = 9 Operation error Error code Description (SD0/SD8067)
  • Page 859: Bit Judgment Of 32-Bit Data

    Bit judgment of 32-bit data DBON(P) FX5S FX5UJ FX5U FX5UC These instructions check whether (n) bit(s) of binary 32-bit data of the device specified by (s) are on or off, and output the result to the device specified by (d). Ladder diagram Structured text ENO:=DBON(EN,s,n,d);...
  • Page 860 Operation error Error code Description (SD0/SD8067) 3405H The value specified by (n) is outside the following range. 0 to 31 8 APPLICATION INSTRUCTION 8.23 Data Operation Instruction...
  • Page 861: Searching The Maximum Value Of 16-Bit Data

    Searching the maximum value of 16-bit data MAX(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions search the maximum value from the (n) point(s) of 16-bit binary data in the device starting from the one specified by (s), and store the maximum value in the device specified by (d). Ladder diagram Structured text ENO:=MAXP(EN,s,n,d);...
  • Page 862: Error Code

    Processing details • These instructions search the maximum value from the (n) point(s) of 16-bit binary data in the device starting from the one specified by (s), and store the maximum value in the device specified by (d). These instructions start searching from the device specified by (s), and store the location from (s) of the first maximum value in (d)+1 and the number of maximum values in (d)+2.
  • Page 863: Searching The Maximum Value Of 32-Bit Data

    Searching the maximum value of 32-bit data DMAX(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions search the maximum value from the (n) point(s) of 32-bit binary data in the device starting from the one specified by (s), and store the maximum value in the device specified by (d). Ladder diagram Structured text ENO:=DMAXP(EN,s,n,d);...
  • Page 864 Processing details • These instructions search the maximum value from the (n) point(s) of 32-bit binary data in the device starting from the one specified by (s), and store the maximum value in the device specified by (d) and (d)+1. These instructions start searching from the device specified by (s), and store the location from (s) of the first minimum value in (d)+2 and the number of maximum values in (d)+3.
  • Page 865: Searching The Minimum Value Of 16-Bit Data

    Searching the minimum value of 16-bit data MIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions search the minimum value from the (n) point(s) of 16-bit binary data in the device starting from the one specified by (s), and store the minimum value in the device specified by (d). Ladder diagram Structured text ENO:=MINP(EN,s,n,d);...
  • Page 866 Processing details • These instructions search the minimum value from the (n) point(s) of 16-bit binary data in the device starting from the one specified by (s), and store the minimum value in the device specified by (d). These instructions start searching from the device specified by (s), and store the location from (s) of the first minimum value in (d)+1 and the number of minimum values in (d)+2.
  • Page 867: Searching The Minimum Value Of 32-Bit Data

    Searching the minimum value of 32-bit data DMIN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions search the minimum value from the (n) point(s) of 32-bit binary data in the device starting from the one specified by (s), and store the minimum value in the device specified by (d). Ladder diagram Structured text ENO:=DMINP(EN,s,n,d);...
  • Page 868 Processing details • These instructions search the minimum value from the (n) point(s) of 32-bit binary data in the device starting from the one specified by (s), and store the minimum value in the device specified by (d) and (d)+1. These instructions start searching from the device specified by (s), and store the location from (s) of the first minimum value in (d)+2 and the number of minimum values in (d)+3.
  • Page 869 Sorting 16-bit data SORTTBL(_U) FX5S FX5UJ FX5U FX5UC These instructions sort data lines in the data table (sorting source) having ((n1)(n2)) points specified by (s) in the ascending order based on the group data in the column number (n3), and store the result in the data table (sorting result) having ((n1)(n2)) points specified by (d).
  • Page 870 Processing details • These instructions sort data lines in the data table (sorting source) having ((n1)(n2)) points specified by (s) in the ascending order based on the group data in the column number (n3), and store the result in the data table (sorting result) having (n1n2) points specified by (d).
  • Page 871 • Sorting result when the instructions are executed with (n3) = K3 (column No. 3) Number of groups (n2 = K4) Column No. 1 Column No. 2 Column No. 3 Column No. 4 Control number Height Weight Line No. 1 (d)+15 Number of data (n1) = 5 (d)+5...
  • Page 872: Sorting 16-Bit Data

    Sorting 16-bit data 2 SORTTBL2(_U) FX5S FX5UJ FX5U FX5UC These instructions sort data lines in the data table (sorting source) of 16-bit binary data having (n1n2) points specified by (s) in the ascending order or descending order based on the group data in the column number (n3), and store the result in the data table (sorting result) of 16-bit binary data having ((n1)(n2)) points specified by (d).
  • Page 873 Processing details • These instructions sort data lines in the data table (sorting source) of 16-bit binary data having (n1n2) points specified by (s) in the ascending order or descending order based on the group data in the column number (n3), and store the result in the data table (sorting result) of 16-bit binary data having ((n1)(n2)) points specified by (d).
  • Page 874 • Sorting result when the instructions are executed with (n3) = K3 (column No. 3) (in the case of descending order SM703=ON) Number of groups (n2 = K4) Column No. 1 Column No. 2 Column No. 3 Column No. 4 Control number Height Weight...
  • Page 875 Sorting 32-bit data 2 DSORTTBL2(_U) FX5S FX5UJ FX5U FX5UC These instructions sort data lines in the data table (sorting source) of 32-bit binary data having (n1n2) points specified by (s) in the ascending order or descending order based on the group data in the column number (n3), and store the result in the data table (sorting result) of 32-bit binary data having ((n1)(n2)) points specified by (d).
  • Page 876 Processing details • These instructions sort data lines in the data table (sorting source) of 32-bit binary data having (n1n2) points specified by (s) in the ascending order or descending order based on the group data in the column number (n3), and store the result in the data table (sorting result) of 32-bit binary data having ((n1)(n2)) points specified by (d).
  • Page 877 • Sorting result when the instructions are executed with (n3) = K3 (column No. 3) (in the case of descending order SM703=ON) Number of groups (n2 = K4) Column No. 1 Column No. 2 Column No. 3 Column No. 4 Control number Height Weight...
  • Page 878: Adding 16-Bit Data

    Adding 16-bit data WSUM(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the (n) point(s) of 16-bit binary data in the device starting from the one specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=WSUM(EN,s,n,d);...
  • Page 879: Program Example

    Program example In the program shown below, the sum of 16-bit data stored in D10 to D14 is stored in [D101, D100] when X10 is set to ON. K4500 WSUMP D100 K2500 WSUMP instruction [D101, D100] K-3276 K14948 K6780 K4444 Operation error Error code Description...
  • Page 880: Adding 32-Bit Data

    Adding 32-bit data DWSUM(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions add the (n) point(s) of 32-bit binary data in the device starting from the one specified by (s), and store the result in the device specified by (d). Ladder diagram Structured text ENO:=DWSUM(EN,s,n,d);...
  • Page 881 Precautions In the 32-bit operation, the acquired sum is 64-bit data. The FX5 CPU module cannot handle 64-bit data. When the sum is within the numeric range of 32-bit data (K-2147483648 to K2147483647), however, the FX5 CPU module can handle the low- order 32 bits of 32-bit data as the sum while ignoring the high-order 32 bits.
  • Page 882: Calculating The Mean Value Of 16-Bit Data

    Calculating the mean value of 16-bit data MEAN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions calculate the mean value of the (n) point(s) of 16-bit data units starting from the one specified by (s), and store the operation result in (d). Ladder diagram Structured text ENO:=MEAN(EN,s,n,d);...
  • Page 883 Precautions When a device number is exceeded, (n) is handled as a smaller value in the possible range. Program example In the program example shown below, the data of D0, D1 and D2 are summed, divided by "3", and then stored to D10. (D0) + (D1) + (D2) (D10) MEAN...
  • Page 884: Calculating The Mean Value Of 32-Bit Data

    Calculating the mean value of 32-bit data DMEAN(P)(_U) FX5S FX5UJ FX5U FX5UC These instructions calculate the mean value of the (n) point(s) of 32-bit data units starting from the one specified by (s), and store the operation result in (d). Ladder diagram Structured text ENO:=DMEAN(EN,s,n,d);...
  • Page 885 Precautions When a device number is exceeded, (n) is handled as a smaller value in the possible range. Operation error Error code Description (SD0/SD8067) 3405H The value stored in a device specified by (n) is 0. 8 APPLICATION INSTRUCTION 8.23 Data Operation Instruction...
  • Page 886: Calculating The Square Root Of 16-Bit Data

    Calculating the square root of 16-bit data SQRT(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the square root of binary 16-bit data specified by (s1), and store the operation result in (d). Ladder diagram Structured text ENO:=SQRTP(EN,s,d); FBD/LD *1 The SQRT instruction is not supported by the ST language and the FBD/LD language. Use SQRT of the standard function. Page 1287 SQRT(_E) Setting data Descriptions, ranges, and data types...
  • Page 887 Program example In the program example shown below, the square root of D10 is stored to D12. SQRT D10 → D12 When K100 is specified in D10 D10 = K100 D12 = K10  8 APPLICATION INSTRUCTION 8.23 Data Operation Instruction...
  • Page 888: Calculating The Square Root Of 32-Bit Data

    Calculating the square root of 32-bit data DSQRT(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the square root of binary 32-bit data specified by (s1), and store the operation result in (d). Ladder diagram Structured text ENO:=DSQRT(EN,s,d); ENO:=DSQRTP(EN,s,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description...
  • Page 889: Crc Calculation

    CRC calculation CRC(P) FX5S FX5UJ FX5U FX5UC These instructions calculate the CRC (cyclic redundancy check) value which is an error check method used in communication. In addition to CRC value, parity check and sum check are available. For obtaining the horizontal parity value and sum check value, the CCD(P) instruction is available.
  • Page 890 Processing details • These instructions generate CRC value for (n) 8-bit data (unit: byte) starting from a device specified in (s), and store to (d). The 16-bit conversion mode and 8-bit conversion mode are available for these instructions. For the operation in each mode, refer to the proceeding pages.
  • Page 891 Precautions • In these instructions, "X +1" is used in a polynomial for generating the CRC value (CRC-16). There are many other standard polynomials for generating the CRC value. Note that the CRC value completely differs if an adopted polynomial is different. Major polynomials for generating the CRC value are shown below. Name Polynomial CRC-12...
  • Page 892: Reading The Indirect Address

    8.24 Indirect Address Read Instruction Reading the indirect address ADRSET(P) FX5S FX5UJ FX5U FX5UC These instructions store the indirect address of the device specified by (s) to the device specified by (d). The addresses stored in the device specified by (d)+0 and (d)+1 are used by the program to execute the indirect address of the device.
  • Page 893 Processing details • These instructions store the indirect address of the device specified by (s) to the device specified by (d). The addresses stored in the device specified by (d)+0 and (d)+1 are used by the program to execute the indirect address of the device. (1) Stores the address of W100 to D100 ADRSET W100 D100...
  • Page 894: Reading Clock Data

    8.25 Clock Instruction Reading clock data TRD(P) FX5S FX5UJ FX5U FX5UC These instructions read the clock data from the built-in real time clock in the CPU module. Ladder diagram Structured text ENO:=TRD(EN,d); ENO:=TRDP(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 895 • The table below shows the related devices. The clock data stored in these special registers is updated during the END processing. Device Name Description Binary code SD210 Binary clock data (year) The year data in the clock data is stored as a four-digit binary code. SD211 Binary clock data (month) The month data in the clock data is stored as a binary code.
  • Page 896: Writing Clock Data

    Writing clock data TWR(P) FX5S FX5UJ FX5U FX5UC This instruction writes the clock data to the built-in CPU module real time clock. Ladder diagram Structured text ENO:=TWR(EN,s); ENO:=TWRP(EN,s); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Head device number where the clock write source data is stored ...
  • Page 897 • Day of the week (SD216 and SD8019) is automatically corrected. • The table below shows the related devices. Device Name Description SM8019 Real time clock error This special data register turns on when the clock data value in the special register is exceeding the setting range.
  • Page 898 Operation error Error code Description (SD0/SD8067) 2820H The device range specified by (s) exceeds the corresponding device range. 8 APPLICATION INSTRUCTION 8.25 Clock Instruction...
  • Page 899: Adding Clock Data

    Adding clock data TADD(P) FX5S FX5UJ FX5U FX5UC These instructions add the time data stored in the device number specified by (s2) and later to the clock data stored in the device number specified by (s1) and later, and store the result to the device number specified by (d) and later. Ladder diagram Structured text ENO:=TADD(EN,s1,s2,d);...
  • Page 900 Processing details • These instructions add the time data stored in the device numbers starting from (s2) to the clock data stored in the device numbers starting from (s1), and store the result to the device numbers starting from (d). (s1) hour (0 to 23)
  • Page 901 Operation error Error code Description (SD0/SD8067) 2820H The device range specified by (s1), (s2), and (d) exceeds the corresponding device range. 3405H Any of values specified by (s1) and (s2) is outside the following range. 0 to 23 Any of values specified by (s1)+1, (s2)+1, (s1)+2, and (s2)+2 is outside the following range. 0 to 59 8 APPLICATION INSTRUCTION 8.25 Clock Instruction...
  • Page 902: Subtracting Clock Data

    Subtracting clock data TSUB(P) FX5S FX5UJ FX5U FX5UC These instructions subtract the time data stored in the device numbers starting from (s2) from the clock data stored in the device numbers starting from (s1), and store the result to the device numbers starting from (d). Ladder diagram Structured text ENO:=TSUB(EN, s1, s2,d);...
  • Page 903 Processing details • These instructions subtract the time data stored in the device numbers starting from (s2) from the clock data stored in the device numbers starting from (s1), and store the result to the device numbers starting from (d). (s1) hour (0 to 23)
  • Page 904: Error Code

    Operation error Error code Description (SD0/SD8067) 2820H The device range specified by (s1), (s2), and (d) exceeds the corresponding device range. 3405H Any of values specified by (s1) and (s2) is outside the following range. 0 to 23 Any of values specified by (s1)+1, (s2)+1, (s1)+2, and (s2)+2 is outside the following range. 0 to 59 8 APPLICATION INSTRUCTION 8.25 Clock Instruction...
  • Page 905 Converting time data from hour/minute/second to seconds in 16 bits HTOS(P) FX5S FX5UJ FX5U FX5UC These instructions convert the time data stored in the device numbers starting from (s) to the time value in seconds, and store the converted data in the device numbers starting from (d) as 16-bit binary. Ladder diagram Structured text ENO:=HTOS(EN,s,d);...
  • Page 906 Operation error Error code Description (SD0/SD8067) 2820H Any of the device area ranges specified in (s) and (d) exceed the corresponding device range. 3403H The result is outside the following range. 0 to 32767 3405H A value specified by (s) is outside the following range. 0 to 9 Any of values specified by (s)+1 and (s)+2 is outside the following range.
  • Page 907 Converting time data from hour/minute/second to seconds in 32 bits DHTOS(P) FX5S FX5UJ FX5U FX5UC These instructions convert the time data stored in the device numbers starting from (s) to the time value in seconds, and store the converted data in the device numbers starting from (d) as 32-bit binary. Ladder diagram Structured text ENO:=DHTOS(EN,s,d);...
  • Page 908 Program example In the program shown below, the time data read from the built-in CPU module real time clock is converted into data in units of "second", and stored to D100 and D101 when X20 turns ON. DHTOS D100 • Clock data reading operation by TRD instruction 2019 Year Real time clock...
  • Page 909: Converting Time Data From Seconds To Hour/Minute/Second In 16 Bits

    Converting time data from seconds to hour/minute/second in 16 bits STOH(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 16-bit time value in seconds stored in the device numbers starting from (s) to the time value in the HHMMDD format, and store the converted data in the device numbers starting from (d). Ladder diagram Structured text ENO:=STOH(EN,s,d);...
  • Page 910 Operation error Error code Description (SD0/SD8067) 2820H The specified device area exceeds the corresponding device range. 3405H The value specified by (s) is outside the range. 8 APPLICATION INSTRUCTION 8.25 Clock Instruction...
  • Page 911: Converting Time Data From Seconds To Hour/Minute/Second In 32 Bits

    Converting time data from seconds to hour/minute/second in 32 bits DSTOH(P) FX5S FX5UJ FX5U FX5UC These instructions convert the 32-bit time value in seconds stored in the device numbers starting from (s) to the time value in the HHMMDD format, and store the converted data in the device numbers starting from (d). Ladder diagram Structured text ENO:=DSTOH(EN,s,d);...
  • Page 912 Program example In the program shown below, the time data in units of "second" stored in D0 and D1 is converted into data in units of "hour, minute, and second", and stored to D100, D101, and D102 when X20 turns ON. DSTOH D100 •...
  • Page 913: Comparing Date Data

    Comparing date data LDDT, ANDDT, ORDT FX5S FX5UJ FX5U FX5UC These instructions compare the date data in the devices specified by (s1) and (s2). Or, these instructions compare the date data in the device specified by (s1) with the current date. Set the comparison target by (s3).
  • Page 914 Processing details • These instructions compare the date data in the devices specified by (s1) and (s2), or compare the date data in the device specified by (s1) with the current date. Set the comparison target by (s3). • Comparing two specified date data These instructions compare the date data in the device specified by (s1) with the date data in the device specified by (s2) in accordance with the conditions set by (s3).
  • Page 915 • The following table lists the comparison operation results of each instruction. Instruction symbol Condition Result (s1)=(s2) Conductive state DT<> (s1)(s2) DT> (s1)>(s2) DT<= (s1)(s2) DT< (s1)<(s2) DT>= (s1)(s2) (s1)(s2) Non-conductive state DT<> (s1)=(s2) DT> (s1)(s2) DT<= (s1)>(s2) DT< (s1)(s2) DT>= (s1)<(s2) The date data A, B, and C are compared.
  • Page 916: Comparing Time Data

    Comparing time data LDTM, ANDTM, ORTM FX5S FX5UJ FX5U FX5UC These instructions compare the time data in the devices specified by (s1) and (s2). Or, these instructions compare the time data in the device specified by (s1) with the current time. Set the comparison target by (s3).
  • Page 917 Processing details • These instructions compare the time data in the devices specified by (s1) and (s2), or compare the time data in the device specified by (s1) with the current time. Set the comparison target by (s3). • Comparing two specified time data These instructions compare the time data in the device specified by (s1) with the time data in the device specified by (s2) in accordance with the conditions set by (s3).
  • Page 918 • The following table lists the comparison operation results of each instruction. Instruction symbol Condition Result (s1)=(s2) Conductive state TM<> (s1)(s2) TM> (s1)>(s2) TM<= (s1)(s2) TM< (s1)<(s2) TM>= (s1)(s2) (s1)(s2) Non-conductive state TM<> (s1)=(s2) TM> (s1)(s2) TM<= (s1)>(s2) TM< (s1)(s2) TM>= (s1)<(s2) The time data A, B, and C are compared.
  • Page 919: Comparing Clock Data

    Comparing clock data TCMP(P) FX5S FX5UJ FX5U FX5UC These instructions compare the time specified by (s1), (s2), and (s3) with the time data specified by (s4), and turn on/off the bit device specified by (d) depending on the size match. Ladder diagram Structured text ENO:=TCMP(EN,s1,s2,s3,s4,d);...
  • Page 920 Processing details • These instructions compare the time specified by (s1), (s2), and (s3) with the time data specified by (s4), and turn on/off the bit device specified by (d) depending on the size match. > (s1) hour (0 to 23) (s4) hour (0 to 23)
  • Page 921 Operation error Error code Description (SD0/SD8067) 2820H The device range specified exceeds the corresponding device range. 3405H The value specified by (s1) and (s4) is outside the following range. 0 to 23 The value specified by (s2), (s3), (s4)+1, and (s4)+2 is outside the following range. 0 to 59 8 APPLICATION INSTRUCTION 8.25 Clock Instruction...
  • Page 922: Comparing Clock Data Zones

    Comparing clock data zones TZCP(P) FX5S FX5UJ FX5U FX5UC This instruction compares two comparison time (comparison time zone) specified by (s1) and (s2) with the time data specified by (s3), and turns on or off the specified bit devices (d) according to the comparison results. Ladder diagram Structured text ENO:=TZCP(EN,s1,s2,s3,d);...
  • Page 923 Processing details • This instruction compares two comparison time (comparison time zone) specified by (s1) and (s2) with the time data specified by (s3), and turns on or off the specified bit devices (d) according to the comparison results. > hour hour (0 to 23)
  • Page 924 Program example In the program shown below, when X0 is set to ON, the range of the D20 to D22 and D30 to D32 clock data is compared with the D0 to D2 clock data, and the results are stored in M3 to M5. (s1) (s2) (s3)
  • Page 925: Generating Timing Pulses

    8.26 Timing Check Instruction Generating timing pulses DUTY FX5S FX5UJ FX5U FX5UC This instruction sets user timing clock output destinations (SM420 to SM424 and SM8330 to SM8334) specified by (d) to on for the number of scans specified by (n1) and to off for the number of scans specified by (n2). Ladder diagram Structured text ENO:=DUTY(EN,n1,n2,d);...
  • Page 926 Processing details • This instruction sets user timing clock output destinations (SM420 to SM424 and SM8330 to SM8334) specified by (d) to on for the number of scans specified by (n1) and to off for the number of scans specified by (n2). SM420 to SM424, SM8330 to SM8334 (n1)
  • Page 927 Precautions • The DUTY instruction can be used up to 5 times (points). It is not permitted, however, to use the same timing clock output destination device for two or more DUTY instructions. Program example In the program shown below, when X0 is set to ON, SM420 is set to ON for 1 scan, and is set to OFF for 3 scans. SM420 DUTY SM420...
  • Page 928: Hour Meter

    Hour meter HOURM FX5S FX5UJ FX5U FX5UC This instruction measures the on time of the input contact in units of hour. Ladder diagram Structured text ENO:=HOURM(EN,s,d1,d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 929 Precautions • Two devices are occupied by (d1). Make sure that these devices are not used by other machine controls. Program example In the program example shown below, when the accumulated X0 ON time exceeds 300 hours, Y5 turns ON. The current value less than one hour is stored in D201 in units of second.
  • Page 930 DHOURM FX5S FX5UJ FX5U FX5UC This instruction measures the on time of the input contact in units of hour. Ladder diagram Structured text ENO:=DHOURM(EN,s,d1,d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 931 Precautions • Three devices are occupied by (d1). Make sure that these devices are not used by other machine controls. Operation error Error code Description (SD0/SD8067) 2820H The device areas specified by (d1) exceed the corresponding device range. 3405H The value of (s) is negative. 8 APPLICATION INSTRUCTION 8.26 Timing Check Instruction...
  • Page 932: Module Access Instruction

    8.27 Module Access Instruction I/O refresh REF(P)/RFS(P) FX5S FX5UJ FX5U FX5UC These instructions refresh the (n) points of devices starting from the device specified by (s), and receive an external input or generate an output. The REF(P) instructions can also be used as RFS(P). Ladder diagram Structured text ENO:=REF(EN,s,n);...
  • Page 933 Processing details • This function refreshes only the corresponding devices in the middle of a scan and receives an external input or generates an output. • Since the input receptions and external outputs are performed at one time only after the END instruction is executed in the program, a pulse signal cannot be output externally in the middle of a scan.
  • Page 934: Reading 1-Word/2-Word Data From Another Module

    Reading 1-word/2-word data from another module FROM(P), DFROM(P) FX5S FX5UJ FX5U FX5UC • FROM(P) These instructions read (n) words of data from the buffer memory specified by (s) in intelligent function module specified by (U/H), and store the data to the device specified by (d) and later (d). •...
  • Page 935 Processing details FROM(P) • These instructions read (n) words of data from the buffer memory specified by (s) in intelligent function module specified by (U/H), and store the data to the device specified by (d) and later. Buffer memory CPU module (n) points (n) words DFROM(P)
  • Page 936: Error Code

    Operation error Error code Description (SD0/SD8067) 2441H Updating procedure with the unit was not properly completed during the execution of the instruction. 2801H The unit number specified by (U/H) does not exist. 2823H The buffer memory number specified by (s) exceeds the buffer memory area. The buffer memory number specified by (s) + the number of transfer points specified by (n) exceeds the buffer memory area.
  • Page 937 Common items among the FROM(P), DFROM(P), TO(P), and DTO(P) (details) • Use the module number to specify which Intelligent function module the instruction works for. The setting range of each CPU module is shown below. - FX5UJ CPU module: 1H to 8H (K1 to K8) - FX5U/FX5UC CPU module: 1H to 10H (K1 to K16) Module Module...
  • Page 938: Writing 1-Word/2-Word Data To Another Module

    Writing 1-word/2-word data to another module TO(P), DTO(P) FX5S FX5UJ FX5U FX5UC • TO(P) These instructions write the (n) points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). •...
  • Page 939 Processing details TO(P) • These instructions write the (n) points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). CPU module Buffer memory (s2) (s1) (n) points...
  • Page 940 DTO(P) • These instructions write the (n)  2 points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). Buffer memory CPU module (s2) (s1) (n)×2 points...
  • Page 941 Reading 1-word/2-word data from another module FROMD(P), DFROMD(P) FX5S FX5UJ FX5U FX5UC • FROMD(P) These instructions read (n) words of data from the buffer memory specified by (s) in intelligent function module specified by (U/H), and store the data to the device specified by (d) and later. •...
  • Page 942 Processing details FROMD(P) • These instructions read (n) words of data from the buffer memory specified by (s) in intelligent function module specified by (U/H), and store the data to the device specified by (d) and later. Buffer memory CPU module (n) points (n) words DFROMD(P)
  • Page 943 Common items among the FROMD(P), DFROMD(P), TOD(P), and DTOD(P) (details) • Use the module number to specify which intelligent function module the instruction works for. The setting range of each CPU module is shown below. - FX5UJ CPU module: 1H to 8H (K1 to K8) - FX5U/FX5UC CPU module: 1H to 10H (K1 to K16) Module Module...
  • Page 944: Writing 1-Word/2-Word Data To Another Module (32-Bit Specification)

    Writing 1-word/2-word data to another module (32-bit specification) TOD(P), DTOD(P) FX5S FX5UJ FX5U FX5UC • TOD(P) These instructions write the (n) points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). •...
  • Page 945 Processing details TOD(P) • These instructions write the (n) points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). CPU module Buffer memory (s2) (s1) (n) points...
  • Page 946 DTOD(P) • These instructions write the (n)  2 points of data in the device starting from the one specified by (s2) to the buffer memory address specified by (s1) in intelligent function module specified by (U/H). CPU module Buffer memory (s2) (s1) (n)×2 points...
  • Page 947: Logging Instructions

    8.28 Logging Instructions Setting trigger logging LOGTRG FX5S FX5UJ FX5U FX5UC This instruction generates a trigger condition for the specified logging setting number in trigger logging. Ladder diagram Structured text ENO:=LOGTRG(EN,s); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type...
  • Page 948: Resetting Trigger Logging

    Resetting trigger logging LOGTRGR FX5S FX5UJ FX5U FX5UC This instruction resets the trigger condition of the specified logging setting number. Ladder diagram Structured text ENO:=LOGTRGR(EN,s); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Logging setting number 1 to 4 16-bit signed binary...
  • Page 949 8.29 Real-time Monitor Function Instruction FX5S FX5UJ FX5U FX5UC The real-time monitor function monitors the data when the instruction is executed. Ladder diagram Structured text ENO:=RTM(EN); FBD/LD Processing details Depending on the monitor condition of the real-time monitor function, the data collection timing is when the instruction is executed.
  • Page 950 MEMO 8 APPLICATION INSTRUCTION 8.29 Real-time Monitor Function Instruction...
  • Page 951: Step Ladder Instructions

    STEP LADDER INSTRUCTIONS Starts/Ends Step Ladder STL, RETSTL FX5S FX5UJ FX5U FX5UC STL: This instruction starts step ladder. RETSTL: This instruction ends step ladder. Ladder diagram Structured text STL(d); RETSTL(); RETSTL (1): Step ladder program FBD/LD RETSTL *1 For supported version, refer to Page 1454 Added and Changed Functions. Setting data Descriptions, ranges, and data types Operand...
  • Page 952 Processing details • In programs using step ladder instructions, a step relay S is assigned to each process based on machine operations, and sequences of input condition and output control are programmed as circuits connected to contacts (STL contacts) of state relays.
  • Page 953 The actual step ladder program is as follows. SM402 This range divided by the STL instruction is called State. Process of S0 start Moving Process of S20 forward Moving Process of S21 backward RETSTL • A step ladder program is expressed as a relay ladder, but it can be created according to the machine control flow using state relays.
  • Page 954: Operation Of Program

    Operation of program The step ladder program operates as follows. SM402 SM402 SM400 SM400 Process of S31 SM400 SM400 When X1 turns ON, S32 Y31 programmed in the turns ON and S31 is SET instruction remains automatically reset. ON even if S31 is reset. SM400 SM400 Process of S32...
  • Page 955: Pid Control Instruction

    PID CONTROL INSTRUCTION 10.1 PID Control Loop FX5S FX5UJ FX5U FX5UC This instruction executes PID control which changes the output value according to the input variation. Ladder diagram Structured text ENO:=PID(EN,s1,s2,s3,d); (s1) (s2) (s3) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range...
  • Page 956 Precautions • When auto tuning is not used, twenty-five devices are occupied from the head device specified in (s3). • When auto tuning (limit cycle method) is used, twenty-nine devices are occupied from the head device specified in (s3). • When auto tuning (step response method) is used, the number of devices occupied from the devices specified in (s3) differs depending on the ON/OFF status of b8 of (s3)+1.
  • Page 957 Error code Description (SD0/SD8067) 351BH Limit cycle method Auto tuning result exceeds proportional gain. (KP = outside range from 1 to 32767) 351CH Limit cycle method Auto tuning result exceeds integral time. (TI = outside range from 0 to 32767) 351DH Limit cycle method Auto tuning result exceeds derivative time.
  • Page 958: Sfc Program Instructions

    SFC PROGRAM INSTRUCTIONS This chapter describes the instructions used in SFC programs. For details on SFC programs, refer to the following. MELSEC iQ-F FX5 Programming Manual (Program Design) 11.1 SFC Control Instructions Checking the status of a step LD, LDI, AND, ANI, OR, ORI [S/BL\S] FX5S FX5UJ FX5U...
  • Page 959 Applicable devices Operand Word Double word Indirect Constant Others specification (BL\ X, Y, M, L, SM, T, ST, C, D, W, U\G K, H S) F, B, SB, S SD, SW, R *1*2        ...
  • Page 960: Checking The Status Of A Block

    Checking the status of a block LD, LDI, AND, ANI, OR, ORI [BL] FX5S FX5UJ FX5U FX5UC • LD: Normally open contact, LDI: Normally closed contact These instructions output the status (active or inactive) of the specified block as the operation result. •...
  • Page 961 Processing details • These instructions check whether the specified block is active or not. • The status (on or off) of each contact will be as follows depending on the status (active or inactive) of the specified block. Status of the specified block Contact of the normally open contact Contact of the normally closed contact instruction...
  • Page 962: Batch-Reading The Status Of Steps

    Batch-reading the status of steps MOV(P) [KnS/BL\KnS] FX5S FX5UJ FX5U FX5UC These instructions batch-read (in units of 16-bit binary data) the status (active or inactive) of steps in the specified block, and store the read data in the specified device. (Kn: K1 to K4) Ladder diagram Structured text ENO:=MOV(EN,s,d);...
  • Page 963 Processing details • These instructions batch-read (in units of 16-bit binary data) the status (active or inactive) of steps in the specified block. K1 to K4 can be specified to the nibble specification of the step relay (S). • When a block is not specified, the status (active or inactive) of the following block is read. - Sequence program: Block 0 - SFC program (within the action): Block where the instruction is executed (current block) •...
  • Page 964 • If the read target range exceeds the number of steps in the specified block, 0 is stored in the bits exceeding the existing step No. When the last step No. in the specified block is S26 and the status of steps (S16 to S31) are read to D1. (The status of each step is stored in other bits.) BL0\K4S16 ∙∙∙...
  • Page 965 DMOV(P) [KnS/BL\KnS] FX5S FX5UJ FX5U FX5UC These instructions batch-read (in units of 32-bit binary data) the status (active or inactive) of steps in the specified block, and store the read data in the specified device. (Kn: K1 to K8) Ladder diagram Structured text ENO:=DMOV(EN,s,d);...
  • Page 966 Processing details • These instructions batch-read (in units of 32-bit binary data) the status (active or inactive) of steps in the specified block. K1 to K8 can be specified to the nibble specification of the step relay (S). • When a block is not specified, the status (active or inactive) of the following block is read. - Sequence program: Block 0 - SFC program (within the action): Block where the instruction is executed (current block) •...
  • Page 967 • If no block is specified, when the read target range exceeds the maximum step No. in the block, undefined values will be stored. When the last step No. in the specified block is S26 and the status of steps (S0 to S31) are read to D0 and D1. (The status of each step is stored in other bits.) DMOV K8S0...
  • Page 968 BMOV(P) [KnS/BL\KnS] FX5S FX5UJ FX5U FX5UC These instructions batch-read (in units of the specified number of words starting from the specified step) the status (active or inactive) of steps in the specified block. (Kn: K1 to K4) Ladder diagram Structured text ENO:=BMOV(EN,s,n,d);...
  • Page 969 Processing details • These instructions batch-read (in units of the specified number of words starting from the specified step) the status (active or inactive) of steps in the specified block. K1 to K4 can be specified to the nibble specification of the step relay (S). •...
  • Page 970 • When there is a missing step No., 0 is stored in the corresponding bit. When the step No.5 and No.8 are missing in the specified block (The status of each step is stored in other bits.) ∙∙∙ ∙∙∙ ∙∙∙ S15 S14 S13 S12 S11 S10 S9 •...
  • Page 971 Operation error Error code Description (SD0/SD8067) 2820H When a block No. is specified, the specified block No. is out of the range of 0 to 31. When a block No. is specified, the specified step No. is out of the range of 0 to 511. When the step relay No.
  • Page 972: Starting A Block

    Starting a block SET [BL] FX5S FX5UJ FX5U FX5UC This instruction activates the specified block, and executes a step sequence starting from an initial step. Ladder diagram Structured text ENO:=SET(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)
  • Page 973: Ending A Block

    Ending a block RST [BL] FX5S FX5UJ FX5U FX5UC This instruction deactivates the specified block. Ladder diagram Structured text ENO:=RST(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label)  Block No. to be deactivated ANY_ELEMENTARY (Target bit device number to be reset (off)) ...
  • Page 974: Pausing A Block

    Pausing a block PAUSE [BL] FX5S FX5UJ FX5U FX5UC This instruction temporarily stops the step sequence in the specified block. Ladder diagram Structured text ENO:=PAUSE(EN,d); FBD/LD Execution condition Instruction Execution condition PAUSE Setting data Descriptions, ranges, and data types Operand Description Range Data type...
  • Page 975 Operation error Error code Description (SD0) 31A1H The specified block does not exist. The instruction is executed when no SFC program (scan execution type) exists or SM321 (start/stop SFC program) is off. 31A2H The specified block No. is out of the range. 3582H The SFC control instruction is used in the interrupt routine program.
  • Page 976: Restarting A Block

    Restarting a block RSTART [BL] FX5S FX5UJ FX5U FX5UC This instruction releases the temporary stop, and restarts the sequence from the step where the sequence was stopped in the specified block. Ladder diagram Structured text ENO:=RSTART(EN, d); FBD/LD Execution condition Instruction Execution condition RSTART...
  • Page 977 Operation error Error code Description (SD0) 31A1H The specified block does not exist. The instruction is executed when no SFC program (scan execution type) exists or SM321 (Start/stop SFC program) is off. 31A2H The specified block No. is out of the range. 3582H The SFC control instruction is used in the interrupt routine program.
  • Page 978: Activating A Step

    Activating a step SET [S/BL\S] FX5S FX5UJ FX5U FX5UC This instruction activates the specified step. Ladder diagram Structured text ENO:=SET(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Step No. to be activated ...
  • Page 979 Processing details • This instruction activates the specified step in the specified block. The operation of the specified block will be as follows depending on the status (active or inactive) of the specified block. Status of the specified block Operation Inactive The specified block is activated at execution of the instruction, and starts the processing from the specified step.
  • Page 980: Deactivating A Step

    Deactivating a step RST [S/BL\S] FX5S FX5UJ FX5U FX5UC This instruction deactivates the specified step. Ladder diagram Structured text ENO:=RST(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Step No. to be deactivated ...
  • Page 981 Precautions • If the step termination instruction is executed for a step in a parallel branch, the parallel convergence condition will not be met. • The own step cannot be specified as the step No. within the action of the SFC program. If the own step No. is specified as the specified step No., an error will occur.
  • Page 982 Activating/deactivating a step OUT [S/BL\S] FX5S FX5UJ FX5U FX5UC This instruction activates or deactivates the specified step. Ladder diagram Structured text ENO:=OUT(EN,d); FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) Specified step No. to be activated or deactivated ...
  • Page 983 Operation error Error code Description (SD0/SD8067) 31A1H The specified block does not exist. The control target block does not exist. (SET/RST/OUT S) 31A2H When a block No. is specified, the specified block No. is out of the range of 0 to 31. 31B1H The instruction is executed when no SFC program (Start/stop SFC program) exists or SM321 is off.
  • Page 984 Batch-deactivating a step ZRST(P) [S/BL\S] FX5S FX5UJ FX5U FX5UC Batch-deactivates the steps in the specified range. Ladder diagram Structured text ENO:=ZRST(EN,d1,d2); ENO:=ZRSTP(EN,d1,d2); (d1) (d2) FBD/LD Setting data Descriptions, ranges, and data types Operand Description Range Data type Data type (label) ...
  • Page 985 • When a block is specified, specification is possible over blocks. Make sure to specify the block Nos. so as to be (d1) < (d2). When (d1)  (d2), only one step No. that is specified to (d1) will be deactivated. When a block that does not exist is specified to (d1) or (d2), the steps that exist in the specified range will be deactivated.
  • Page 986: Creating A Dummy Transition Condition

    11.2 SFC Dedicated Instruction Creating a dummy transition condition TRAN FX5S FX5UJ FX5U FX5UC This instruction is a dummy output which satisfies a transition condition. Ladder diagram Structured text TRAN(s); FBD/LD For details on transitions, refer to the following. MELSEC iQ-F FX5 Programming Manual (Program Design) 11 SFC PROGRAM INSTRUCTIONS 11.2 SFC Dedicated Instruction...
  • Page 987: Part 4 Module Dedicated Instruction

    PART 4 MODULE DEDICATED INSTRUCTION This part consists of the following chapters. 12 NETWORK COMMON INSTRUCTION 13 Ethernet INSTRUCTION 14 CC-Link IE TSN INSTRUCTION 15 CC-Link IE Field Network INSTRUCTION 16 HIGH-SPEED COUNTER INSTRUCTION 17 EXTERNAL DEVICE COMMUNICATION INSTRUCTION 18 POSITIONING INSTRUCTION 19 DIVIDED DATA READ/WRITE FROM/TO BFM INSTRUCTION...
  • Page 988 NETWORK COMMON INSTRUCTION Target networks and target station types Each link dedicated instruction allows access to a station on a network other than the own station network. The following table lists the target stations of each instruction. Instruction symbol Target station (another station) Target network Target station type GP.READ...
  • Page 989 Specifications of character string data specified by link dedicated instructions Some operands specified in link dedicated instructions are specified in character strings. The following table summarizes the specifications of character string data specified. Instruction Applicable Specifications of character string data symbol operand Specification method...
  • Page 990: Link Dedicated Instructions

    12.1 Link Dedicated Instructions Reading data from another station programmable controller GP.READ FX5S FX5UJ FX5U FX5UC This instruction reads data from a device in another station programmable controller. (In units of words) CC-Link IE TSN is compatible only with FX5U/FX5UC CPU module. Ladder diagram Structured text ENO:=GP_READ(EN,Un,s1,s2,d1,d2);...
  • Page 991 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 992 Device Item Description Setting range Set by (s1)+4 (s1)+4 Target network number [CC-Link IE Field Network] User Specify the network No. of the target station. • Network No.: 1 • 1 to 239 (network No.) to 239 (s1)+5 [CC-Link IE TSN] •...
  • Page 993 Device Item Description Setting range Set by When "0" is specified in b15 in (s1)+0  (s1)+16 Error detection network System number The network number of the station where an error was detected is stored. (The number is not stored when an error was detected in the own station.) •...
  • Page 994: Operation

    • The execution of the GP.READ instruction and whether it has been completed normally or completed with an error can be checked with the completion device (d2) or completion status indication device (d2)+1. Device Operation Completion device (d2) The device turns on during the END processing for the scan in which the GP.READ instruction is completed, and turns off during the next END processing.
  • Page 995 Operation error Error code Description ((s1)+1) Refer to MELSEC iQ-F FX5 CC-Link IE TSN Master/Local Module User's Manual. C000H to CFFFH D000H to DFFFH Refer to MELSEC iQ-F FX5 CC-Link IE TSN Master/Local Module User's Manual. Refer to MELSEC iQ-F FX5 CC-Link IE Field Network Module User's Manual. 12 NETWORK COMMON INSTRUCTION 12.1 Link Dedicated Instructions...
  • Page 996 Reading data from another station programmable controller (with notification) GP.SREAD FX5S FX5UJ FX5U FX5UC This instruction reads data from a device in another station programmable controller. (In units of words) After the data reading is completed by the GP.SREAD instruction, the device of the other station is turned on. The other station can recognize that data has been read by the GP.SREAD instruction.
  • Page 997 Applicable devices Operand Word Double word Indirect Constant Others specification X, Y, M, L, SM, T, ST, C, D, W, U\G K, H F, B, SB, S SD, SW, R           ...
  • Page 998 Device Item Description Setting range Set by (s1)+4 (s1)+4 Target network number [CC-Link IE Field Network] User Specify the network No. of the target station. • Network No.: 1 • 1 to 239 (network No.) to 239 (s1)+5 [CC-Link IE TSN] •...
  • Page 999 Device Item Description Setting range Set by When "0" is specified in b15 in (s1)+0  (s1)+16 Error detection network System number The network number of the station where an error was detected is stored. (The number is not stored when an error was detected in the own station.) •...
  • Page 1000 • The execution of the GP.SREAD instruction and whether it has been completed normally or completed with an error can be checked with the completion device (d2) or completion status indication device (d2)+1. Device Operation Completion device (d2) The device turns on during the END processing for the scan in which the GP.SREAD instruction is completed, and turns off during the next END processing.
  • Page 1001 When completed with an error SREAD Sequence scan Start contact CPU module on Completion device the own station (d2) Completion status indication device (d2)+1 1 scan Completion status Error code (s1)+1 FX5-CCLGN-MS Channel n or FX5-CCLIEF Target station error • Read processing is performed only once on the rising edge when the read command turns on. Operation error Error code Description...

Table of Contents