Q-L_StructuredProgrammingManual-ApplicationFunctions_SH-080784

Q-L_StructuredProgrammingManual-ApplicationFunctions_SH-080784
SAFETY PRECAUTIONS
(Always read these instructions before using this product.)
Before using the MELSEC-Q series and MELSEC-L series programmable controllers, thoroughly read the
manuals attached to the products and the relevant manuals introduced in the attached manuals. Also pay careful
attention to safety and handle the products properly.
Please keep this manual in a place where it is accessible when required and always forward it to the end user.
A-1
CONDITIONS OF USE FOR THE PRODUCT
(1) Mitsubishi programmable controller ("the PRODUCT") shall be used in conditions;
i) where any problem, fault or failure occurring in the PRODUCT, if any, shall not lead to any major
or serious accident; and
ii) where the backup and fail-safe function are systematically or automatically provided outside of
the PRODUCT for the case of any problem, fault or failure occurring in the PRODUCT.
(2) The PRODUCT has been designed and manufactured for the purpose of being used in general
industries.
MITSUBISHI SHALL HAVE NO RESPONSIBILITY OR LIABILITY (INCLUDING, BUT NOT
LIMITED TO ANY AND ALL RESPONSIBILITY OR LIABILITY BASED ON CONTRACT,
WARRANTY, TORT, PRODUCT LIABILITY) FOR ANY INJURY OR DEATH TO PERSONS OR
LOSS OR DAMAGE TO PROPERTY CAUSED BY the PRODUCT THAT ARE OPERATED OR
USED IN APPLICATION NOT INTENDED OR EXCLUDED BY INSTRUCTIONS, PRECAUTIONS,
OR WARNING CONTAINED IN MITSUBISHI'S USER, INSTRUCTION AND/OR SAFETY
MANUALS, TECHNICAL BULLETINS AND GUIDELINES FOR the PRODUCT.
("Prohibited Application")
Prohibited Applications include, but not limited to, the use of the PRODUCT in;
• Nuclear Power Plants and any other power plants operated by Power companies, and/or any
other cases in which the public could be affected if any problem or fault occurs in the PRODUCT.
• Railway companies or Public service purposes, and/or any other cases in which establishment of
a special quality assurance system is required by the Purchaser or End User.
• Aircraft or Aerospace, Medical applications, Train equipment, transport equipment such as
Elevator and Escalator, Incineration and Fuel devices, Vehicles, Manned transportation,
Equipment for Recreation and Amusement, and Safety devices, handling of Nuclear or
Hazardous Materials or Chemicals, Mining and Drilling, and/or other applications where there is a
significant risk of injury to the public or property.
Notwithstanding the above, restrictions Mitsubishi may in its sole discretion, authorize use of the
PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT
is limited only for the specific applications agreed to by Mitsubishi and provided further that no
special quality assurance or fail-safe, redundant or other safety features which exceed the general
specifications of the PRODUCTs are required. For details, please contact the Mitsubishi
representative in your region.
A-2
REVISIONS
The manual number is written at the bottom left of the back cover.
Print date
Manual number
Revision
Jul., 2008
SH(NA)-080784ENG-A First edition
Jan., 2009
SH(NA)-080784ENG-B Model Addition
Q00UJ, Q00U, Q01U, Q10UDH, Q10UDEH, Q20UDH, Q20UDEH
Addition
Section 2.1.5, Section 5.5.2, Section 5.5.3
Correction
GENERIC TERMS AND ABBREVIATIONS IN THIS MANUAL, Section 3.7.1
Jul., 2009
SH(NA)-080784ENG-C Model Addition
Q00J, Q00, Q01
Addition
Section 2.2, Section 3.1
Correction
Section 1.2, Section 2.1,
Section 2.1.1 to Section 2.1.12 are changed to Section 2.2.1 to Section 2.2.12,
Section 3.1 is changed to Section 3.2, Chapter 4, Chapter 5
Deletion
Section 3.2 to Section 3.7, Appendix 1, Appendix 2
Jan., 2010
SH(NA)-080784ENG-D Model Addition
L02, L26-BT
Addition
CONDITIONS OF USE FOR THE PRODUCT
Correction
MANUALS, Section 1.1, Section 1.2, Section 3.1, Chapter 4
Apr., 2010
SH(NA)-080784ENG-E Model Addition
Q50UDEH, Q100UDEH
Correction
Section 1.1, Section 1.2
Sep., 2010
SH(NA)-080784ENG-F Addition
Section 5.1.39, Section 5.1.40, Section 5.1.41, Section 5.1.42, Section 5.1.43,
Section 5.1.44, Section 5.1.45
Correction
Section 2.2.1, Section 5.1.30, Section 5.1.31, Section 5.1.33, Section 5.6.1
Jan., 2011
SH(NA)-080784ENG-G Correction
Section 1.1, Section 2.2, Section 5.1.13, Section 5.1.19, Section 5.1.25,
Section 5.1.29,Section 5.1.30, Section 5.1.31, Section 5.1.32, Section 5.1.33,
Section 5.1.34, Section 5.1.36, Section 5.1.37, Section 5.2.1, Section 5.3.6,
Section 5.5.1, Section 5.5.2, Section 5.5.3, Section 5.5.4, Section 5.6.1,
Section 5.7.1, Section 5.8.1, Section 5.8.2, Section 5.8.4, Section 5.11.1,
Section 5.11.2, Section 5.11.3, Section 5.11.4, Section 5.12.1, Section 5.12.2,
Section 5.12.3, Section 5.12.4
A-3
Print date
Mar., 2011
Manual number
Revision
SH(NA)-080784ENG-H Addition
Section 2.3, Chapter 6
Correction
Section 1.1, Section 2.1, Section 2.2.3, Section 2.2.4, Section 2.2.6, Section 5.1.10,
Section 5.1.15, Section 5.1.32, Section 5.1.34, Section 5.1.38, Section 5.2.1,
Section 5.3.1, Section 5.3.2, Section 5.3.3, Section 5.3.4, Section 5.3.6,
Section 5.3.7, Section 5.4.1, Section 5.6.1, Section 5.8.1, Section 5.8.2,
Section 5.8.3, Section 5.8.4, Section 5.9.1, Section 5.9.2, Section 5.10.1,
Section 5.10.2, Section 5.11.1, Section 5.11.2, Section 5.11.3, Section 5.11.4,
Section 5.12.1, Section 5.12.2, Section 5.12.3, Section 5.12.4
Jul., 2011
SH(NA)-080784ENG-I
Model Addition
L02-P, L26-PBT
Correction
Section 1.2, Section 2.3, Chapter 4, Section 5.1.14, Section 5.1.16, Section 5.1.17,
Section 5.1.18, Section 5.1.19, Section 5.1.45, Section 5.2.1, Section 5.3.1,
Section 5.3.2, Section 5.3.3, Section 5.3.4, Section 5.3.6, Section 5.3.7,
Section 5.5.1, Section 5.5.2, Section 5.5.3, Section 5.5.4, Section 5.6.1,
Section 5.8.3, Section 5.8.4, Section 5.11.14
Japanese manual version SH-080737-K
This manual confers no industrial property rights or any rights of any other kind, nor does it confer any patent licenses.
Mitsubishi Electric Corporation cannot be held responsible for any problems involving industrial property rights which may
occur as a result of using the contents noted in this manual.
© 2008 MITSUBISHI ELECTRIC CORPORATION
A-4
INTRODUCTION
Thank you for purchasing the Mitsubishi MELSEC-Q series/MELSEC-L series programmable controller.
Before using the product, thoroughly read this manual to develop full familiarity with the programming
specifications to ensure correct use.
Please forward this manual to the end user.
CONTENTS
SAFETY PRECAUTIONS .................................................................................................................................A - 1
CONDITIONS OF USE FOR THE PRODUCT................................................................................................. A - 2
REVISIONS.......................................................................................................................................................A - 3
INTRODUCTION...............................................................................................................................................A - 5
CONTENTS ......................................................................................................................................................A - 5
MANUALS.........................................................................................................................................................A - 9
1. OVERVIEW
1 - 1 to 1 - 6
1.1 Purpose of This Manual
1-2
1.2 Generic Terms and Abbreviations in This Manual
1-5
2. FUNCTION TABLES
2 - 1 to 2 - 8
2.1 How to Read Function Tables
2-2
2.2 Function Tables
2-3
2.2.1
2.2.2
2.2.3
2.2.4
2.2.5
2.2.6
2.2.7
2.2.8
2.2.9
2.2.10
2.2.11
2.2.12
Type conversion functions ............................................................................................................. 2 - 3
Standard functions of one numeric variable .................................................................................. 2 - 5
Standard arithmetic functions ........................................................................................................ 2 - 5
Standard bitwise Boolean functions............................................................................................... 2 - 5
Standard selection functions.......................................................................................................... 2 - 5
Standard comparison functions ..................................................................................................... 2 - 6
Standard character string functions ............................................................................................... 2 - 6
Functions of time data types.......................................................................................................... 2 - 6
Standard bistable function blocks .................................................................................................. 2 - 6
Standard edge detection function blocks....................................................................................... 2 - 7
Standard counter function blocks .................................................................................................. 2 - 7
Standard timer function blocks ...................................................................................................... 2 - 7
2.3 Operator Tables
2-8
2.3.1 Arithmetic operations ..................................................................................................................... 2 - 8
2.3.2 Logical operations.......................................................................................................................... 2 - 8
2.3.3 Comparison operations.................................................................................................................. 2 - 8
3. CONFIGURATION OF FUNCTIONS
3 - 1 to 3 - 4
3.1 Configuration of Functions
3-2
3.2 Input Pins Variable Function
3-3
4. HOW TO READ FUNCTIONS
5. APPLICATION FUNCTIONS
5.1 Type Conversion Functions
4 - 1 to 4 - 4
5 - 1 to 5 - 242
5-2
A-5
5.1.1 Bit type → word (signed), double word (signed) type conversion.................................................. 5 - 2
5.1.2 Bit type → string type conversion .................................................................................................. 5 - 5
5.1.3 Bit type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type
conversion ..................................................................................................................................... 5 - 7
5.1.4 Bit type → time type conversion .................................................................................................. 5 - 10
5.1.5 Word (signed) type → double word (signed) type conversion ..................................................... 5 - 12
5.1.6 Double word (signed) type → word (signed) type conversion ..................................................... 5 - 14
5.1.7 Word (signed), double word (signed) type → bit type conversion ............................................... 5 - 16
5.1.8 Word (signed), double word (signed) type → single-precision real type conversion ................... 5 - 19
5.1.9 Word (signed), double word (signed) type → double-precision real type conversion.................. 5 - 22
5.1.10 Word (signed), double word (signed) type → string type conversion .......................................... 5 - 25
5.1.11 Word (signed), double word (signed) type → word (unsigned)/16-bit string type conversion...... 5 - 29
5.1.12 Word (signed), double word (signed) type → double word (unsigned)/32-bit string type
conversion ................................................................................................................................... 5 - 32
5.1.13 Word (signed), double word (signed) type → BCD type conversion............................................ 5 - 35
5.1.14 Word (signed), double word (signed) type → time type conversion ............................................ 5 - 38
5.1.15 Single-precision real type → word (signed), double word (signed) type conversion ................... 5 - 41
5.1.16 Double-precision real type → word (signed), double word (signed) type conversion .................. 5 - 44
5.1.17 Single-precision real type → double-precision real type conversion ........................................... 5 - 47
5.1.18 Double-precision real type → single-precision real type conversion ........................................... 5 - 50
5.1.19 Single-precision real type → string type conversion .................................................................... 5 - 53
5.1.20 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → bit type
conversion ................................................................................................................................... 5 - 57
5.1.21 Word (unsigned)/16-bit string type → word (signed), double word (signed) type conversion...... 5 - 60
5.1.22 Double word (unsigned)/32-bit string type → word (signed), double word (signed) type
conversion ................................................................................................................................... 5 - 63
5.1.23 Word (unsigned)/16-bit string type → double word (unsigned)/32-bit string type conversion...... 5 - 66
5.1.24 Double word (unsigned)/32-bit string type → word (unsigned)/16-bit string type conversion...... 5 - 69
5.1.25 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → string type
conversion ................................................................................................................................... 5 - 72
5.1.26 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → time type
conversion ................................................................................................................................... 5 - 75
5.1.27 String type → bit type conversion ................................................................................................ 5 - 78
5.1.28 String type → word (signed), double word (signed) type conversion........................................... 5 - 81
5.1.29 String type → single-precision real type conversion .................................................................... 5 - 84
5.1.30 String type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type
conversion ................................................................................................................................... 5 - 88
5.1.31 String type → time type conversion ............................................................................................. 5 - 92
5.1.32 String type → BCD type conversion ............................................................................................ 5 - 95
5.1.33 BCD type → word (signed), double word (signed) type conversion .......................................... 5 - 100
5.1.34 BCD type → string type conversion ........................................................................................... 5 - 104
5.1.35 Time type → bit type conversion ............................................................................................... 5 - 107
5.1.36 Time type → word (signed), double word (signed) type conversion .......................................... 5 - 109
5.1.37 Time type → string type conversion .......................................................................................... 5 - 112
5.1.38 Time type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type
conversion ................................................................................................................................. 5 - 114
5.1.39 Bit array → word (signed) type, word (unsigned)/16-bit string type, double word (signed) type,
double word (unsigned)/32-bit string type conversion ............................................................... 5 - 117
5.1.40 Word (signed) type, word (unsigned)/16-bit string type, double word (signed) type, double
word (unsigned)/32-bit string type → bit array conversion ........................................................ 5 - 119
5.1.41 Bit array copy............................................................................................................................. 5 - 121
5.1.42 Specified bit read of word (signed) type data ............................................................................ 5 - 123
A-6
5.1.43 Specified bit write of word (signed) type data ............................................................................ 5 - 125
5.1.44 Specified bit copy of word (signed) type data ............................................................................ 5 - 127
5.1.45 Nonessential type conversion.................................................................................................... 5 - 129
5.2 Standard Functions of One Numeric Variable
5 - 131
5.2.1 Absolute value ........................................................................................................................... 5 - 131
5.3 Standard Arithmetic Functions
5.3.1
5.3.2
5.3.3
5.3.4
5.3.5
5.3.6
5.3.7
5 - 135
Addition...................................................................................................................................... 5 - 135
Multiplication .............................................................................................................................. 5 - 138
Subtraction................................................................................................................................. 5 - 141
Division ...................................................................................................................................... 5 - 144
Modulus operation ..................................................................................................................... 5 - 147
Exponentiation ........................................................................................................................... 5 - 150
Move operation .......................................................................................................................... 5 - 153
5.4 Standard Bitwise Boolean Functions
5 - 157
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT .................................... 5 - 157
5.5 Standard Selection Functions
5.5.1
5.5.2
5.5.3
5.5.4
5 - 162
Selection .................................................................................................................................... 5 - 162
Maximum/Minimum selection .................................................................................................... 5 - 165
Upper/Lower limit control ........................................................................................................... 5 - 168
Multiplexer ................................................................................................................................. 5 - 171
5.6 Standard Comparison Functions
5 - 174
5.6.1 Comparison ............................................................................................................................... 5 - 174
5.7 Standard Character String Functions
5.7.1
5.7.2
5.7.3
5.7.4
5.7.5
Extract mid string ....................................................................................................................... 5 - 178
String concatenation .................................................................................................................. 5 - 181
String insertion........................................................................................................................... 5 - 184
String deletion............................................................................................................................ 5 - 187
String replacement..................................................................................................................... 5 - 190
5.8 Functions of Time Data Type
5.8.1
5.8.2
5.8.3
5.8.4
5 - 178
5 - 193
Addition...................................................................................................................................... 5 - 193
Subtraction................................................................................................................................. 5 - 196
Multiplication .............................................................................................................................. 5 - 199
Division ...................................................................................................................................... 5 - 202
5.9 Standard Bistable Function Blocks
5 - 204
5.9.1 Standard bistable function blocks (Set-dominant) ..................................................................... 5 - 204
5.9.2 Standard bistable function blocks (Reset-dominant) ................................................................. 5 - 207
5.10 Standard Edge Detection Function Blocks
5 - 210
5.10.1 Rising edge detector.................................................................................................................. 5 - 210
5.10.2 Falling edge detector ................................................................................................................. 5 - 213
5.11 Standard Counter Function Blocks
5.11.1
5.11.2
5.11.3
5.11.4
5 - 215
Up counter ................................................................................................................................. 5 - 215
Down counter............................................................................................................................. 5 - 218
Up/Down counter ....................................................................................................................... 5 - 221
Counter function blocks ............................................................................................................. 5 - 225
5.12 Standard Timer Function Blocks
5 - 227
5.12.1 Pulse timer................................................................................................................................. 5 - 227
5.12.2 On delay timer ........................................................................................................................... 5 - 230
5.12.3 Off delay timer ........................................................................................................................... 5 - 233
A-7
5.12.4 Timer function blocks................................................................................................................. 5 - 236
6. OPERATOR
6.1 Arithmetic Operations
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.1.6
6 - 1 to 6 - 18
6-2
Addition.......................................................................................................................................... 6 - 2
Multiplication .................................................................................................................................. 6 - 4
Subtraction..................................................................................................................................... 6 - 6
Division .......................................................................................................................................... 6 - 8
Modulus operation ....................................................................................................................... 6 - 10
Exponentiation ............................................................................................................................. 6 - 11
6.2 Logical Operations
6 - 13
6.2.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT ...................................... 6 - 13
6.3 Comparison Operations
6 - 16
6.3.1 Comparison ................................................................................................................................. 6 - 16
INDEX
A-8
Index - 1 to Index - 4
MANUALS
Related manuals
The manuals related to this product are shown below.
Refer to the following tables when ordering required manuals.
(1) Structured programming
Manual number
Manual name
(Model code)
MELSEC-Q/L/F Structured Programming Manual (Fundamentals)
Explains the programming method, types of programming languages, and other information required to create
structured programs.
SH-080782ENG
(13JW06)
(Sold separately)
MELSEC-Q/L Structured Programming Manual (Common Instructions)
Explains the specifications and functions of common instructions such as sequence instructions, basic instructions,
and application instructions that can be used in structured programs.
SH-080783ENG
(13JW07)
(Sold separately)
MELSEC-Q/L Structured Programming Manual (Special Instructions)
Explains the specifications and functions of special instructions such as module dedicated instruction, PID control
instruction, and built-in I/O function dedicated instruction, that can be used in structured programs.
SH-080785ENG
(13JW09)
(Sold separately)
(2) Operation of GX Works2
Manual number
Manual name
(Model code)
GX Works2 Version 1 Operating Manual (Common)
Explains the system configuration of GX Works2 and the functions common to Simple project and Structured project
such as parameter setting, operation method for the online function.
SH-080779ENG
(13JU63)
(Sold separately)
GX Works2 Version 1 Operating Manual (Structured Project)
Explains operation methods such as creating and monitoring programs in Structured project of GX Works2.
(Sold separately)
SH-080781ENG
(13JU65)
GX Works2 Beginner's Manual (Structured Project)
Explains fundamental operation methods such as creating, editing, and monitoring programs in Structured project for
users inexperienced with GX Works2.
SH-080788ENG
(13JZ23)
(Sold separately)
The Operating Manuals are included on the CD-ROM of the software package in a
PDF file format. Manuals in printed form are sold separately. Order a manual by
quoting the manual number (model code) listed in the table above.
A-9
MEMO
A-10
1
OVERVIEW
1
OVERVIEW
FUNCTION TABLES
2
4
HOW TO READ
FUNCTIONS
Generic Terms and Abbreviations in This Manual . . . . . . . . . . . . . . . . . . . . . . 1-5
5
APPLICATION
FUNCTIONS
1.2
6
OPERATOR
Purpose of This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
I
INDEX
1.1
CONFIGURATION
OF FUNCTIONS
3
1-1
1.1 Purpose of This Manual
This manual explains the application functions used for creating structured programs.
Manuals for reference are listed in the following table according to their purpose.
For information such as the contents and number of each manual, refer to the list of 'Related
manuals'.
(1) Operation of GX Works2
Purpose
Installation
Learning the
operating
environment and
installation method
GX Works2
Installation
Instructions
GX Works2
Beginner's Manual
Simple
Project
Structured
Project
Common
Simple
Project
Structured
Project
Details
Details
Intelligent
Function
Module
Details
Learning a USB
driver installation
method
Details
Learning all functions
of GX Works2
Outline
Learning the project
types and available
languages in
GX Works2
Learning the basic
operations and
operating procedures
when creating a
simple project for the
first time
Learning the basic
operations and
Operation of operating procedures
GX Works2 when creating a
structured project for
the first time
Learning the
operations of
available functions
regardless of project
type.
Learning the
functions and
operation methods
for programming
Learning data setting
methods for
intelligent function
module
1-2
GX Works2 Version 1
Operating Manual
1.1 Purpose of This Manual
Outline
Details
Details
Details
Outline
Details
For details of instructions used in each programming language, refer to the section 3 on the
next page
Purpose
Ladder
Simple
Project
SFC
GX Works2
Beginner's Manual
Simple
Project
Structured
Project
Simple
Project
Structured
Project
Details
Outline
*1
Details
Outline
ST
Ladder
SFC
Structured
Project/FBD
GX Works2 Version 1
Operating Manual
Details
Outline
Details
Outline
*1
Details
Outline
Structured ladder/
FBD
ST
Outline
Details
Outline
Details
*1: MELSAP3 and FX series SFC only
1.1 Purpose of This Manual
1-3
OVERVIEW
1
(2) Operations in each programming language
(3) Details of instructions in each programming language
Purpose
All
languages
MELSECQ/L/F
Structured
Programming
Manual
MELSEC-Q/L Structured
Programming Manual
MELSECQ/L
Programming
Manual
MELSEC-Q/L/QnA
Programming Manual
Fundamentals
Common
Special
Application
Instructions Instructions Functions
Common
Instructions
PID Control
Instructions
Learning details of
programmable
controller CPU
error codes,
special relays,
and special
registers
SFC
Details
Learning the
types and details
of instructions for
intelligent function
Using ladder modules
language
Learning the
types and details
of instructions for
network modules
Details
Details
Learning the
types and details
of instructions for
the PID control
function
Details
Learning details of
specifications,
functions, and
instructions of
SFC (MELSAP3)
Learning the
fundamentals for
creating a
structured
program
Details
Details
Learning the
types and details
of common
instructions
Using
structured
ladder/FBD/
ST
language
Learning the
types and details
of instructions for
intelligent function
modules
Learning the
types and details
of instructions for
network modules
Learning the
types and details
of instructions for
the PID control
function
Learning the
types and details
of application
functions
1-4
−
Details
Learning the
types and details
of common
instructions
Using SFC
language
Manual
for
module to
be used
1.1 Purpose of This Manual
Details
Outline
Details
Outline
Details
Details
Outline
Details
This manual uses the generic terms and abbreviations listed in the following table to discuss the
software packages and programmable controller CPUs. Corresponding module models are also
listed if needed.
Generic term and
Description
abbreviation
GX Works2
Generic product name for SWnDNC-GXW2-E (n: version)
Basic model QCPU
Generic term for Q00J, Q00, and Q01
High Performance model
QCPU
Generic term for Q02, Q02H, Q06H, Q12H, and Q25H
Generic term for Q00UJ, Q00U, Q01U, Q02U, Q03UD, Q03UDE, Q04UDH, Q04UDEH, Q06UDH,
Universal model QCPU
Q06UDEH, Q10UDH, Q10UDEH, Q13UDH, Q13UDEH, Q20UDH, Q20UDEH, Q26UDH, Q26UDEH,
Q50UDEH, and Q100UDEH
QCPU (Q mode)
Generic term for Basic model QCPU, High Performance model QCPU, and Universal model QCPU
LCPU
Generic term for L02, L02 -P, L26-BT, and L26-PBT
CPU module
Generic term for QCPU (Q mode) and LCPU
Personal computer
Generic term for personal computer on which Windows® operates
Generic term for sequence instructions, basic instructions, application instructions, data link
Common instruction
instructions, multiple CPU dedicated instructions, and multiple CPU high-speed transmission dedicated
instructions
Special instruction
Generic term for module dedicated instructions, PID control instructions, socket communication function
instructions, built-in I/O function instructions, and data logging function instructions
1.2 Generic Terms and Abbreviations in This Manual
1-5
OVERVIEW
1
1.2 Generic Terms and Abbreviations in This Manual
MEMO
1-6
2
OVERVIEW
1
FUNCTION TABLES
FUNCTION TABLES
2
4
HOW TO READ
FUNCTIONS
Function Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
5
APPLICATION
FUNCTIONS
2.2
6
OPERATOR
How to Read Function Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
I
INDEX
2.1
CONFIGURATION
OF FUNCTIONS
3
2-1
2.1 How to Read Function Tables
Function tables in Section 2.2 are shown in the following format.
Function name
Argument
s1
ADD_E
Processing details
Page
, s2 ,... s28 , d
(Number of pins
Outputs the sum ( s1 + s2 +···+ s28 ) of input values.
5-135
Outputs the product ( s1
) of input values.
5-138
variable)
s1
MUL_E
, s2 ,... s28 , d
(Number of pins
s2
···
s28
variable)
SUB_E
s1
,
s2
,
d
Outputs the difference ( s1 − s2 ) between input values.
5-141
DIV_E
s1
,
s2
,
d
Outputs the quotient ( s1 ÷ s2 ) of input values.
5-144
5-147
Description
..........Indicates the functions used in a program. 'Function name(_E)' is used as a function
with EN/ENO.
..........Indicates the arguments of the function.
s
: Source ......................................Stores data before operation.
d
: Destination................................Indicates the destination of data after operation.
(Number of pins variable) ...............Allows the number of s (source) to be changed in
the range from 2 to 28.
Changing the number of pins
Adding a pin
Deleting a pin
..........Indicates the processing details of each function.
..........Indicates the pages on which the functions are explained.
2-2
2.1 How to Read Function Tables
2.2 Function Tables
Type conversion functions
Function name
Argument
Processing details
BOOL_TO_INT(_E)
s
,
d
BOOL_TO_DINT(_E)
s
,
d
BOOL_TO_STR(_E)
s
,
d
Converts bit type data into string type data.
Converts bit type data into word (unsigned)/16-bit string or double
Converts bit type data into word (signed) or double word (signed) type
data.
Page
5-5
BOOL_TO_WORD(_E)
s
,
d
BOOL_TO_DWORD(_E)
s
,
d
BOOL_TO_TIME(_E)
s
,
d
Converts bit type data into time type data.
5-10
d
Converts word (signed) type data into double word (signed) type data.
5-12
5-14
INT_TO_DINT(_E)
s
,
word (unsigned)/32-bit string type date.
DINT_TO_INT(_E)
s
,
d
Converts double word (signed) type data into word (signed) type data.
INT_TO_BOOL(_E)
s
,
d
Converts word (signed) or double word (signed) type data into bit type
DINT_TO_BOOL(_E)
s
,
d
INT_TO_REAL(_E)
s
,
d
DINT_TO_REAL(_E)
s
,
d
INT_TO_LREAL(_E)
s
,
d
DINT_TO_LREAL(_E)
s
,
d
INT_TO_STR(_E)
s
,
d
DINT_TO_STR(_E)
s
,
d
INT_TO_WORD(_E)
s
,
d
DINT_TO_WORD(_E)
s
,
d
INT_TO_DWORD(_E)
s
,
d
DINT_TO_DWORD(_E)
s
,
d
INT_TO_BCD(_E)
s
,
d
DINT_TO_BCD(_E)
s
,
d
INT_TO_TIME(_E)
s
,
d
DINT_TO_TIME(_E)
s
,
d
REAL_TO_INT(_E)
s
,
d
REAL_TO_DINT(_E)
s
,
d
LREAL_TO_INT(_E)
s
,
d
LREAL_TO_DINT(_E)
s
,
d
REAL_TO_LREAL(_E)
s
,
d
LREAL_TO_REAL(_E)
s
data.
Converts word (signed) or double word (signed) type data into singleprecision real type data.
Converts word (signed) or double word (signed) type data into doubleprecision real type data.
Converts word (signed) or double word (signed) type data into string
type data.
Converts word (signed) or double word (signed) type data into word
(unsigned)/16-bit string type data.
Converts word (signed) or double word (signed) type data into double
word (unsigned)/32-bit string type data.
Converts word (signed) or double word (signed) type data into BCD
type data.
Converts word (signed) or double word (signed) type data into time
type data.
Converts single-precision real type data into word (signed) or double
word (signed) type data.
Converts double-precision real type data into word (signed) or double
word (signed) type data.
Converts single-precision real type data into double-precision real
type data.
,
d
Converts double-precision real type data into single-precision real
type data.
Converts single-precision real type data into string type (exponential
REAL_TO_STR(_E)
s
,
d
WORD_TO_BOOL(_E)
s
,
d
DWORD_TO_BOOL(_E)
s
,
d
WORD_TO_INT(_E)
s
,
d
WORD_TO_DINT(_E)
s
,
d
DWORD_TO_INT(_E)
s
,
d
DWORD_TO_DINT(_E)
s
,
d
WORD_TO_DWORD(_E)
s
,
d
DWORD_TO_WORD(_E)
s
form) data.
Converts word (unsigned)/16-bit string or double word (unsigned)/32bit string type data into bit type data.
Converts word (unsigned)/16-bit string type data into word (signed) or
double word (signed) type data.
Converts double word (unsigned)/32-bit string type data into word
(signed) or double word (signed) type data.
Converts word (unsigned)/16-bit string type data into double word
(unsigned)/32-bit string type data.
,
d
Converts double word (unsigned)/32-bit string type data into word
(unsigned)/16-bit string type data.
WORD_TO_STR(_E)
s
,
d
DWORD_TO_STR(_E)
s
,
d
WORD_TO_TIME(_E)
s
,
d
DWORD_TO_TIME(_E)
s
,
d
STR_TO_BOOL(_E)
s
,
d
Converts word (unsigned)/16-bit string or double word (unsigned)/32bit string type data into string type data.
Converts word (unsigned)/16-bit string or double word (unsigned)/32bit string type data into time type data.
Converts string type data into bit type data.
2.2 Function Tables
2.2.1 Type conversion functions
2
5-2
FUNCTION TABLES
2.2.1
5-7
5-16
5-19
5-22
5-25
5-29
5-32
5-35
5-38
5-41
5-44
5-47
5-50
5-53
5-57
5-60
5-63
5-66
5-69
5-72
5-75
5-78
2-3
Function name
Argument
Processing details
s
,
d
STR_TO_DINT(_E)
s
,
d
STR_TO_REAL(_E)
s
,
d
Converts string type data into single-precision real type data.
STR_TO_WORD(_E)
s
,
d
Converts string type data into word (unsigned)/16-bit string or double
STR_TO_DWORD(_E)
s
,
d
STR_TO_TIME(_E)
s
,
d
Converts string type data into time type data.
5-92
5-95
Converts string type data into word (signed) or double word (signed)
type data.
word (unsigned)/32-bit string type data.
5-81
5-84
5-88
STR_TO_BCD(_E)
s
,
d
Converts string type data into BCD type data.
BCD_TO_INT(_E)
s
,
d
Converts BCD type data into word (signed) or double word (signed)
BCD_TO_DINT(_E)
s
,
d
BCD_TO_STR(_E)
s
,
d
Converts BCD type data into string type data.
5-104
5-107
type data.
TIME_TO_BOOL(_E)
s
,
d
Converts time type data into bit type data.
TIME_TO_INT(_E)
s
,
d
Converts time type data into word (signed) or double word (signed)
TIME_TO_DINT(_E)
s
,
d
TIME_TO_STR(_E)
s
,
d
Converts time type data into string type data.
TIME_TO_WORD(_E)
s
,
d
Converts time type data into word (unsigned)/16-bit string or double
TIME_TO_DWORD(_E)
s
,
d
BITARR_TO_INT(_E)
s
, n,
d
type data.
word (unsigned)/32-bit string type data.
BITARR_TO_DINT(_E)
s
, n,
d
INT_TO_BITARR(_E)
s
, n,
d
Converts specified number of bits from bit array into word (signed)
type, word (unsigned)/16-bit string type, double word (signed) type, or
double word (unsigned)/32-bit string type data.
5-100
5-109
5-112
5-114
5-117
Outputs low-order n bits of word (signed) type, word (unsigned)/16-bit
string type, double word (signed) type, or double word (unsigned)/32-
2-4
Page
STR_TO_INT(_E)
5-119
DINT_TO_BITARR(_E)
s
, n,
d
bit string type data.
CPY_BITARR(_E)
s
, n,
d
Copies specified number of bits from bit array.
5-121
GET_BIT_OF_INT(_E)
s
, n,
d
Reads a value of specified bit of word (signed) type data.
5-123
SET_BIT_OF_INT(_E)
s
, n,
d
Writes a value to the specified bit of word (signed) type data.
5-125
CPY_BIT_OF_INT(_E)
s
, n1, n2,
GET_BOOL_ADDR
s
,
d
Converts the type of data into bit type.
GET_INT_ADDR
s
,
d
Converts the type of data into word (signed) type.
GET_WORD_ADDR
s
,
d
Converts the type of data to word (unsigned)/16-bit string type.
Copies a specified bit of word (signed) type data to the specified bit of
d
2.2 Function Tables
2.2.1 Type conversion functions
another word (signed) type data.
5-127
5-129
Standard functions of one numeric variable
Function name
ABS(_E)
2.2.3
Argument
s
,
Processing details
Outputs the absolute value of an input value.
d
Page
5-131
Standard arithmetic functions
Function name
Argument
s1
ADD_E
2
Processing details
FUNCTION TABLES
2.2.2
Page
, s2 ,... s28 , d
(Number of pins
Outputs the sum ( s1 + s2 +···+ s28 ) of input values.
5-135
Outputs the product ( s1
) of input values.
5-138
variable)
s1
MUL_E
, s2 ,... s28 , d
(Number of pins
···
s2
s28
variable)
SUB_E
s1
,
s2
,
d
Outputs the difference ( s1 − s2 ) between input values.
5-141
DIV_E
s1
,
s2
,
d
Outputs the quotient ( s1 ÷ s2 ) of input values.
5-144
MOD(_E)
s1
,
s2
,
d
s1
,
s2
,
d
Outputs the remainder after division of input values ( s1 ÷ s2 ).
Outputs the exponentiation of an input value.
5-147
EXPT(_E)
MOVE(_E)
s
,
d
Moves the input value to
5-153
2.2.4
d
.
5-150
Standard bitwise Boolean functions
Function name
Argument
s1
AND_E
Processing details
Page
, s2 ,... s28 , d
(Number of pins
Outputs the Boolean AND of input values.
variable)
s1
OR_E
, s2 ,... s28 , d
(Number of pins
Outputs the Boolean OR of input values.
variable)
s1
XOR_E
5-157
, s2 ,... s28 , d
(Number of pins
Outputs the Boolean exclusive OR of input values.
variable)
NOT(_E)
2.2.5
s
,
Outputs the Boolean NOT of input values.
d
Standard selection functions
Function name
SEL(_E)
MAXIMUM(_E)
Argument
s1
,
s1
, s2 ,... s28 , d
s2
,
s3
,
d
(Number of pins
Processing details
Outputs the value selected from the input values.
Outputs the maximum value of the input values.
variable)
s1
MINIMUM(_E)
Page
5-162
5-165
, s2 ,... s28 , d
(Number of pins
Outputs the minimum value of the input values.
variable)
LIMITATION(_E)
MUX(_E)
s1
,
n,
s1
s2
,
,
s3
s2
,
d
Outputs the input value controlled by the upper and lower limit control.
5-168
Outputs one of the multiple input values.
5-171
,... s28 , d
(Number of pins
variable)
2.2 Function Tables
2.2.2 Standard functions of one numeric variable
2-5
2.2.6
Standard comparison functions
Function name
Argument
s1
GT_E
Processing details
Page
, s2 ,... s28 , d
(Number of pins
variable)
s1
GE_E
, s2 ,... s28 , d
(Number of pins
variable)
s1
EQ_E
, s2 ,... s28 , d
(Number of pins
variable)
s1
LE_E
Outputs the comparison value of an input value.
5-174
, s2 ,... s28 , d
(Number of pins
variable)
s1
LT_E
, s2 ,... s28 , d
(Number of pins
variable)
NE_E
s1
2.2.7
,
s2
,
d
Standard character string functions
Function name
Argument
Processing details
Outputs the specified number of characters, extracted from the
MID(_E)
s
CONCAT(_E)
s1
,
s2
,
s1
,
s2
, n,
INSERT(_E)
(Number of pins
, n1, n2,
d
specified start position in the input character string.
Concatenates the character strings and outputs the operation result.
d
d
variable)
DELETE(_E)
s
REPLACE(_E)
s1
2.2.8
, n1, n2,
,
the operation result.
Deletes the specified range in a character string and outputs the
d
, n1, n2,
operation result.
Replaces the specified range in a character string with the specified
d
character string and outputs the operation result.
5-178
5-181
5-184
5-187
5-190
Functions of time data types
Function name
Argument
Processing details
Page
ADD_TIME(_E)
s1
,
s2
,
d
Outputs the sum ( s1 + s2 ) of the input values (time type).
5-193
SUB_TIME(_E)
s1
,
s2
,
d
Outputs the difference ( s1 - s2 ) of input values (time type).
5-196
MUL_TIME(_E)
s1
,
s2
,
d
Outputs the product ( s1
) of input values (time type).
5-199
DIV_TIME(_E)
s1
,
s2
,
d
Outputs the quotient ( s1 ÷ s2 ) of input values (time type).
5-202
2.2.9
s2
Standard bistable function blocks
Function name
2-6
s2
Inserts a character string between other character strings and outputs
Page
Argument
Processing details
Discriminates two input values and outputs 1 (TRUE) or 0 (FALSE).
SR(_E)
s1
,
s2
,
d
RS(_E)
s1
,
s2
,
d
(Set-dominant)
Discriminates two input values and outputs 1 (TRUE) or 0 (FALSE).
(Reset-dominant)
2.2 Function Tables
2.2.6 Standard comparison functions
Page
5-204
5-207
Standard edge detection function blocks
Function name
Argument
R_TRIG(_E)
s
,
F_TRIG(_E)
s
,
2.2.11
Page
d
5-210
d
Detects the falling edge of a signal and outputs pulse signals.
5-213
2
Standard counter function blocks
Function name
Argument
CTU(_E)
s1
,
s2
, n,
d1
,
CTD(_E)
s1
,
s2
, n,
d1
,
s1
,
s2
,
,
n,
d1
s1
,
CTUD(_E)
COUNTER_FB_M
2.2.12
Processing details
Detects the rising edge of a signal and outputs pulse signals.
,
s2
s3
d2
,
,
s3
Processing details
Page
d2
Counts the number of times that the signal turns ON.
5-215
d2
Counts down the number of times that the signal turns ON.
5-218
Counts/counts down the number of times that the signal turns ON.
5-221
s4
FUNCTION TABLES
2.2.10
d3
,
d1
,
d2
Counts the number of times that the signal turns ON from
s3
to
s2
.
5-225
Standard timer function blocks
Function name
Argument
TP(_E)
TP_HIGH(_E)
, n,
d1
,
d2
Holds the signal ON for the specified time.
5-227
s
, n,
d1
,
d2
Turns ON the signal after the specified time.
5-230
s
, n,
d1
,
d2
Turns OFF the signal after the specified time.
5-233
s1
,
,
TOF(_E)
TOF_HIGH(_E)
Page
s
TON(_E)
TON_HIGH(_E)
Processing details
TIMER_10_FB_M
TIMER_100_FB_M
Turns ON the signal after the specified time counted from input value
TIMER_HIGH_FB_M
TIMER_LOW_FB_M
s2
s3
,
d1
,
d2
s3
to
s2
.
5-236
TIMER_CONT_FB_M
TIMER_CONTHFB_M
The function and function block of the application functions execute the operation
with the combination of multiple sequence instructions. Therefore, if the interrupt
occurs in the application function operations, unintended operation results may
occur.
For using an interrupt program, use Disable interrupt/ Enable interrupt (DI/EI
instruction) as necessary.
2.2 Function Tables
2.2.10 Standard edge detection function blocks
2-7
2.3 Operator Tables
2.3.1
Arithmetic operations
Operator name
Structured ladder/FBD
Argument
ST
s1
ADD
+
Processing details
Page
, s2 ,... s28 , d
(Number of pins
Outputs the sum ( s1 + s2 +···+ s28 ) of input values.
6-2
Outputs the product ( s1
) of input values.
6-4
variable)
s1
, s2 ,... s28 , d
MUL
*
SUB
-
s1
,
s2
,
d
Outputs the difference ( s1 − s2 ) between input values.
6-6
DIV
/
s1
,
s2
,
d
Outputs the quotient ( s1 ÷ s2 ) of input values.
6-8
(Not supported)
MOD
s1
,
s2
,
d
**
s1
,
s2
,
d
Outputs the remainder after division of input values ( s1 ÷ s2 ).
Outputs the exponentiation of an input value.
6-10
(Not supported)
(Number of pins
s2
···
s28
variable)
2.3.2
6-11
Logical operations
Operator name
Structured ladder/FBD
s1
&
AND
Argument
ST
AND
OR
Outputs the Boolean AND of input values.
variable)
, s2 ,... s28 , d
(Number of pins
Outputs the Boolean OR of input values.
variable)
s1
XOR
XOR
Page
, s2 ,... s28 , d
(Number of pins
s1
OR
Processing details
6-13
, s2 ,... s28 , d
(Number of pins
Outputs the Boolean exclusive OR of input values.
variable)
(Not supported)
2.3.3
NOT
s
,
Comparison operations
Operator name
Structured ladder/FBD
Argument
ST
s1
GT
Outputs the Boolean NOT of input values.
d
>
Processing details
Page
, s2 ,... s28 , d
(Number of pins
variable)
s1
GE
>=
, s2 ,... s28 , d
(Number of pins
variable)
s1
EQ
=
, s2 ,... s28 , d
(Number of pins
variable)
s1
LE
<=
, s2 ,... s28 , d
(Number of pins
variable)
s1
LT
<
, s2 ,... s28 , d
(Number of pins
variable)
NE
2-8
<>
s1
,
s2
2.3 Operator Tables
2.3.1 Arithmetic operations
,
d
Outputs the comparison value of an input value.
6-16
3
OVERVIEW
1
CONFIGURATION OF FUNCTIONS
FUNCTION TABLES
2
4
HOW TO READ
FUNCTIONS
Input Pins Variable Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
5
APPLICATION
FUNCTIONS
3.2
6
OPERATOR
Configuration of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
I
INDEX
3.1
CONFIGURATION
OF FUNCTIONS
3
3-1
3.1 Configuration of Functions
Instructions available in the CPU module can be divided into a function name and an argument.
The application of a function name and an argument are as follows:
• Function name ....... Indicates the function.
• Argument .............. Indicates the I/O data used in the function.
Arguments are classified into source data, destination data, executing condition, and execution
result.
(1) Source
s
(a) A source is data used in an operation.
(b) The following source types are available depending on the device specified in a
function:
• Constant . . . . . . . . . . . . . . . . . . . . .Specifies a numeric value used in an operation.
Constants are set during programming so that
they cannot be changed while the program is
being executed.
Perform index setting when using them as
variable data.
• Bit device and word device . . . . . . .Specifies the device in which the data used in
the operation are stored.
Data must be stored to the specified device
before executing the operation.
By changing the data to be stored to the
specified device while a program is being
executed, the data used in the function can be
changed.
(c) Contacts cannot be input directly to sources that use bit devices.
(2) Destination
d
(a) Data after the operation are stored to a destination.
(b) Set a device in which data are to be stored to a destination.
(c) Coils cannot be directly connected to destinations that store bit devices.
(3) Executing condition (EN)
(a) An input variable EN inputs an executing condition of a function.
(4) Execution result (ENO)
(a) An output variable ENO outputs an execution result.
For details of the configuration of functions for labels and structures, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
3-2
3.1 Configuration of Functions
3.2 Input Pins Variable Function
Some functions allow the number of input pins to be changed.
To change the number of input pins, select the target function and change the number.
For the number of input pins change operation
(Structured Project)
GX Works2 Version 1 Operating Manual
Adding a pin
CONFIGURATION
OF FUNCTIONS
3
Deleting a pin
3.2 Input Pins Variable Function
3-3
MEMO
3-4
INDEX
OPERATOR
APPLICATION
FUNCTIONS
HOW TO READ
FUNCTIONS
CONFIGURATION
OF FUNCTIONS
FUNCTION TABLES
4
HOW TO READ FUNCTIONS
OVERVIEW
1
2
3
4
5
6
I
4-1
Chapter 5 provides detailed explanation on each function in the layout as shown below.
Indicates a section number and an outline of a function.
Indicates a function to be explained.
4-2
Indicates the CPU modules that can use the function.
Icon
Basic model
High Performance
Universal model
QCPU
model QCPU
QCPU
Description
LCPU
The normal icon indicates that the CPU
module can use the corresponding
Basic
High
performance
Universal
L CPU
functions.
The icon with Ver. symbol indicates that
the CPU module can use the
Ver.
Basic
Ver.
High
performance
Ver.
Ver.
Universal
L CPU
corresponding functions under certain
restrictions. (Function version and
software version)
The icon with
symbol indicates that
the CPU module cannot use the
Basic
High
performance
Universal
L CPU
corresponding functions.
Indicates the function names.
Indicates the function names that can be described.
Indicates the description format of the function in the structured ladder/FBD/ST language .
HOW TO READ
FUNCTIONS
Indicates the names of input and output arguments, and the data type of each argument.
For details of the data type, refer to MELSEC-Q/L/F Structured Programming Manual
(Fundamentals).
4
Indicates the processing performed by the function.
Indicates whether to exist the related error. When an error exists, conditions that cause an
error are described.
Indicates program examples in the structured ladder/FBD/ST language .
4-3
MEMO
4-4
5
OVERVIEW
1
APPLICATION FUNCTIONS
FUNCTION TABLES
2
5.3
Standard Arithmetic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-135
5.4
Standard Bitwise Boolean Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-157
5.5
Standard Selection Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-162
5.6
Standard Comparison Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-174
5.7
Standard Character String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-178
5.8
Functions of Time Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-193
5.9
Standard Bistable Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-204
5.10
Standard Edge Detection Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . 5-210
5.11
Standard Counter Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-215
5.12
Standard Timer Function Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-227
4
HOW TO READ
FUNCTIONS
Standard Functions of One Numeric Variable. . . . . . . . . . . . . . . . . . . . . . . . 5-131
5
APPLICATION
FUNCTIONS
5.2
6
OPERATOR
Type Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
I
INDEX
5.1
CONFIGURATION
OF FUNCTIONS
3
5-1
BOOL_TO_INT(_E), BOOL_TO_DINT(_E)
5.1 Type Conversion Functions
5.1.1
Bit type → word (signed), double word (signed) type
conversion
BOOL_TO_INT(_E), BOOL_TO_DINT(_E)
Basic
BOOL_TO_INT(_E)
BOOL_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BOOL_TO_INT_E
EN
BOOL_TO_INT_E
BOOL_TO_DINT
BOOL_TO_DINT_E
ENO:= BOOL_TO_INT_E (EN, s, d);
ENO
s
BOOL_TO_INT
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_BOOL): Input
Output argument,
:Bit
:Bit
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
:Word (signed), double word (signed)
Function
Operation processing
(1) BOOL_TO_INT, BOOL_TO_INT_E
Converts bit type data input to
s
into word (signed) type data, and outputs the operation
result from d .
When the input value is FALSE, 0 is output in word (signed) type data.
When the input value is TRUE, 1 is output in word (signed) type data.
5-2
s
d
FALSE
0
TRUE
1
Bit type
Word (signed) type
5.1 Type Conversion Functions
5.1.1 Bit type → word (signed), double word (signed) type conversion
BOOL_TO_INT(_E), BOOL_TO_DINT(_E)
(2) BOOL_TO_DINT, BOOL_TO_DINT_E
Converts bit type data input to
s
into double word (signed) type data, and outputs the
operation result from d .
When the input value is FALSE, 0 is output in double word (signed) type data.
When the input value is TRUE, 1 is output in double word (signed) type data.
s
d
FALSE
0
TRUE
1
Bit type
Double word (signed) type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5
APPLICATION
FUNCTIONS
Operation Error
No operation error occurs in the execution of the BOOL_TO_INT(_E) and
BOOL_TO_DINT(_E) functions.
(1) The program which converts bit type data input to
outputs the operation result from
d
s
BOOL_TO_INT(_E),
BOOL_TO_DINT(_E)
Program Example
into word (signed) type data, and
.
(a) Function without EN/ENO (BOOL_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1 := BOOL_TO_INT(g_bool1);
5.1 Type Conversion Functions
5.1.1 Bit type → word (signed), double word (signed) type conversion
5-3
BOOL_TO_INT(_E), BOOL_TO_DINT(_E)
(b) Function with EN/ENO (BOOL_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := BOOL_TO_INT_E(g_bool1, g_bool2, g_int1);
(2) The program which converts bit type data input to
and outputs the operation result from
d
s
into double word (signed) type data,
.
(a) Function without EN/ENO (BOOL_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1 := BOOL_TO_DINT(g_bool1);
5-4
5.1 Type Conversion Functions
5.1.1 Bit type → word (signed), double word (signed) type conversion
BOOL_TO_STR(_E)
5.1.2
Bit type → string type conversion
BOOL_TO_STR(_E)
Basic
BOOL_TO_STR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BOOL_TO_STR
BOOL_TO_STR_E
BOOL_TO_STR_E
EN
ENO:= BOOL_TO_STR_E (EN, s, d);
ENO
s
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_BOOL): Input
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
5
:String
APPLICATION
FUNCTIONS
Output argument,
:Bit
:Bit
Function
Converts bit type data input to
s
into string type data, and outputs the operation result from
.
When the input value is FALSE, 0 is output in string type data.
When the input value is TRUE, 1 is output in string type data.
d
s
d
FALSE
'0'
TRUE
'1'
Bit type
String type
5.1 Type Conversion Functions
5.1.2 Bit type → string type conversion
5-5
BOOL_TO_STR(_E)
Operation processing
BOOL_TO_STR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the BOOL_TO_STR(_E) function.
Program Example
The program which converts bit type data input to
operation result from
d
s
.
(a) Function without EN/ENO (BOOL_TO_STR)
[Structured ladder/FBD]
[ST]
g_string1 := BOOL_TO_STR (g_bool1);
5-6
5.1 Type Conversion Functions
5.1.2 Bit type → string type conversion
into string type data, and outputs the
BOOL_TO_WORD(_E), BOOL_TO_DWORD(_E)
5.1.3
Bit type → word (unsigned)/16-bit string, double word
(unsigned)/32-bit string type conversion
BOOL_TO_WORD(_E), BOOL_TO_DWORD(_E)
Basic
BOOL_TO_WORD(_E)
BOOL_TO_DWORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BOOL_TO_WORD_E
EN
BOOL_TO_WORD_E
BOOL_TO_DWORD
BOOL_TO_DWORD_E
ENO:= BOOL_TO_WORD_E (EN, s, d);
ENO
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_BOOL): Input
Output argument,
5
:Bit
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string, double word
APPLICATION
FUNCTIONS
s
BOOL_TO_WORD
(unsigned)/32-bit string
Operation processing
(1) BOOL_TO_WORD, BOOL_TO_WORD_E
Converts bit type data input to
s
into word (unsigned)/16-bit string type data, and outputs
the operation result from d .
When the input value is FALSE, 0H is output in word (unsigned)/16-bit string type data.
When the input value is TRUE, 1H is output in word (unsigned)/16-bit string type data.
s
d
FALSE
0H
TRUE
1H
Bit type
Word (unsigned)/16-bit string type
5.1 Type Conversion Functions
5.1.3 Bit type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
5-7
BOOL_TO_WORD(_E),
BOOL_TO_DWORD(_E)
Function
BOOL_TO_WORD(_E), BOOL_TO_DWORD(_E)
(2) BOOL_TO_DWORD, BOOL_TO_DWORD_E
Converts bit type data input to
s
into double word (unsigned)/32-bit string type data, and
outputs the operation result from d .
When the input value is FALSE, 0H is output in double word (unsigned)/32-bit string type
data.
When the input value is TRUE, 1H is output in double word (unsigned)/32-bit string type
data.
s
d
FALSE
0H
TRUE
1H
Bit type
Double word (unsigned)/32-bit string type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-8
5.1 Type Conversion Functions
5.1.3 Bit type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
BOOL_TO_WORD(_E), BOOL_TO_DWORD(_E)
Operation Error
No operation error occurs in the execution of the BOOL_TO_WORD(_E) and
BOOL_TO_DWORD(_E) functions.
Program Example
(1) The program which converts bit type data input to
data, and outputs the operation result from
d
s
into word (unsigned)/16-bit string type
.
(a) Function without EN/ENO (BOOL_TO_WORD)
[Structured ladder/FBD]
[ST]
g_word1 := BOOL_TO_WORD (g_bool1);
(b) Function with EN/ENO (BOOL_TO_WORD_E)
[Structured ladder/FBD]
5
APPLICATION
FUNCTIONS
[ST]
g_bool3 := BOOL_TO_WORD_E(g_bool1, g_bool2, g_word1);
(2) The program which converts bit type data input to
s
into double word (unsigned)/32-bit
string type data, and outputs the operation result from
d
.
BOOL_TO_WORD(_E),
BOOL_TO_DWORD(_E)
(a) Function without EN/ENO (BOOL_TO_DWORD)
[Structured ladder/FBD]
[ST]
g_dword1 := BOOL_TO_DWORD (g_bool1);
5.1 Type Conversion Functions
5.1.3 Bit type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
5-9
BOOL_TO_TIME(_E)
5.1.4
Bit type → time type conversion
BOOL_TO_TIME(_E)
Basic
BOOL_TO_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BOOL_TO_TIME
BOOL_TO_TIME_E
BOOL_TO_TIME_E
EN
ENO:= BOOL_TO_TIME_E (EN, s, d);
ENO
s
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_BOOL): Input
Output argument,
:Bit
:Bit
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop):Bit
d:
Output
:Time
Function
Operation processing
Converts bit type data input to
s
into time type data, and outputs the operation result from
.
When the input value is FALSE, 0 is output in time type data.
When the input value is TRUE, 1 is output in time type data.
d
5-10
s
d
FALSE
0
TRUE
T#1ms
Bit type
Time type
5.1 Type Conversion Functions
5.1.4 Bit type → time type conversion
BOOL_TO_TIME(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the BOOL_TO_TIME(_E) function.
Program Example
The program which converts bit type data input to
operation result from
d
s
into time type data, and outputs the
.
(a) Function without EN/ENO (BOOL_TO_TIME)
5
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
BOOL_TO_TIME(_E)
g_time1 := BOOL_TO_TIME (g_bool1);
(b) Function with EN/ENO (BOOL_TO_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := BOOL_TO_TIME_E (g_bool1, g_bool2, g_time1);
5.1 Type Conversion Functions
5.1.4 Bit type → time type conversion
5-11
INT_TO_DINT(_E)
5.1.5
Word (signed) type → double word (signed) type conversion
INT_TO_DINT(_E)
Basic
INT_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_DINT
INT_TO_DINT_E
INT_TO_DINT_E
EN
ENO:= INT_TO_DINT_E (EN, s, d);
ENO
s
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_INT): Input
Output argument,
:Bit
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Double word (signed)
Function
Operation processing
Converts word (signed) type data input to
outputs the operation result from
5-12
d
s
into double word (signed) type data, and
.
s
d
1234
1234
Word (signed) type
Double word (signed) type
5.1 Type Conversion Functions
5.1.5 Word (signed) type → double word (signed) type conversion
INT_TO_DINT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the INT_TO_DINT(_E) function.
Program Example
The program which converts word (signed) type data input to
data, and outputs the operation result from
d
s
into double word (signed) type
.
(a) Function without EN/ENO (INT_TO_DINT)
5
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
g_dint1 := INT_TO_DINT (g_int1);
INT_TO_DINT(_E)
(b) Function with EN/ENO (INT_TO_DINT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_DINT_E (g_bool1, g_int1, g_dint1);
5.1 Type Conversion Functions
5.1.5 Word (signed) type → double word (signed) type conversion
5-13
DINT_TO_INT(_E)
5.1.6
Double word (signed) type → word (signed) type conversion
DINT_TO_INT(_E)
Basic
DINT_TO_INT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
DINT_TO_INT
DINT_TO_INT_E
DINT_TO_INT_E
EN
ENO:= DINT_TO_INT_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_DINT): Input
:Double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed)
:Bit
Function
Operation processing
Converts double word (signed) type data input to
outputs the operation result from
5-14
d
s
into word (signed) type data, and
.
s
d
1234
1234
Double word (signed) type
Word (signed) type
5.1 Type Conversion Functions
5.1.6 Double word (signed) type → word (signed) type conversion
DINT_TO_INT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
When the DINT_TO_INT(_E) function is executed, low-order 16-bit data of
double word (signed) type data input to s are converted into word (signed)
type data. High-order 16-bit data are discarded.
Operation Error
No operation error occurs in the execution of the DINT_TO_INT(_E) function.
The program which converts double word (signed) type data input to
data, and outputs the operation result from
d
s
into word (signed) type
.
(a) Function without EN/ENO (DINT_TO_INT)
APPLICATION
FUNCTIONS
5
Program Example
DINT_TO_INT(_E)
[Structured ladder/FBD]
[ST]
g_int1 := DINT_TO_INT(g_dint1);
(b) Function with EN/ENO (DINT_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := DINT_TO_INT_E (g_bool1, g_dint1, g_int1);
5.1 Type Conversion Functions
5.1.6 Double word (signed) type → word (signed) type conversion
5-15
INT_TO_BOOL(_E), DINT_TO_BOOL(_E)
5.1.7
Word (signed), double word (signed) type → bit type
conversion
INT_TO_BOOL(_E), DINT_TO_BOOL(_E)
Basic
INT_TO_BOOL(_E)
DINT_TO_BOOL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_BOOL_E
EN
INT_TO_BOOL_E
DINT_TO_BOOL
DINT_TO_BOOL_E
ENO:= INT_TO_BOOL_E (EN, s, d);
ENO
s
INT_TO_BOOL
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
;Bit
s(_INT, _DINT):
Input
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Bit
Function
Operation processing
(1) INT_TO_BOOL, INT_TO_BOOL_E
Converts word (signed) type data input to
s
into bit type data, and outputs the operation
result from d .
When the input value is 0, FALSE is output in bit type data.
When the input value is other than 0, TRUE is output in bit type data.
5-16
s
d
0
FALSE
1567
TRUE
Word (signed) type
Bit type
5.1 Type Conversion Functions
5.1.7 Word (signed), double word (signed) type → bit type conversion
INT_TO_BOOL(_E), DINT_TO_BOOL(_E)
(2) DINT_TO_BOOL, DINT_TO_BOOL_E
Converts double word (signed) type data input to
into bit type data, and outputs the
s
operation result from d .
When the input value is 0, FALSE is output in bit type data.
When the input value is other than 0, TRUE is output in bit type data.
s
d
0
FALSE
12345678
TRUE
Double word (signed) type
Bit type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
5
APPLICATION
FUNCTIONS
No operation error occurs in the execution of the INT_TO_BOOL(_E) and
DINT_TO_BOOL(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
d
into bit type data, and
.
INT_TO_BOOL(_E),
DINT_TO_BOOL(_E)
outputs the operation result from
s
(a) Function without EN/ENO (INT_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1 := INT_TO_BOOL(g_int1);
5.1 Type Conversion Functions
5.1.7 Word (signed), double word (signed) type → bit type conversion
5-17
INT_TO_BOOL(_E), DINT_TO_BOOL(_E)
(b) Function with EN/ENO (INT_TO_BOOL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_BOOL_E (g_bool1, g_int1, g_bool2);
(2) The program which converts double word (signed) type data input to
and outputs the operation result from
d
.
(a) Function without EN/ENO (DINT_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1 := DINT_TO_BOOL(g_dint1);
5-18
5.1 Type Conversion Functions
5.1.7 Word (signed), double word (signed) type → bit type conversion
s
into bit type data,
INT_TO_REAL(_E), DINT_TO_REAL(_E)
5.1.8
Word (signed), double word (signed) type → single-precision
real type conversion
INT_TO_REAL(_E), DINT_TO_REAL(_E)
Basic
INT_TO_REAL(_E)
DINT_TO_REAL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_REAL_E
EN
INT_TO_REAL_E
DINT_TO_REAL
DINT_TO_REAL_E
ENO:= INT_TO_REAL_E (EN, s, d);
ENO
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_INT, _DINT):
Input
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Single-precision real
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
(1) INT_TO_REAL, INT_TO_REAL_E
Converts word (signed) type data input to
the operation result from
d
s
into single-precision real type data, and outputs
.
s
d
1234
1234.0
Word (signed) type
Single-precision real type
5.1 Type Conversion Functions
5.1.8 Word (signed), double word (signed) type → single-precision real type conversion
5-19
INT_TO_REAL(_E),
DINT_TO_REAL(_E)
s
INT_TO_REAL
INT_TO_REAL(_E), DINT_TO_REAL(_E)
(2) DINT_TO_REAL, DINT_TO_REAL_E
(a) Converts double word (signed) type data input to
and outputs the operation result from
d
s
into single-precision real type data,
.
s
d
16543521
16543521.0
Double word (signed) type
Single-precision real type
(b) The number of significant figures of single-precision real type data is approximately 7
since the data is processed in 32-bit single precision. Accordingly, the converted data
includes an error (rounding error) if an integer value is outside the range of -16777216
to 16777215.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-20
5.1 Type Conversion Functions
5.1.8 Word (signed), double word (signed) type → single-precision real type conversion
INT_TO_REAL(_E), DINT_TO_REAL(_E)
Operation Error
No operation error occurs in the execution of the INT_TO_REAL(_E) and
DINT_TO_REAL(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
type data, and outputs the operation result from
d
s
into single-precision real
.
(a) Function without EN/ENO (INT_TO_REAL)
[Structured ladder/FBD]
[ST]
g_real1 := INT_TO_REAL(g_int1);
(b) Function with EN/ENO (INT_TO_REAL_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
g_bool3 := INT_TO_REAL_E(g_bool1, g_int1, g_real1);
(2) The program which converts double word (signed) type data input to
d
into single-precision
.
INT_TO_REAL(_E),
DINT_TO_REAL(_E)
real type data, and outputs the operation result from
s
(a) Function without EN/ENO (DINT_TO_REAL)
[Structured ladder/FBD]
[ST]
g_real1 := DINT_TO_REAL(g_dint1);
5.1 Type Conversion Functions
5.1.8 Word (signed), double word (signed) type → single-precision real type conversion
5-21
INT_TO_LREAL(_E), DINT_TO_LREAL(_E)
5.1.9
Word (signed), double word (signed) type → double-precision
real type conversion
INT_TO_LREAL(_E), DINT_TO_LREAL(_E)
Basic
INT_TO_LREAL(_E)
DINT_TO_LREAL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_LREAL_E
EN
ENO:= INT_TO_LREAL_E
ENO
s
INT_TO_LREAL
INT_TO_LREAL_E
DINT_TO_LREAL
DINT_TO_LREAL_E
(EN, s, d);
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_INT, _DINT): Input
Output argument,
:Bit
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Double-precision real
Function
Operation processing
(1) INT_TO_LREAL, INT_TO_LREAL_E
Converts word (signed) type data input to
outputs the operation result from
5-22
d
s
into double-precision real type data, and
.
s
d
1234
1234.0
Word (signed) type
Double-precision real type
5.1 Type Conversion Functions
5.1.9 Word (signed), double word (signed) type → double-precision real type conversion
INT_TO_LREAL(_E), DINT_TO_LREAL(_E)
(2) DINT_TO_LREAL, DINT_TO_LREAL_E
Converts double word (signed) type data input to
and outputs the operation result from
d
s
into double-precision real type data,
.
s
d
16543521
16543521.0
Double word (signed) type
Double-precision real type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
INT_TO_LREAL(_E),
DINT_TO_LREAL(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.9 Word (signed), double word (signed) type → double-precision real type conversion
5-23
INT_TO_LREAL(_E), DINT_TO_LREAL(_E)
Operation Error
No operation error occurs in the execution of the INT_TO_LREAL(_E) and
DINT_TO_LREAL(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
type data, and outputs the operation result from
d
s
into double-precision real
.
(a) Function without EN/ENO (INT_TO_LREAL)
[Structured ladder/FBD]
[ST]
g_lreal1 := INT_TO_LREAL(g_int1);
(b) Function with EN/ENO (INT_TO_LREAL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_LREAL_E(g_bool1, g_int1, g_lreal2);
(2) The program which converts double word (signed) type data input to
precision real type data, and outputs the operation result from
d
s
into double-
.
(a) Function without EN/ENO (DINT_TO_LREAL)
[Structured ladder/FBD]
[ST]
g_lreal1 := DINT_TO_LREAL(g_dint1);
5-24
5.1 Type Conversion Functions
5.1.9 Word (signed), double word (signed) type → double-precision real type conversion
INT_TO_STR(_E), DINT_TO_STR(_E)
5.1.10
Word (signed), double word (signed) type → string type
conversion
INT_TO_STR(_E), DINT_TO_STR(_E)
Basic
INT_TO_STR(_E)
DINT_TO_STR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_STR_E
EN
INT_TO_STR_E
DINT_TO_STR
DINT_TO_STR_E
ENO:= INT_TO_STR_E (EN, s, d);
ENO
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_INT, _DINT): Input
Output argument,
5
:Bit
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String(6) / (11)
APPLICATION
FUNCTIONS
s
INT_TO_STR
Function
INT_TO_STR(_E),
DINT_TO_STR(_E)
Operation processing
(1) INT_TO_STR, INT_TO_STR_E
(a) Converts word (signed) type data input to
operation result from
d
s
into string type data, and outputs the
.
d
s
Word (signed) type
High-order byte
Low-order byte
ASCII code of ten-thousands place
Sign data
String 1st word
ASCII code of hundreds place ASCII code of thousands place
2nd word
ASCII code of units place ASCII code of tens place
3rd word
00H
4th word
When SM701 (signal for switching the number of output characters) is OFF,
"00H" is stored.
(b) '20H (space)' is stored in 'Sign data' when the input value is positive; '2DH (−)' is stored
when negative.
5.1 Type Conversion Functions
5.1.10 Word (signed), double word (signed) type → string type conversion
5-25
INT_TO_STR(_E), DINT_TO_STR(_E)
(c) If the number of significant figures is less, '20H (space)' is stored to high-order digits.
(Example) Inputting −123
d
Low-order byte
High-order byte
s
20H (space)
2DH (-)
31H (1)
20H (space)
2nd word
32H (2)
3rd word
-123
33H (3)
Word (signed) type
String 1st word
4th word
00H
(d) When SM701 (signal for switching the number of output characters) is OFF, "00H" is
stored to the end of the character string.
(2) DINT_TO_STR, DINT_TO_STR_E
(a) Converts double word (signed) type data input to
the operation result from
d
s
into string type data, and outputs
.
d
s
Double word (signed) type
High-order byte
Low-order byte
ASCII code of billions place
Sign data
String 1st word
ASCII code of ten-millions place ASCII code of hundred-millions place
2nd word
ASCII code of hundred-thousands place ASCII code of millions place
3rd word
ASCII code of thousands place ASCII code of ten-thousands place
4th word
ASCII code of tens place ASCII code of hundreds place
5th word
00H
ASCII code of units place
6th word
When SM701 (signal for switching the number of output characters) is OFF,
"00H" is stored.
(b) '20H (space)' is stored in 'Sign data' when the input value is positive; '2DH (-)' is stored
when negative
(c) If the number of significant figures is less, '20H (space)' is stored to high-order digits.
(Example) Inputting −123456
d
s
-123456
Double word (signed) type
High-order byte
Low-order byte
20H (space)
2DH ( - )
String 1st word
20H (space)
20H (space)
2nd word
31H (1)
20H (space)
3rd word
33H (3)
32H (2)
4th word
35H (5)
34H (4)
5th word
00H
36H (6)
6th word
(d) When SM701 (signal for switching the number of output characters) is OFF, "00H" is
stored to the end of the character string.
5-26
5.1 Type Conversion Functions
5.1.10 Word (signed), double word (signed) type → string type conversion
INT_TO_STR(_E), DINT_TO_STR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the INT_TO_STR(_E) and DINT_TO_STR(_E)
functions.
Program Example
(1) The program which converts word (signed) type data input to
outputs the operation result from
d
s
into string type data, and
.
(a) Function without EN/ENO (INT_TO_STR)
5
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
INT_TO_STR(_E),
DINT_TO_STR(_E)
g_string1 := INT_TO_STR(g_int1);
(b) Function with EN/ENO (INT_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_STR_E (g_bool1, g_int1, g_string1);
5.1 Type Conversion Functions
5.1.10 Word (signed), double word (signed) type → string type conversion
5-27
INT_TO_STR(_E), DINT_TO_STR(_E)
(2) The program which converts double word (signed) type data input to
and outputs the operation result from
d
.
(a) Function without EN/ENO (DINT_TO_STR)
[Structured ladder/FBD]
[ST]
g_string1 := DINT_TO_STR (g_dint1);
5-28
5.1 Type Conversion Functions
5.1.10 Word (signed), double word (signed) type → string type conversion
s
into string type data,
INT_TO_WORD(_E), DINT_TO_WORD(_E)
5.1.11
Word (signed), double word (signed) type → word
(unsigned)/16-bit string type conversion
INT_TO_WORD(_E), DINT_TO_WORD(_E)
Basic
INT_TO_WORD(_E)
DINT_TO_WORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_WORD_E
EN
INT_TO_WORD_E
DINT_TO_WORD
DINT_TO_WORD_E
ENO:= INT_TO_WORD_E (EN, s, d);
ENO
d
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_INT, _DINT): Input
Output argument,
5
:Bit
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
(1) INT_TO_WORD, INT_TO_WORD_E
Converts word (signed) type data input to
and outputs the operation result from
d
s
into word (unsigned)/16-bit string type data,
.
s
d
22136
5678H
Word (signed) type
Word (unsigned)/16-bit string type
5.1 Type Conversion Functions
5.1.11 Word (signed), double word (signed) type → word (unsigned)/16-bit string type conversion
5-29
INT_TO_WORD(_E),
DINT_TO_WORD(_E)
s
INT_TO_WORD
INT_TO_WORD(_E), DINT_TO_WORD(_E)
(2) DINT_TO_WORD, DINT_TO_WORD_E
Converts double word (signed) type data input to
data, and outputs the operation result from
d
s
into word (unsigned)/16-bit string type
.
s
d
12345678
614EH
Double word (signed) type
Word (unsigned)/16-bit string type
12345678
0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
614EH
0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
High-order 16-bit data is discarded.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
d
Operation output value
*1
FALSE
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
When the DINT_TO_WORD(_E) function is executed, low-order 16-bit data of
double word (signed) type data input to input variable s are converted into
word (unsigned)/16-bit string type data. High-order word (unsigned)/16-bit
string type data are discarded.
5-30
5.1 Type Conversion Functions
5.1.11 Word (signed), double word (signed) type → word (unsigned)/16-bit string type conversion
INT_TO_WORD(_E), DINT_TO_WORD(_E)
Operation Error
No operation error occurs in the execution of the INT_TO_WORD(_E) and
DINT_TO_WORD(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
string type data, and outputs the operation result from
d
s
into word (unsigned)/16-bit
.
(a) Function without EN/ENO (INT_TO_WORD)
[Structured ladder/FBD]
[ST]
g_word1 := INT_TO_WORD(g_int1);
(b) Function with EN/ENO (INT_TO_WORD_E)
[Structured ladder/FBD]
5
APPLICATION
FUNCTIONS
[ST]
g_bool3 := INT_TO_WORD_E (g_bool1, g_int1, g_word1);
s
(unsigned)/16-bit string type data, and outputs the operation result from
into word
d
.
INT_TO_WORD(_E),
DINT_TO_WORD(_E)
(2) The program which converts double word (signed) type data input to
(a) Function without EN/ENO (DINT_TO_WORD)
[Structured ladder/FBD]
[ST]
g_word1 := DINT_TO_WORD(g_dint1);
5.1 Type Conversion Functions
5.1.11 Word (signed), double word (signed) type → word (unsigned)/16-bit string type conversion
5-31
INT_TO_DWORD(_E), DINT_TO_DWORD(_E)
5.1.12
Word (signed), double word (signed) type → double word
(unsigned)/32-bit string type conversion
INT_TO_DWORD(_E), DINT_TO_DWORD(_E)
Basic
INT_TO_DWORD(_E)
DINT_TO_DWORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_DWORD_E
EN
INT_TO_DWORD_E
DINT_TO_DWORD
DINT_TO_DWORD_E
ENO:= INT_TO_DWORD_E (EN, s, d);
ENO
s
INT_TO_DWORD
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_INT, _DINT):
Input
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Double word (unsigned)/32-bit string
Function
Operation processing
(1) INT_TO_DWORD, INT_TO_DWORD_E
Converts word (signed) type data input to
into double word (unsigned)/32-bit string type
s
data, and outputs the operation result from
d
.
s
d
-325
0000FEBBH
Word (signed) type
Double word (unsigned)/32-bit string type
-325
1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 1
Data conversion
0000FEBBH
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 1
Always filled with 0s.
5-32
5.1 Type Conversion Functions
5.1.12 Word (signed), double word (signed) type → double word (unsigned)/32-bit string type conversion
INT_TO_DWORD(_E), DINT_TO_DWORD(_E)
(2) DINT_TO_DWORD, DINT_TO_DWORD_E
Converts double word (signed) type data input to
s
into double word (unsigned)/32-bit
string type data, and outputs the operation result from
d
.
s
d
12345678
BC614EH
Double word (signed) type
Double word (unsigned)/32-bit string type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
INT_TO_DWORD(_E),
DINT_TO_DWORD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.12 Word (signed), double word (signed) type → double word (unsigned)/32-bit string type conversion
5-33
INT_TO_DWORD(_E), DINT_TO_DWORD(_E)
Operation Error
No operation error occurs in the execution of the INT_TO_DWORD(_E) and
DINT_TO_DWORD(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
s
into double word
(unsigned)/32-bit string type data, and outputs the operation result from
d
.
(a) Function without EN/ENO (INT_TO_DWORD)
[Structured ladder/FBD]
[ST]
g_dword1:= INT_TO_DWORD(g_int1);
(b) Function with EN/ENO (INT_TO_DWORD_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_DWORD_E(g_bool1, g_int1, g_dword1);
(2) The program which converts double word (signed) type data input to
s
into double word
(unsigned)/32-bit string type data, and outputs the operation result from
(a) Function without EN/ENO (DINT_TO_DWORD)
[Structured ladder/FBD]
[ST]
g_dword1:= DINT_TO_DWORD(g_dint1);
5-34
5.1 Type Conversion Functions
5.1.12 Word (signed), double word (signed) type → double word (unsigned)/32-bit string type conversion
d
.
INT_TO_BCD(_E), DINT_TO_BCD(_E)
5.1.13
Word (signed), double word (signed) type → BCD type
conversion
INT_TO_BCD(_E), DINT_TO_BCD(_E)
High
performance
Basic
INT_TO_BCD(_E)
DINT_TO_BCD(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_BCD_E
EN
INT_TO_BCD_E
DINT_TO_BCD
DINT_TO_BCD_E
ENO:= INT_TO_BCD_E (EN, s, d);
ENO
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
Output argument,
5
:Bit
s(_INT, _DINT): Input
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string, double word
APPLICATION
FUNCTIONS
s
INT_TO_BCD
(unsigned)/32-bit string
INT_TO_BCD(_E),
DINT_TO_BCD(_E)
Function
Operation processing
(1) INT_TO_BCD, INT_TO_BCD_E
(a) Converts word (signed) type data input to
operation result from
d
0
s
d
9999
9999H
Word (signed) type
Word (unsigned)/16-bit string type
0
1
0
0
256
128
64
32
16
8
4
2
1
1
1
0
0
0
0
1
1
1
1
400
200
100
80
40
20
10
8
4
2
1
0
0
1
1
0
0
1
1
0
0
1
1
BCD conversion
Must always be 0.
8000 4000 2000 1000 800
9999H
1
into BCD type data, and outputs the
.
3276816384 8192 4096 2048 1024 512
9999
s
0
0
1
1
Thousands place Hundreds place
(b) The value to be input to
s
Tens place
Units place
is word (signed) type data within the range from 0 to 9999.
5.1 Type Conversion Functions
5.1.13 Word (signed), double word (signed) type → BCD type conversion
5-35
INT_TO_BCD(_E), DINT_TO_BCD(_E)
(2) DINT_TO_BCD, DINT_TO_BCD_E
(a) Converts double word (signed) type data input to
the operation result from
d
s
into BCD type data, and outputs
.
d
99999999H
Double word (signed) type
Double word (unsigned)/32-bit string type
231
230
229
228
227
226
225
224
223
222
221
220
219
218
217
216
215
214
213
212
211
210
29
28
27
26
25
24
23
22
21
20
s
99999999
0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1
100
101
102
104
105
106
BCD conversion
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
107
Must always be 0.
103
99999999
99999999H
1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Ten
millions
place
Millions Hundred Ten
Thousands Hundreds Tens
place
thousands thousands place
place
place
place
place
(b) The value to be input to
99999999.
s
Units
place
is double word (signed) type data within the range from 0 to
(c) Word (unsigned)/16-bit string type, double word (unsigned)/32-bit string type data can
be specified for
s
. Bit type cannot be specified.
The output from d cannot be used with connecting to the input of double word
(unsigned)/32-bit string type data. In this case, use the DBCD instruction.
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
FALSE (Operation stop)
d
*1
FALSE
Operation output value
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-36
5.1 Type Conversion Functions
5.1.13 Word (signed), double word (signed) type → BCD type conversion
INT_TO_BCD(_E), DINT_TO_BCD(_E)
Operation Error
An operation error occurs when the value input exceeds 9999 or 99999999 respectively in
the execution of the INT_TO_BCD(_E) or DINT_TO_BCD(_E) function. (Error code: 4100)
Program Example
(1) The program which converts word (signed) type data input to
outputs the operation result from
d
s
into BCD type data, and
.
(a) Function without EN/ENO (INT_TO_BCD)
[Structured ladder/FBD]
[ST]
g_word1:= INT_TO_BCD(g_int1);
(b) Function with EN/ENO (INT_TO_BCD_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
g_bool3 := INT_TO_BCD_E(g_bool1, g_int1, g_word1);
and outputs the operation result from
d
s
into BCD type data,
INT_TO_BCD(_E),
DINT_TO_BCD(_E)
(2) The program which converts double word (signed) type data input to
.
(a) Function without EN/ENO (DINT_TO_BCD)
[Structured ladder/FBD]
[ST]
g_dword1:= DINT_TO_BCD(g_dint1);
5.1 Type Conversion Functions
5.1.13 Word (signed), double word (signed) type → BCD type conversion
5-37
INT_TO_TIME(_E), DINT_TO_TIME(_E)
5.1.14
Word (signed), double word (signed) type → time type
conversion
INT_TO_TIME(_E), DINT_TO_TIME(_E)
Basic
INT_TO_TIME(_E)
DINT_TO_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
INT_TO_TIME_E
EN
INT_TO_TIME_E
DINT_TO_TIME
DINT_TO_TIME_E
ENO:= INT_TO_TIME_E (EN, s, d);
ENO
s
INT_TO_TIME
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_INT, _DINT): Input
Output argument,
:Bit
:Word (signed), double word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
Function
Operation processing
Converts word (signed) /double word (signed) type data input to
outputs the operation result from
5-38
d
.
s
d
1234
T#1s234ms
Word (signed) type
Time type
5.1 Type Conversion Functions
5.1.14 Word (signed), double word (signed) type → time type conversion
s
into time type data, and
INT_TO_TIME(_E), DINT_TO_TIME(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*2
Undefined value
d
*2: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the INT_TO_TIME(_E) and
DINT_TO_TIME(_E) functions.
Program Example
(1) The program which converts word (signed) type data input to
outputs the operation result from
d
s
into time type data, and
.
(a) Function without EN/ENO (INT_TO_TIME)
5
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
INT_TO_TIME(_E),
DINT_TO_TIME(_E)
g_time1:= INT_TO_TIME(g_int1);
(b) Function with EN/ENO (INT_TO_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INT_TO_TIME_E(g_bool1, g_int1, g_time1);
5.1 Type Conversion Functions
5.1.14 Word (signed), double word (signed) type → time type conversion
5-39
INT_TO_TIME(_E), DINT_TO_TIME(_E)
(2) The program which converts double word (signed) type data input to
and outputs the operation result from
d
.
(a) Function without EN/ENO (DINT_TO_TIME)
[Structured ladder/FBD]
[ST]
g_time1:= DINT_TO_TIME(g_dint1);
5-40
5.1 Type Conversion Functions
5.1.14 Word (signed), double word (signed) type → time type conversion
s
into time type data,
REAL_TO_INT(_E), REAL_TO_DINT(_E)
5.1.15
Single-precision real type → word (signed), double word
(signed) type conversion
REAL_TO_INT(_E), REAL_TO_DINT(_E)
Basic
REAL_TO_INT(_E)
REAL_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
REAL_TO_INT_E
EN
REAL_TO_INT_E
REAL_TO_DINT
REAL_TO_DINT_E
ENO:= REAL_TO_INT_E (EN, s, d);
ENO
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_REAL):
Input
:Single-precision real
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
(1) REAL_TO_INT, REAL_TO_INT_E
(a) Converts single-precision real type data input to
outputs the operation result from
d
s
into word (signed) type data, and
.
s
d
1234.0
1234
Single-precision real type
Word (signed) type
(b) The value to be input to
−32768 to 32767.
s
is single-precision real type data, within the range from
(c) The converted data is the value rounded single-precision real type data to the first digit
after the decimal point.
5.1 Type Conversion Functions
5.1.15 Single-precision real type → word (signed), double word (signed) type conversion
5-41
REAL_TO_INT(_E),
REAL_TO_DINT(_E)
s
REAL_TO_INT
REAL_TO_INT(_E), REAL_TO_DINT(_E)
(2) REAL_TO_DINT, REAL_TO_DINT_E
(a) Converts single-precision real type data input to
and outputs the operation result from
d
s
into double word (signed) type data,
.
s
d
16543521.0
16543521
Single-precision real type
Double word (signed) type
(b) The value to be input to s is single-precision real type data within the range from
−2147483648 to 2147483647.
However, a rounding error may occur when setting the input value by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(c) The converted data is the value rounded single-precision real type data to the first digit
after the decimal point.
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
FALSE (Operation stop)
d
*1
FALSE
Operation output value
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-42
5.1 Type Conversion Functions
5.1.15 Single-precision real type → word (signed), double word (signed) type conversion
REAL_TO_INT(_E), REAL_TO_DINT(_E)
Operation Error
An operation error occurs in the following cases.
• REAL_TO_INT(_E): The input value is outside the range of −32768 to 32767.
(Error code: 4100)
• REAL_TO_DINT(_E): The input value is outside the range of −2147483648 to
2147483647.
(Error code: 4100)
Program Example
(1) The program which converts single-precision real type data input to
type data, and outputs the operation result from
d
s
into word (signed)
.
(a) Function without EN/ENO (REAL_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1:= REAL_TO_INT(g_real1);
(b) Function with EN/ENO (REAL_TO_INT_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
(2) The program which converts single-precision real type data input to
(signed) type data, and outputs the operation result from
d
s
into double word
.
(a) Function without EN/ENO (REAL_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1:= REAL_TO_DINT(g_real1);
5.1 Type Conversion Functions
5.1.15 Single-precision real type → word (signed), double word (signed) type conversion
5-43
REAL_TO_INT(_E),
REAL_TO_DINT(_E)
g_bool3 := REAL_TO_INT_E(g_bool1, g_real1, g_int1);
LREAL_TO_INT(_E), LREAL_TO_DINT(_E)
5.1.16
Double-precision real type → word (signed), double word
(signed) type conversion
LREAL_TO_INT(_E), LREAL_TO_DINT(_E)
Basic
LREAL_TO_INT(_E)
LREAL_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
LREAL_TO_INT_E
EN
LREAL_TO_INT_E
LREAL_TO_DINT
LREAL_TO_DINT_E
ENO:= LREAL_TO_INT_E (EN, s, d);
ENO
s
LREAL_TO_INT
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_LREAL):
Input
:Double-precision real
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
Function
Operation processing
(1) LREAL_TO_INT, LREAL_TO_INT_E
(a) Converts double-precision real type data input to
outputs the operation result from
d
s
into word (signed) type data, and
.
s
d
1234.0
1234
Double-precision real type
Word (signed) type
(b) The value to be input to
−32768 to 32767.
s
is double-precision real type data, within the range from
(c) The converted data is the value rounded double-precision real type data to the first digit
after the decimal point.
5-44
5.1 Type Conversion Functions
5.1.16 Double-precision real type → word (signed), double word (signed) type conversion
LREAL_TO_INT(_E), LREAL_TO_DINT(_E)
(2) LREAL_TO_DINT, LREAL_TO_DINT_E
(a) Converts double-precision real type data input to
data, and outputs the operation result from
d
s
into double word (signed) type
.
s
d
16543521.0
16543521
Double-precision real type
Double word (signed) type
(b) The value to be input to s is double-precision real type data within the range from
−2147483648 to 2147483647.
However, rounding error may occur when setting the input value by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(c) The converted data is the value rounded double-precision real type data to the first digit
after the decimal point.
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
5
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
APPLICATION
FUNCTIONS
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
LREAL_TO_INT(_E),
LREAL_TO_DINT(_E)
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.1 Type Conversion Functions
5.1.16 Double-precision real type → word (signed), double word (signed) type conversion
5-45
LREAL_TO_INT(_E), LREAL_TO_DINT(_E)
Operation Error
An operation error occurs in the following cases.
• The input value is -0 or outside the following range.
-1022
0, 2
|
s
|
(Error code: 4140)
1024
2
• LREAL_TO_INT(_E): The input value is outside the range of -32768 to 32767.
(Error code: 4140)
• LREAL_TO_DINT(_E): The input value is outside the range of -2147483648 to
2147483647.
(Error code: 4140)
Program Example
(1) The program which converts double-precision real type data input to
type data, and outputs the operation result from
d
s
into word (signed)
s
into double word
.
(a) Function without EN/ENO (LREAL_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1:= LREAL_TO_INT(g_lreal1);
(b) Function with EN/ENO (LREAL_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := LREAL_TO_INT_E(g_bool1, g_lreal1, g_int1);
(2) The program which converts double-precision real type data input to
(signed) type data, and outputs the operation result from
d
.
(a) Function without EN/ENO (LREAL_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1:= LREAL_TO_DINT(g_lreal1);
5-46
5.1 Type Conversion Functions
5.1.16 Double-precision real type → word (signed), double word (signed) type conversion
REAL_TO_LREAL(_E)
5.1.17
Single-precision real type → double-precision real type
conversion
REAL_TO_LREAL(_E)
Basic
REAL_TO_LREAL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
REAL_TO_LREAL
REAL_TO_LREAL_E
REAL_TO_LREAL_E
EN
ENO:= REAL_TO_LREAL_E (EN, s, d);
ENO
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_REAL):
Input
:Single-precision real
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Double-precision real
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
(1) Converts single-precision real type data input to
outputs the operation result from
d
s
into double-precision real type data, and
.
s
d
1234.0
1234.0
Single-precision real type
Double-precision real type
(2) Rounding error may occur when specifying the input value to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5.1 Type Conversion Functions
5.1.17 Single-precision real type → double-precision real type conversion
5-47
REAL_TO_LREAL(_E)
s
REAL_TO_LREAL(_E)
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-48
5.1 Type Conversion Functions
5.1.17 Single-precision real type → double-precision real type conversion
REAL_TO_LREAL(_E)
Operation Error
An operation error occurs in the following cases.
• The input value is -0 or outside the following range.
0, 2
-126
|
s
|
(Error code: 4140)
128
2
• The operation result is outside the following range (an overflow occurrence).
(Error code: 4141)
21024
| operation result |
Program Example
The program which converts single-precision real type data input to
type data, and outputs the operation result from
d
s
into double-precision real
.
(a) Function without EN/ENO (REAL_TO_LREAL)
[Structured ladder/FBD]
[ST]
g_lreal1:= REAL_TO_LREAL(g_real1);
5
(b) Function with EN/ENO (REAL_TO_LREAL_E)
REAL_TO_LREAL(_E)
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
g_bool3 := REAL_TO_LREAL_E(g_bool1, g_real1, g_lreal1);
5.1 Type Conversion Functions
5.1.17 Single-precision real type → double-precision real type conversion
5-49
LREAL_TO_REAL(_E)
5.1.18
Double-precision real type → single-precision real type
conversion
LREAL_TO_REAL(_E)
Basic
LREAL_TO_REAL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
LREAL_TO_REAL
LREAL_TO_REAL_E
LREAL_TO_REAL_E
EN
ENO:= LREAL_TO_REAL_E (EN, s, d);
ENO
s
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_LREAL): Input
Output argument,
:Bit
:Double-precision real
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Single-precision real
Function
Operation processing
(1) Converts double-precision real type data input to
outputs the operation result from
d
s
into single-precision real type data, and
.
s
d
1234.0
1234
Double-precision real type
Single-precision real type
(2) Rounding error may occur when setting the input value to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to MELSEC-Q/
L/F Structured Programming Manual (Fundamentals).
5-50
5.1 Type Conversion Functions
5.1.18 Double-precision real type → single-precision real type conversion
LREAL_TO_REAL(_E)
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
LREAL_TO_REAL(_E
)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.18 Double-precision real type → single-precision real type conversion
5-51
LREAL_TO_REAL(_E)
Operation Error
An operation error occurs in the following cases.
• The input value is -0 or outside the following range.
-1022
0, 2
|
s
|
(Error code: 4140)
1024
2
• The operation result is outside the following range (an overflow occurrence).
(Error code: 4141)
2128
| operation result |
Program Example
The program which converts double-precision real type data input to
type data, and outputs the operation result from
d
s
.
(a) Function without EN/ENO (LREAL_TO_REAL)
[Structured ladder/FBD]
[ST]
g_real1:= LREAL_TO_REAL(g_lreal1);
(b) Function with EN/ENO (LREAL_TO_REAL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := LREAL_TO_REAL_E(g_bool1, g_lreal1, g_real1);
5-52
5.1 Type Conversion Functions
5.1.18 Double-precision real type → single-precision real type conversion
into single-precision real
REAL_TO_STR(_E)
5.1.19
Single-precision real type → string type conversion
REAL_TO_STR(_E)
Ver.
Basic
High
performance
Universal
L CPU
Basic model QCPU: First 5 digits of the serial number are 04122 or higher
REAL_TO_STR(_E)
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
REAL_TO_STR
REAL_TO_STR_E
REAL_TO_STR_E
EN
ENO:= REAL_TO_STR_E (EN, s, d);
ENO
s
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_REAL):
Input
:Single-precision real
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String(13)
5
APPLICATION
FUNCTIONS
Input argument,
Function
(1) Converts single-precision real type data input to
and outputs the operation result from
d
s
into string type (exponential form) data,
.
d
High-order byte
s
Single-precision
real type
.
Sign
(integer part)
E
Sign
(exponent part)
Automatically
added.
Low-order byte
20H(space)
Sign data
(integer part)
2EH(.)
ASCII code of
integer part
2nd word
ASCII code of
two decimal place
ASCII code of
one decimal place
3rd word
ASCII code of
four decimal place
ASCII code of
three decimal place
4th word
45H(E)
ASCII code of
five decimal place
5th word
ASCII code of
exponent part's
tens place
Sign data
(exponent part)
6th word
00H(NUL)
ASCII code of
exponent part's
units place
7th word
String 1st word
When SM701 (signal for switching the number of output character) is OFF,
"00H" is stored.
5.1 Type Conversion Functions
5.1.19 Single-precision real type → string type conversion
5-53
REAL_TO_STR(_E)
Operation processing
REAL_TO_STR(_E)
(2) The character string data after conversion is output from output variable
manner.
d
in the following
(a) The number of digits is fixed respectively for the integer part, fractional part, and
exponent part. (Integer part: 1 digit, fractional part: 5 digits, exponent part: 2 digits)
'20H' (space), '2EH' (.) and '45H' (E) are automatically stored in the 2nd, 4th and 10th
bytes, respectively.
d
All together 13 digits
s
Integer part (1 digit) Fractional part (5 digits)Exponent part (2 digits)
-12.3456
-
1 . 2 3 4 5 6 E + 0 1
45H (E)
Single-precision real type
2EH (.)
20H (space)
(b) '20H' (space) is stored in 'Sign data' (integer part) when the input value is positive; '2DH'
(−) is stored when negative.
(c) Fractional part is rounded to 5 decimal places.
d
All together 13 digits
s
-12.345678
Single-precision real type
7
-
1 . 2 3 4 5 6 7 8 E + 0 1
Fractional part (5 digits)
Rounded off.
(d) If the number of significant figures is less, '30H' (0) is stored to fractional part.
d
All together 13 digits
s
-12.34
-
1 . 2 3 4 0 0 E + 0 1
30H (0)
Single-precision real type
Fractional part (5 digits)
(e) '2BH' (+) is stored in the 'Sign data' (exponent part) if the exponent is positive; '2DH' (−)
is stored when negative.
(f)
'30H' (0) is stored to tens place in the exponent part if exponent part has only one digit.
d
All together 13 digits
Exponent part (2 digits)
s
-12.3456
-
1 . 2 3 4 5 6 E + 0 1
Single-precision real type
30H (0)
(3) When SM701 (signal for switching the number of output characters) is OFF, "00H" is stored
to the end of the character string (7th word).
(4) Rounding error may occur when specifying the input value to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5-54
5.1 Type Conversion Functions
5.1.19 Single-precision real type → string type conversion
REAL_TO_STR(_E)
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
REAL_TO_STR(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.19 Single-precision real type → string type conversion
5-55
REAL_TO_STR(_E)
Operation Error
An operation error occurs in the following case.
• The input value is outside the range of -3.40282+38 to -1.17549-38, 0 or 1.17549-38 to
3.40282+38
(Error code: 4100)
Program Example
The program which converts single-precision real type data input to
(exponential form) data, and outputs the operation result from
d
s
.
(a) Function without EN/ENO (REAL_TO_STR)
[Structured ladder/FBD]
[ST]
g_string1:= REAL_TO_STR(g_real1);
(b) Function with EN/ENO (REAL_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := REAL_TO_STR_E(g_bool1, g_real1, g_string1);
5-56
5.1 Type Conversion Functions
5.1.19 Single-precision real type → string type conversion
into string type
WORD_TO_BOOL(_E), DWORD_TO_BOOL(_E)
5.1.20
Word (unsigned)/16-bit string, double word (unsigned)/32-bit
string type → bit type conversion
WORD_TO_BOOL(_E), DWORD_TO_BOOL(_E)
Basic
WORD_TO_BOOL(_E)
DWORD_TO_BOOL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
WORD_TO_BOOL_E
EN
WORD_TO_BOOL_E
DWORD_TO_BOOL
DWORD_TO_BOOL_E
ENO:= WORD_TO_BOOL_E (EN, s, d);
ENO
s
WORD_TO_BOOL
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop) :Bit
s(_WORD, _DWORD): Input
:Word (unsigned)/16-bit string, double word
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Bit
5
APPLICATION
FUNCTIONS
(unsigned)/32-bit string
Output argument,
Operation processing
(1) WORD_TO_BOOL, WORD_TO_BOOL_E
Converts word (unsigned)/16-bit string type data input to
s
into bit type data, and outputs
the operation result from d .
When the input value is 0H, FALSE is output.
When the input value is other than 0H, TRUE is output.
s
d
0H
FALSE
1567H
TRUE
Word (unsigned)/16-bit string type
Bit type
5.1 Type Conversion Functions
5.1.20 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → bit type conversion
5-57
WORD_TO_BOOL(_E),
DWORD_TO_BOOL(_E)
Function
WORD_TO_BOOL(_E), DWORD_TO_BOOL(_E)
(2) DWORD_TO_BOOL, DWORD_TO_BOOL_E
Converts double word (unsigned)/32-bit string type data input to
into bit type data, and
s
outputs the operation result from d .
When the input value is 0H, FALSE is output.
When the input value is other than 0H, TRUE is output.
s
d
0H
FALSE
12345678H
TRUE
Double word (unsigned)/32-bit string type
Bit type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-58
5.1 Type Conversion Functions
5.1.20 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → bit type conversion
WORD_TO_BOOL(_E), DWORD_TO_BOOL(_E)
Operation Error
No operation error occurs in the execution of the WORD_TO_BOOL(_E) and
DWORD_TO_BOOL(_E) functions.
Program Example
(1) The program which converts word (unsigned)/16-bit string type data input to
data, and outputs the operation result from
d
s
into bit type
.
(a) Function without EN/ENO (WORD_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1:= WORD_TO_BOOL(g_word1);
(b) Function with EN/ENO (WORD_TO_BOOL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := WORD_TO_BOOL_E(g_bool1, g_word1, g_bool2);
(2) The program which converts double word (unsigned)/32-bit string type data input to
d
into
.
WORD_TO_BOOL(_E),
DWORD_TO_BOOL(_E)
bit type data, and outputs the operation result from
s
(a) Function without EN/ENO (DWORD_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1:= DWORD_TO_BOOL(g_dword1);
5.1 Type Conversion Functions
5.1.20 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → bit type conversion
APPLICATION
FUNCTIONS
5
5-59
WORD_TO_INT(_E), WORD_TO_DINT(_E)
5.1.21
Word (unsigned)/16-bit string type → word (signed), double
word (signed) type conversion
WORD_TO_INT(_E), WORD_TO_DINT(_E)
Basic
WORD_TO_INT(_E)
WORD_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
WORD_TO_INT_E
EN
WORD_TO_INT_E
WORD_TO_DINT
WORD_TO_DINT_E
ENO:= WORD_TO_INT_E (EN, s, d);
ENO
s
WORD_TO_INT
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_WORD):
Input
:Word (unsigned)/16-bit string
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
Function
Operation processing
(1) WORD_TO_INT, WORD_TO_INT_E
Converts word (unsigned)/16-bit string type data input to
and outputs the operation result from
5-60
d
s
into word (signed) type data,
.
s
d
5678H
22136
Word (unsigned)/16-bit string type
Word (signed) type
5.1 Type Conversion Functions
5.1.21 Word (unsigned)/16-bit string type → word (signed), double word (signed) type conversion
WORD_TO_INT(_E), WORD_TO_DINT(_E)
(2) WORD_TO_DINT, WORD_TO_DINT_E
Converts word (unsigned)/16-bit string type data input to
data, and outputs the operation result from
d
s
into double word (signed) type
.
s
d
5678H
22136
Word (unsigned)/16-bit string type
Double word (signed) type
5678H
0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
Data conversion
22136
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
Always filled with 0s.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
WORD_TO_INT(_E),
WORD_TO_DINT(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.21 Word (unsigned)/16-bit string type → word (signed), double word (signed) type conversion
5-61
WORD_TO_INT(_E), WORD_TO_DINT(_E)
Operation Error
No operation error occurs in the execution of the WORD_TO_INT(_E) and
WORD_TO_DINT(_E) functions.
Program Example
(1) The program which converts word (unsigned)/16-bit string type data input to
(signed) type data, and outputs the operation result from
d
s
into word
s
into double
.
(a) Function without EN/ENO (WORD_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1:= WORD_TO_INT(g_word1);
(b) Function with EN/ENO (WORD_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := WORD_TO_INT_E(g_bool1, g_word1, g_int1);
(2) The program which converts word (unsigned)/16-bit string type data input to
word (signed) type data, and outputs the operation result from
d
.
(a) Function without EN/ENO (WORD_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1:= WORD_TO_DINT(g_word1);
5-62
5.1 Type Conversion Functions
5.1.21 Word (unsigned)/16-bit string type → word (signed), double word (signed) type conversion
DWORD_TO_INT(_E), DWORD_TO_DINT(_E)
5.1.22
Double word (unsigned)/32-bit string type → word (signed),
double word (signed) type conversion
DWORD_TO_INT(_E), DWORD_TO_DINT(_E)
High
performance
Basic
DWORD_TO_INT(_E)
DWORD_TO_DINT(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
DWORD_TO_INT_E
EN
DWORD_TO_INT_E
DWORD_TO_DINT
DWORD_TO_DINT_E
ENO:= DWORD_TO_INT_E (EN, s, d);
ENO
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_DWORD):
Input
:Double word (unsigned)/32-bit string
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
(1) DWORD_TO_INT, DWORD_TO_INT_E
Converts double word (unsigned)/32-bit string type data input to
data, and outputs the operation result from
d
s
into word (signed) type
.
s
d
BC614EH
24910
Double word (unsigned)/32-bit string type
Word (signed) type
BC614EH
0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
24910
0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
High-order 16-bit data is discarded.
5.1 Type Conversion Functions
5.1.22 Double word (unsigned)/32-bit string type → word (signed), double word (signed) type conversion
5-63
DWORD_TO_INT(_E),
DWORD_TO_DINT(_E)
s
DWORD_TO_INT
DWORD_TO_INT(_E), DWORD_TO_DINT(_E)
(2) DWORD_TO_DINT, DWORD_TO_DINT_E
Converts double word (unsigned)/32-bit string type data input to
(signed) type data, and outputs the operation result from
d
into double word
s
.
s
d
BC614EH
12345678
Double word (unsigned)/32-bit string type
Double word (signed) type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
When the DINT_TO_INT(_E) function is executed, low-order 16-bit data of double
word (unsigned)/32-bit string type data input to s are converted into word
(signed) type data. High-order 16-bit data are discarded.
5-64
5.1 Type Conversion Functions
5.1.22 Double word (unsigned)/32-bit string type → word (signed), double word (signed) type conversion
DWORD_TO_INT(_E), DWORD_TO_DINT(_E)
Operation Error
No operation error occurs in the execution of the DWORD_TO_INT(_E) and
DWORD_TO_DINT(_E) functions.
Program Example
(1) The program which converts double word (unsigned)/32-bit string type data input to
word (signed) type data, and outputs the operation result from
d
s
into
.
(a) Function without EN/ENO (DWORD_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1:= DWORD_TO_INT(g_dword1);
(b) Function with EN/ENO (DWORD_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := DWORD_TO_INT_E(g_bool1, g_dword1, g_int1);
(2) The program which converts double word (unsigned)/32-bit string type data input to
double word (signed) type data, and outputs the operation result from
d
s
into
.
(a) Function without EN/ENO (DWORD_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1:= DWORD_TO_DINT(g_dword1);
5.1 Type Conversion Functions
5.1.22 Double word (unsigned)/32-bit string type → word (signed), double word (signed) type conversion
5-65
DWORD_TO_INT(_E),
DWORD_TO_DINT(_E)
APPLICATION
FUNCTIONS
5
WORD_TO_DWORD(_E)
5.1.23
Word (unsigned)/16-bit string type → double word
(unsigned)/32-bit string type conversion
WORD_TO_DWORD(_E)
Basic
WORD_TO_DWORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
WORD_TO_DWORD
WORD_TO_DWORD_E
WORD_TO_DWORD_E
EN
ENO:= WORD_TO_DWORD_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_WORD):
Input
:Word (unsigned)/16-bit string
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Double word (unsigned)/32-bit string
Function
Operation processing
Converts word (unsigned)/16-bit string type data input to
s
into double word (unsigned)/32-
bit string type data, and outputs the operation result from d .
After data conversion, high-order 16 bits are filled with 0s.
5-66
s
d
5678H
00005678H
Word (unsigned)/16-bit string type
Double word (unsigned)/32-bit string type
5.1 Type Conversion Functions
5.1.23 Word (unsigned)/16-bit string type → double word (unsigned)/32-bit string type conversion
WORD_TO_DWORD(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
WORD_TO_DWORD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.23 Word (unsigned)/16-bit string type → double word (unsigned)/32-bit string type conversion
5-67
WORD_TO_DWORD(_E)
Operation Error
No operation error occurs in the execution of the WORD_TO_DWORD(_E) function.
Program Example
The program which converts word (unsigned)/16-bit string type data input to
(unsigned)/32-bit string type data, and outputs the operation result from
d
s
into double word
.
(a) Function without EN/ENO (WORD_TO_DWORD)
[Structured ladder/FBD]
[ST]
g_dword1:= WORD_TO_DWORD(g_word1);
(b) Function with EN/ENO (WORD_TO_DWORD_E)
[Structured ladder/FBD]
[ST]
g_bool3 := WORD_TO_DWORD_E(g_bool1, g_word1, g_dword1);
5-68
5.1 Type Conversion Functions
5.1.23 Word (unsigned)/16-bit string type → double word (unsigned)/32-bit string type conversion
DWORD_TO_WORD(_E)
5.1.24
Double word (unsigned)/32-bit string type → word
(unsigned)/16-bit string type conversion
DWORD_TO_WORD(_E)
High
performance
Basic
DWORD_TO_WORD(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
DWORD_TO_WORD
DWORD_TO_WORD_E
DWORD_TO_WORD_E
EN
ENO:= DWORD_TO_WORD_E (EN, s, d);
ENO
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_DWORD):
Input
:Double word (unsigned)/32-bit string
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
Converts double word (unsigned)/32-bit string type data input to
bit string type data, and outputs the operation result from
d
12345678H
5678H
2
3
4
into word (unsigned)/16-
.
s
Double word (unsigned)/32-bit string type
1
d
s
Word (unsigned)/16-bit string type
5
6
7
8
12345678H
0 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
5678H
0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
High-order 16-bit data is discarded.
5.1 Type Conversion Functions
5.1.24 Double word (unsigned)/32-bit string type → word (unsigned)/16-bit string type conversion
5-69
DWORD_TO_WORD(_E)
s
DWORD_TO_WORD(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
When the DWORD_TO_WORD(_E) function is executed, low-order 16-bit data of
double word (unsigned)/32-bit string type data input to s are converted into word
(unsigned)/16-bit string type data. High-order 16-bit data are discarded.
5-70
5.1 Type Conversion Functions
5.1.24 Double word (unsigned)/32-bit string type → word (unsigned)/16-bit string type conversion
DWORD_TO_WORD(_E)
Operation Error
No operation error occurs in the execution of the DWORD_TO_WORD(_E) function.
Program Example
The program which converts double word (unsigned)/32-bit string type data input to
(unsigned)/16-bit string type data, and outputs the operation result from
d
s
into word
.
(a) Function without EN/ENO (DWORD_TO_WORD)
[Structured ladder/FBD]
[ST]
g_word1:= DWORD_TO_WORD(g_dword1);
(b) Function with EN/ENO (DWORD_TO_WORD_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
DWORD_TO_WORD(_E)
g_bool3 := DWORD_TO_WORD_E(g_bool1, g_dword1, g_word1);
5.1 Type Conversion Functions
5.1.24 Double word (unsigned)/32-bit string type → word (unsigned)/16-bit string type conversion
5-71
WORD_TO_STR(_E), DWORD_TO_STR(_E)
5.1.25
Word (unsigned)/16-bit string, double word (unsigned)/32-bit
string type → string type conversion
WORD_TO_STR(_E), DWORD_TO_STR(_E)
Basic
WORD_TO_STR(_E)
DWORD_TO_STR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
WORD_TO_STR_E
EN
WORD_TO_STR_E
DWORD_TO_STR
DWORD_TO_STR_E
ENO:= WORD_TO_STR_E (EN, s, d);
ENO
s
WORD_TO_STR
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop) :Bit
s(_WORD, _DWORD):
Input
:Word (unsigned)/16-bit string, double word
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String(4)/(8)
(unsigned)/32-bit string
Output argument,
Function
Operation processing
(1) WORD_TO_STR, WORD_TO_STR_E
(a) Converts word (unsigned)/16-bit string type data input to
outputs the operation result from
d
s
into string type data, and
.
s
d
0H
'0'
1567H
' 1567 '
Word (unsigned)/16-bit string type
String type
(b) When SM701 (signal for switching the number of output characters) is OFF, "00H" is
stored to the end of the character string.
5-72
5.1 Type Conversion Functions
5.1.25 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → string type conversion
WORD_TO_STR(_E), DWORD_TO_STR(_E)
(2) DWORD_TO_STR, DWORD_TO_STR_E
(a) Converts double word (unsigned)/32-bit string type data input to
and outputs the operation result from
d
s
into string type data,
.
s
d
0H
'0'
12345678H
' 12345678 '
Double word (unsigned)/32-bit string type
String type
(b) When SM701 (signal for switching the number of output characters) is OFF, "00H" is
stored to the end of the character string.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
WORD_TO_STR(_E),
DWORD_TO_STR(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.25 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → string type conversion
5-73
WORD_TO_STR(_E), DWORD_TO_STR(_E)
Operation Error
No operation error occurs in the execution of the WORD_TO_STR(_E) and
DWORD_TO_STR(_E) functions.
Program Example
(1) The program which converts word (unsigned)/16-bit string type data input to
type data, and outputs the operation result data from
d
s
into string
.
(a) Function without EN/ENO (WORD_TO_STR)
[Structured ladder/FBD]
[ST]
g_string1 := WORD_TO_STR (g_word1);
(b) Function with EN/ENO (WORD_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := WORD_TO_STR_E (g_bool1, g_word1, g_string1);
(2) The program which converts double word (unsigned)/32-bit string type data input to
string type data, and outputs the operation result data from
d
.
(a) Function without EN/ENO (DWORD_TO_STR)
[Structured ladder/FBD]
[ST]
g_string1:= DWORD_TO_STR (g_dword1);
5-74
5.1 Type Conversion Functions
5.1.25 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → string type conversion
s
into
WORD_TO_TIME(_E), DWORD_TO_TIME(_E)
5.1.26
Word (unsigned)/16-bit string, double word (unsigned)/32-bit
string type → time type conversion
WORD_TO_TIME(_E), DWORD_TO_TIME(_E)
Basic
WORD_TO_TIME(_E)
DWORD_TO_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
WORD_TO_TIME_E
EN
WORD_TO_ TIME _E
DWORD_TO_TIME
DWORD_TO_ TIME _E
ENO:= WORD_TO_TIME_E (EN, s, d);
ENO
s
WORD_TO_TIME
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_WORD, _DWORD): Input
:Word (unsigned)/16-bit string, double word
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
5
APPLICATION
FUNCTIONS
(unsigned)/32-bit string
Output argument,
Operation processing
(1) WORD_TO_TIME, WORD_TO_TIME_E
Converts word (unsigned)/16-bit string type data input to
the operation result from
d
s
into time type data, and outputs
.
s
d
0H
T#0ms
1234H
T#1s234ms
Word (unsigned)/16-bit string type
Time type
5.1 Type Conversion Functions
5.1.26 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → time type conversion
5-75
WORD_TO_TIME(_E),
DWORD_TO_TIME(_E)
Function
WORD_TO_TIME(_E), DWORD_TO_TIME(_E)
(2) DWORD_TO_TIME, DWORD_TO_TIME_E
Converts double word (unsigned)/32-bit string type data input to
outputs the operation result from
d
into time type data, and
s
.
s
d
0H
T#0ms
1234567H
T#20m34s567ms
Double word (unsigned)/32-bit string type
Time type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-76
5.1 Type Conversion Functions
5.1.26 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → time type conversion
WORD_TO_TIME(_E), DWORD_TO_TIME(_E)
Operation Error
No operation error occurs in the execution of the WORD_TO_TIME(_E) and
DWORD_TO_TIME(_E) functions.
Program Example
(1) The program which converts word (unsigned)/16-bit string type data input to
type data, and outputs the operation result from
d
s
into time
.
(a) Function without EN/ENO (WORD_TO_TIME)
[Structured ladder/FBD]
[ST]
g_time1 := WORD_TO_TIME (g_word1);
(b) Function with EN/ENO (WORD_TO_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := WORD_TO_TIME_E (g_bool1, g_word1, g_time1);
(2) The program which converts double word (unsigned)/32-bit string type data input to
time type data, and outputs the operation result from
d
s
into
.
(a) Function without EN/ENO (DWORD_TO_TIME)
[Structured ladder/FBD]
[ST]
g_time1 := DWORD_TO_TIME (g_dword1)
5.1 Type Conversion Functions
5.1.26 Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type → time type conversion
5-77
WORD_TO_TIME(_E),
DWORD_TO_TIME(_E)
APPLICATION
FUNCTIONS
5
STR_TO_BOOL(_E)
5.1.27
String type → bit type conversion
STR_TO_BOOL(_E)
Basic
STR_TO_BOOL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_BOOL
STR_TO_BOOL_E
STR_TO_BOOL_E
EN
ENO:= STR_TO_BOOL_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_STRING):
Input
:String(1)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Bit
Function
Operation processing
Converts string type data input to
s
into bit type data, and outputs the operation result from
.
When the input value is 0, FALSE is output in bit type data.
When the input value is other than 0, TRUE is output in bit type data.
d
5-78
s
d
'0'
FALSE
'1'
TRUE
String type
Bit type
5.1 Type Conversion Functions
5.1.27 String type → bit type conversion
STR_TO_BOOL(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
STR_TO_BOOL(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.27 String type → bit type conversion
5-79
STR_TO_BOOL(_E)
Operation Error
No operation error occurs in the execution of the STR_TO_BOOL(_E) function.
Program Example
The program which converts string type data input to
operation result from
d
s
into bit type data, and outputs the
.
(a) Function without EN/ENO (STR_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1 := STR_TO_BOOL (g_string1);
(b) Function with EN/ENO (STR_TO_BOOL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := STR_TO_BOOL_E (g_bool1, g_string1, g_bool2);
5-80
5.1 Type Conversion Functions
5.1.27 String type → bit type conversion
STR_TO_INT(_E), STR_TO_DINT(_E)
5.1.28
String type → word (signed), double word (signed) type
conversion
STR_TO_INT(_E), STR_TO_DINT(_E)
Basic
STR_TO_INT(_E)
STR_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_INT_E
EN
STR_TO_INT_E
STR_TO_DINT
STR_TO_DINT_E
ENO:= STR_TO_INT_E (EN, s, d);
ENO
d
Input argument,
Output argument,
5
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_STRING):
Input
:String (6)/(11)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
APPLICATION
FUNCTIONS
s
STR_TO_INT
Function
STR_TO_INT(_E),
STR_TO_DINT(_E)
Operation processing
(1) STR_TO_INT, STR_TO_INT_E
(a) Converts string type data input to
operation result from
d
s
into word (signed) type data, and outputs the
.
s
High-order byte
String 1st word ASCII code of ten-thousands place
Low-order byte
Sign data
d
2nd word ASCII code of hundreds place ASCII code of thousands place
3rd word ASCII code of units place ASCII code of tens place
4th word
00H (Indicates the end of the character string.)
Word (signed) type
(b) The value to be input to s is string type data within the following range.
ASCII code: '30H' to '39H', '20H', '2DH', and '00H'
String type data: '-32768' to '32767'
5.1 Type Conversion Functions
5.1.28 String type → word (signed), double word (signed) type conversion
5-81
STR_TO_INT(_E), STR_TO_DINT(_E)
(2) STR_TO_DINT, STR_TO_DINT_E
(a) Converts string type data input to
the operation result from
d
into double word (signed) type data, and outputs
s
.
s
High-order byte
Low-order byte
String 1st word ASCII code of billions place
Sign data
d
2nd word ASCII code of ten-millions place ASCII code of hundred-millions place
3rd word ASCII code of hundred-thousands place ASCII code of millions place
4th word ASCII code of thousands place ASCII code of ten-thousands place
5th word
ASCII code of tens place
ASCII code of hundreds place
6th word
00H
ASCII code of units place
Double word (signed) type
Indicates the end of the character string.
(b) The value to be input to s is string type data within the following range.
ASCII code: '30H' to '39H', '20H', '2DH', and '00H'
String type data: −2147483648 to 2147483647
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-82
5.1 Type Conversion Functions
5.1.28 String type → word (signed), double word (signed) type conversion
STR_TO_INT(_E), STR_TO_DINT(_E)
Operation Error
An operation error occurs in the following cases.
• The input value is other than '30H' to '39H', '20H', '2DH', and '00H' of ASCII code.
(Error code: 4100)
• The input value is outside the following ranges of ASCII code.
STR_TO_INT(_E): −32768 to 32767
STR_TO_DINT(_E): −2147483648 to 2147483647
(Error code: 4100)
Program Example
(1) The program which converts string type data input to
outputs the operation result from
d
s
into word (signed) type data, and
.
(a) Function without EN/ENO (STR_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1 := STR_TO_INT (g_string1);
5
(b) Function with EN/ENO (STR_TO_INT_E)
[ST]
g_bool3 := STR_TO_INT_E (g_bool1, g_string1, g_int1);
(2) The program which converts string type data input to
and outputs the operation result from
d
s
into double word (signed) type data,
.
(a) Function without EN/ENO (STR_TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1 := STR_TO_DINT (g_string1);
5.1 Type Conversion Functions
5.1.28 String type → word (signed), double word (signed) type conversion
5-83
STR_TO_INT(_E),
STR_TO_DINT(_E)
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
STR_TO_REAL(_E)
5.1.29
String type → single-precision real type conversion
STR_TO_REAL(_E)
Ver.
Basic
High
performance
Universal
L CPU
Basic model QCPU: First 5 digits of the serial number are 04122 or higher
STR_TO_REAL(_E)
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_REAL
STR_TO_REAL_E
STR_TO_REAL_E
EN
ENO
s
ENO:= STR_TO_REAL_E (EN, s, d);
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop) :Bit
s(_STRING):
Input
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Single-precision real
:String (24)
Function
Operation processing
(1) Converts string type (decimal form/exponential form) data input to
real type data, and outputs the operation result from
d
s
into single-precision
.
s
String 1st word
High-order byte
Low-order byte
ASCII code of 1st character
Sign date
2nd word
ASCII code of 3rd character ASCII code of 2nd character
3rd word
ASCII code of 5th character
ASCII code of 4th character
4th word
ASCII code of 7th character
ASCII code of 6th character
5th word
ASCII code of 9th character
ASCII code of 8th character
6th word ASCII code of 11th character ASCII code of 10th character
7th word
5-84
00H (Indicates the end of the character string.)
5.1 Type Conversion Functions
5.1.29 String type → single-precision real type conversion
d
Single-precision real type
STR_TO_REAL(_E)
(2) Both string type data in decimal form and exponential form can be converted to singleprecision real type data.
(a) Decimal form
s
High-order byte
Low-order byte
String 1st word
31H(1)
2DH(-)
2nd word
33H(3)
2EH(.)
3rd word
30H(0)
35H(5)
d
4th word
34H(4)
33H(3)
-1.35034
5th word
00H
Single-precision real type
- 1 . 3 5 0 3 4
(b) Exponential form
s
High-order byte
Low-order byte
String 1st word
31H(1)
2DH(-)
2nd word
33H(3)
2EH(.)
3rd word
30H(0)
35H(5)
d
4th word
34H(4)
33H(3)
-1.35034E-10
5th word
2DH(-)
45H(E)
6th word
30H(0)
31H(1)
7th word
Single-precision real type
00H
- 1 . 3 5 0 3 4 E - 1 0
(3) As the number of significant figures of string type data is 6, the 7th and later digits excluding
the sign, decimal point, and exponent part are cut and converted.
- 1 . 3 5 0 3 4 1 2 0 2 3
5
APPLICATION
FUNCTIONS
(a) Decimal form
-1.35034
Single-precision real type
Cut
- 1 . 3 5 0 3 4 1 2 E - 1 0
STR_TO_REAL(_E)
(b) Exponential form
-1.35034E-10
Single-precision real type
Cut
(4) When a sign is not specified or '2BH' (+) is specified for a sign in decimal form, string type
data is converted as a positive value. When '2DH' (−) is specified for a sign, string type data
is converted as a negative value.
(5) When a sign is not specified or '2BH' (+) is specified for a sign of the exponent part in
exponential form, string type data is converted as a positive value.
When '2DH' (−) is specified for a sign of the exponential part, string type data is converted as
a negative value.
5.1 Type Conversion Functions
5.1.29 String type → single-precision real type conversion
5-85
STR_TO_REAL(_E)
(6) When '20H' (space) or '30H' (0) exists before the first 0 in string type data, the conversion is
executed ignoring '20H' and '30H'.
(a) Decimal form
-
0 1 . 3 5 0 3 4
-1.35034
Single-precision real type
Neglected
(b) Exponential form
-
0 1 . 3 5 0 3 4 E - 1 0
-1.35034E-10
Single-precision real type
Neglected
(7) When '30H (0)' exists between 'E' and a numeric value in string type data (exponential form),
the conversion is executed ignoring '30H'.
- 1 . 3 5 0 3 4 E - 0 2
-1.35034E-2
Single-precision real type
Ignored.
(8) When '20H' (space) exists in the character string, the conversion is executed ignoring '20H'.
(9) String type data can contain up to 24 characters.
'20H' (space) and '30H' (0) in the character string are counted as one character.
(10) The value to be input to s is string type data within the following range.
ASCII code: '30H' to '39H', '45H', '2BH', '2DH', '2EH', '20H', and '00H'
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-86
5.1 Type Conversion Functions
5.1.29 String type → single-precision real type conversion
STR_TO_REAL(_E)
Operation Error
An operation error occurs in the following cases.
• Any characters other than '30H' to '39H' exist in the integer or fractional part.
(Error code: 4100)
• Two or more 2EH exist.
(Error code: 4100)
• Any characters other than '45H'(E), '2BH'(+) or '45H'(E), '2DH'(−) exist in the exponent part,
or more than one exponent parts exist.
(Error code: 4100)
• The data after conversion is outside the range of -3.40282+38 to -1.17549-38, 0 or
1.17549-38 to 3.40282+38
(Error code: 4100)
• The number of characters is 0 or exceeding 24.
(Error code: 4100)
Program Example
The program which converts string type data input to
outputs the operation result from
d
s
into single-precision real type data, and
.
(a) Function without EN/ENO (STR_TO_REAL)
[Structured ladder/FBD]
5
[ST]
APPLICATION
FUNCTIONS
g_real1 := STR_TO_REAL (g_string1);
(b) Function with EN/ENO (STR_TO_REAL_E)
STR_TO_REAL(_E)
[Structured ladder/FBD]
[ST]
g_bool3 := STR_TO_REAL_E (g_bool1, g_string1, g_real1);
5.1 Type Conversion Functions
5.1.29 String type → single-precision real type conversion
5-87
STR_TO_WORD(_E), STR_TO_DWORD(_E)
5.1.30
String type → word (unsigned)/16-bit string, double word
(unsigned)/32-bit string type conversion
STR_TO_WORD(_E), STR_TO_DWORD(_E)
Basic
STR_TO_WORD(_E)
STR_TO_DWORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_WORD_E
EN
STR_TO_WORD_E
STR_TO_DWORD
STR_TO_DWORD_E
ENO:= STR_TO_WORD_E (EN, s, d);
ENO
s
STR_TO_WORD
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_STRING):
Input
:String (4)/(8)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string, double word
(unsigned)/32-bit string
Function
Operation processing
(1) STR_TO_WORD, STR_TO_WORD_E
Converts string type data input to
outputs the operation result from
5-88
into word (unsigned)/16-bit string type data, and
s
d
.
s
d
"0000"
0H
"0012"
12H
String type
Word (unsigned)/16-bit string type
5.1 Type Conversion Functions
5.1.30 String type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
STR_TO_WORD(_E), STR_TO_DWORD(_E)
(2) STR_TO_DWORD, STR_TO_DWORD_E
Converts the string type data input to
s
into double word (unsigned)/32-bit string type data,
and outputs the operation result from
d
.
s
d
"00000000"
0H
"00000012"
12H
String type
Double word (unsigned)/32-bit string type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
STR_TO_WORD(_E),
STR_TO_DWORD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.30 String type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
5-89
STR_TO_WORD(_E), STR_TO_DWORD(_E)
Operation Error
These functions consist of the following instructions.
STR_TO_WORD(_E) : HABIN
STR_TO_DWORD(_E) : DHABIN
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON,
and the corresponding error code is stored to SD0.
• The ASCII code for each number specified for
to 46H.
s
is outside the range of 30H to 39H, 41H
(Error code: 4100)
• The device specified s for exceeds the corresponding device range.
(For Universal model QCPU and LCPU)
(Error code: 4101)
Program Example
(1) The program which converts string type data input to
type data, and outputs the converted data from
d
s
into word (unsigned)/16-bit string
.
(a) Function without EN/ENO (STR_TO_WORD)
[Structured ladder/FBD]
[ST]
g_string1 :="0012";
g_word1 := STR_TO_WORD (g_string1);
(b) Function with EN/ENO (STR_TO_WORD_E)
[Structured ladder/FBD]
[ST]
g_string1 :="0012";
g_bool3 := STR_TO_WORD_E(g_bool1, g_string1, g_word1);
5-90
5.1 Type Conversion Functions
5.1.30 String type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
STR_TO_WORD(_E), STR_TO_DWORD(_E)
(2) The program which converts string type data input to
string type data, and outputs the operation result from
into double word (unsigned)/32-bit
s
d
.
(a) Function without EN/ENO (STR_TO_DWORD)
[Structured ladder/FBD]
[ST]
g_string1 :="00000012";
g_dword1 := STR_TO_DWORD (g_string1);
STR_TO_WORD(_E),
STR_TO_DWORD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.30 String type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
5-91
STR_TO_TIME(_E)
5.1.31
String type → time type conversion
STR_TO_TIME(_E)
Basic
STR_TO_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_TIME
STR_TO_ TIME _E
STR_TO_TIME_E
EN
ENO:= STR_TO_TIME_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_STRING):
Input
:String(11)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
Function
Operation processing
Converts string type data input to
from
5-92
d
s
into time type data, and outputs the operation result
.
s
d
"00000000"
0ms
"01234567"
T#20m34s567ms
String type
Time type
5.1 Type Conversion Functions
5.1.31 String type → time type conversion
STR_TO_TIME(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
This function consists of the following instruction.
STR_TO_TIME(_E) : DDABIN
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON,
and the corresponding error code is stored to SD0.
• The ASCII code for each number specified for
and 00H.
is outside of the range shown below.
(Error code: 4100)
5
APPLICATION
FUNCTIONS
s
is outside the range of 30H to 39H, 20H,
(Error code: 4100)
STR_TO_TIME(_E)
• The ASCII data specified for
-2147483648 to 4147483647
s
5.1 Type Conversion Functions
5.1.31 String type → time type conversion
5-93
STR_TO_TIME(_E)
Program Example
The program which converts string type data input to
operation result from
d
s
into time type data, and outputs the
.
(a) Function without EN/ENO (STR_TO_TIME)
[Structured ladder/FBD]
[ST]
g_string1 :="01234567";
g_time1 := STR_TO_TIME (g_string1);
(b) Function with EN/ENO (STR_TO_TIME_E)
[Structured ladder/FBD]
[ST]
g_string1 :="01234567";
g_bool3 := STR_TO_TIME_E (g_bool1, g_string1, g_time1);
5-94
5.1 Type Conversion Functions
5.1.31 String type → time type conversion
STR_TO_BCD(_E)
5.1.32
String type → BCD type conversion
STR_TO_BCD(_E)
Basic
STR_TO_BCD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
STR_TO_BCD
STR_TO_ BCD _E
STR_TO_BCD_E
EN
ENO:= STR_TO_BCD_E (EN, s, d);
ENO
s
d
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_STRING):
Input
:String (8)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY BIT
5
APPLICATION
FUNCTIONS
Input argument,
Function
(1) When word (unsigned)/16-bit string type is specified for output argument.
(a) Converts string type 4-character-string data input to
the operation result from
d
s
into BCD type data, and outputs
.
s
d
'9999'
9999H
String type
Word (unsigned)/16-bit string type
(b) When '20H' (space) exists in the character string, the conversion is executed ignoring
'20H'.
(c) '20H' (space) and '30H' (0) in the character string are counted as one character.
(d) The value to be input to s is string type data within the following range.
ASCII code: '30H' to '39H', '20H', and '00H'
5.1 Type Conversion Functions
5.1.32 String type → BCD type conversion
5-95
STR_TO_BCD(_E)
Operation processing
STR_TO_BCD(_E)
(e) When input character string has less than 4 letters, convert it with 4 letters
supplementing with 0 to the end of the character string. Therefore, when converting
character string ("0001" for "1") with less than 4 letters to BCD data, input the zero
padding character strings.
(f)
When the character string has more than 4 letters, the conversion target is the forth
character from the left of the character string data.
Entered character string
Converted character string
Output (BCD type)
"1"
"1000"
1000H(4096)
"12"
"1200"
1200H(4608)
"123"
"1230"
1230H(4656)
"1234"
"1234"
1230H(4656)
"12345"
"1234"
1230H(4656)
(2) When double word (unsigned)/32-bit string type is specified for output argument.
(a) Converts string type 8-character-string data input to
the operation result from
d
s
into BCD type data, and outputs
.
s
d
"99999999"
99999999H
String type
Double word (unsigned)/32-bit string type
(b) When '20H' (space) exists in the character string, the conversion is executed ignoring
'20H'.
(c) '20H' (space) and '30H' (0) in the character string are counted as one character.
(d) The value to be input to s is string type data within the following range.
ASCII code: '30H' to '39H', '20H', and '00H'
(3) Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type can be specified for
s
.
Bit type cannot be specified.
Output from d cannot be used with connecting to input of function and operator
in double word (unsigned)/32-bit string type. In this case, use the DDABCD
instruction.
5-96
5.1 Type Conversion Functions
5.1.32 String type → BCD type conversion
STR_TO_BCD(_E)
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
An operation error occurs in the following cases.
• The input character string is outside the range of ASCII code '30H' to '39H', "20H", and
"00H".
(Error code 4100)
STR_TO_BCD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.32 String type → BCD type conversion
5-97
STR_TO_BCD(_E)
Program Example
(1) The program which converts string type data input to
operation result from
d
s
into BCD type data, and outputs the
.
(a) Function without EN/ENO (STR_TO_BCD)
[Structured ladder/FBD]
[ST]
g_string1:="0012";
g_word1 := STR_TO_BCD (g_string1);
(b) Function without EN/ENO (STR_TO_BCD_E)
[Structured ladder/FBD]
[ST]
g_string1:="0012";
g_bool3 := STR_TO_BCD_E (g_bool1, g_string1, g_word1);
5-98
5.1 Type Conversion Functions
5.1.32 String type → BCD type conversion
STR_TO_BCD(_E)
(2) The program which converts string type data input to
s
into BCD type data in double word
(unsigned)/32-bit string type data, and outputs the operation result from
d
.
(a) Function without EN/ENO (STR_TO_BCD)
[Structured ladder/FBD]
[ST]
g_string1:="00000012";
g_dword1 := STR_TO_BCD (g_string1);
(b) Function without EN/ENO (STR_TO_BCD_E)
[Structured ladder/FBD]
5
[ST]
STR_TO_BCD(_E)
APPLICATION
FUNCTIONS
g_string1:="00000012";
g_bool3 := STR_TO_BCD_E (g_bool1, g_string1, g_dword1);
5.1 Type Conversion Functions
5.1.32 String type → BCD type conversion
5-99
BCD_TO_INT(_E), BCD_TO_DINT(_E)
5.1.33
BCD type → word (signed), double word (signed) type conversion
BCD_TO_INT(_E), BCD_TO_DINT(_E)
High
performance
Basic
BCD_TO_INT(_E)
BCD_TO_DINT(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BCD_TO_INT_E
EN
BCD_TO_INT_E
BCD_TO_DINT
BCD_TO_DINT_E
ENO:= BCD_TO_INT_E (EN, s, d);
ENO
s
BCD_TO_INT
d
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_BCD):
Input
:Word (unsigned)/16-bit string, double word
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (signed), double word (signed)
(unsigned)/32-bit string
Output argument,
Function
Operation processing
(1) BCD_TO_INT, BCD_TO_INT_E
(a) Converts BCD type data input to
operation result from
d
s
d
9999H
9999
Word (unsigned)/16-bit string type
Word (signed) type
1
0
0
1
1
400
200
100
80
40
20
10
8
4
2
1
0
0
1
1
0
0
1
1
0
0
1
Thousands place Hundreds place
3276816384 8192 4096 2048 1024 512
9999
into word (signed) type data, and outputs the
.
8000 4000 2000 1000 800
9999H
s
0
0
1
0
0
1
1
Tens place
INT conversion
Units place
256
128
64
32
16
8
4
2
1
1
0
0
0
0
1
1
1
1
Always filled with 0s.
(b) The value to be input to s is word (unsigned)/16-bit string type data within the range
from 0H to 9999H (0 to 9 for each digit).
5-100
5.1 Type Conversion Functions
5.1.33 BCD type → word (signed), double word (signed) type conversion
BCD_TO_INT(_E), BCD_TO_DINT(_E)
(2) BCD_TO_DINT, BCD_TO_DINT_E
(a) Converts BCD type data input to
the operation result from
d
s
into double word (signed) type data, and outputs
.
• When word (unsigned)/16-bit string is specified for
s
Word (unsigned)/16-bit string type
Double word (signed) type
×
×
×
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
×
100
9999
101
9999H
102
d
103
s
9999H
1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Thousands Hundreds Tens
place
place
place
Units
place
231
230
229
228
227
226
225
224
223
222
221
220
219
218
217
216
215
214
213
212
211
210
29
28
27
26
25
24
23
22
21
20
DINT conversion
9999
0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1
Always filled with 0s.
• When double word (unsigned)/32-bit string is specified for
s
×
×
100
×
101
×
102
×
103
×
×
5
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
8
4
2
1
×
104
Double word (signed) type
105
Double word (unsigned)/32-bit string type
106
d
99999999
107
s
99999999H
1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Millions Hundred
place
thousands
place
Ten
Thousands Hundreds Tens
thousands place
place
place
place
Units
place
DINT conversion
231
230
229
228
227
226
225
224
223
222
221
220
219
218
217
216
215
214
213
212
211
210
29
28
27
26
25
24
23
22
21
20
Ten
millions
place
APPLICATION
FUNCTIONS
99999999H
99999999
0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1
(b) The value to be input to s is word (unsigned)/16-bit string type data within the range
from 0H to 9999H (0 to 9 for each digit), double word (unsigned)/32-bit string type data
within the range from 0H to 99999999H (0 to 9 for each digit).
(c) Word (unsigned)/16-bit string, double word (unsigned)/32-bit string type can be
specified for
d
. Bit type cannot be specified.
5.1 Type Conversion Functions
5.1.33 BCD type → word (signed), double word (signed) type conversion
5-101
BCD_TO_INT(_E),
BCD_TO_DINT(_E)
Always filled with 0s.
BCD_TO_INT(_E), BCD_TO_DINT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
These functions consist of the following common instructions.
BCD_TO_INT(_E) : BIN
BCD_TO_DINT(_E) : BIN, WAND
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON,
and the corresponding error code is stored to SD0.
• Values other than 0 to 9 are specified for each digit of
(Error code: 4100)
s
.
The error above can be suppressed by turning ON SM722.
However, the instruction is not executed regardless of whether SM722 is turned ON or
OFF if the specified value is out of the available range.
For the BINP and DBINP instruction, the next operation will not be performed until the
command (executing condition) is turned from OFF to ON regardless of the presence or
absence of an error.
5-102
5.1 Type Conversion Functions
5.1.33 BCD type → word (signed), double word (signed) type conversion
BCD_TO_INT(_E), BCD_TO_DINT(_E)
Program Example
(1) The program which converts BCD type data input to
outputs the operation result from
d
s
into word (signed) type data, and
.
(a) Function without EN/ENO (BCD_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1 := BCD_TO_INT (g_word1);
(b) Function with EN/ENO (BCD_TO_INT_E)
[Structured ladder/FBD]
[ST]
(2) The program which converts BCD type data input to
and outputs the operation result from
d
s
into double word (signed) type data,
.
(a) Function without EN/ENO (BCD_TO_DINT)
APPLICATION
FUNCTIONS
5
g_bool3 := BCD_TO_INT_E (g_bool1, g_word1, g_int1);
BCD_TO_INT(_E),
BCD_TO_DINT(_E)
[Structured ladder/FBD]
[ST]
g_dint1 := BCD_TO_DINT (g_dword1);
5.1 Type Conversion Functions
5.1.33 BCD type → word (signed), double word (signed) type conversion
5-103
BCD_TO_STR(_E)
5.1.34
BCD type → string type conversion
BCD_TO_STR(_E)
Basic
BCD_TO_STR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
BCD_TO_STR
BCD_TO_STR_E
BCD_TO_STR_E
EN
ENO:= BCD_TO_STR_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_BCD):
Input
ANY_BIT
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (8)
:Bit
Function
Operation processing
(1) Converts BCD type data input to
from
d
s
into string type data, and outputs the operation result
.
(a) When word (unsigned)/16-bit string type is specified for
s
d
9999H
"9999"
Word (unsigned)/16-bit string type
String type
s
.
(b) When double word (unsigned)/32-bit string type is specified for
s
d
99999999H
"99999999"
Double word(unsigned)/32-bit string type
String type
s
.
(2) Word (unsigned)/16-bit string type, double word (unsigned)/32-bit string type data can be
specified for
d
. Bit type cannot be specified.
(3) When SM701 (signal for switching the number of output characters) is OFF, "00H" is stored
to the end of the character string.
5-104
5.1 Type Conversion Functions
5.1.34 BCD type → string type conversion
BCD_TO_STR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
These functions consist of the following common instructions.
When word (unsigned)/16-bit string type is specified for
s
: BCDDA
When double word (unsigned)/32-bit string type is specified for
: DBCDDA
d
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON,
and the corresponding error code is stored to SD0.
s
,
s
is outside the range of 0 to
(Error code: 4100)
• When double word (unsigned)/32-bit string type is specified for
range of 0 to 99999999.
s
,
s
(Error code:4101)
5
BCD_TO_STR(_E)
• The device specified for d exceeds the corresponding device range.
(For Universal model QCPU and LCPU)
is outside the
(Error code: 4100)
APPLICATION
FUNCTIONS
• When word (unsigned)/16-bit string type is specified for
9999.
5.1 Type Conversion Functions
5.1.34 BCD type → string type conversion
5-105
BCD_TO_STR(_E)
Program Example
(1) The program which converts word (unsigned)/16-bit string type data input to
type data, and outputs the operation result from
d
s
into string
.
(a) Function without EN/ENO (BCD _TO_STR)
[Structured ladder/FBD]
[ST]
g_string1 := BCD_TO_STR (g_word1);
(b) Function with EN/ENO (BCD_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := BCD_TO_STR_E (g_bool1, g_word1, g_string1);
(2) The program which converts double word (unsigned)/32-bit string type data input to
string type data, and outputs the operation result from
d
.
(a) Function without EN/ENO (BCD _TO_STR)
[Structured ladder/FBD]
[ST]
g_string1 := BCD_TO_STR (g_dword1);
(b) Function with EN/ENO (BCD_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := BCD_TO_STR_E (g_bool1, g_dword1, g_string1);
5-106
5.1 Type Conversion Functions
5.1.34 BCD type → string type conversion
s
into
TIME_TO_BOOL(_E)
5.1.35
Time type → bit type conversion
TIME_TO_BOOL(_E)
Basic
TIME_TO_BOOL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TIME_TO_BOOL
TIME_TO_BOOL_E
TIME_TO_BOOL_E
EN
ENO:= TIME_TO_BOOL_E (EN, s, d);
ENO
s
d
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_TIME):
Input
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Bit
5
APPLICATION
FUNCTIONS
Output argument,
EN:
Function
Converts time type data input to
s
into bit type data, and outputs the operation result from
.
When the input value is 0ms, FALSE is output in bit type data.
When the input value is other than 0ms, TRUE is output in bit type data.
d
s
d
T#0ms
FALSE
T#20m34s567ms
TRUE
Time type
Bit type
5.1 Type Conversion Functions
5.1.35 Time type → bit type conversion
5-107
TIME_TO_BOOL(_E)
Operation processing
TIME_TO_BOOL(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the TIME_TO_BOOL(_E) function.
Program Example
The program which converts time type data input to
operation result from
d
s
into bit type data, and outputs the
.
(a) Function without EN/ENO (TIME_TO_BOOL)
[Structured ladder/FBD]
[ST]
g_bool1 := TIME_TO_BOOL (g_time1);
(b) Function with EN/ENO (TIME_TO_BOOL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := TIME_TO_BOOL_E (g_bool1, g_time1, g_bool2);
5-108
5.1 Type Conversion Functions
5.1.35 Time type → bit type conversion
TIME_TO_INT(_E), TIME_TO_DINT(_E)
5.1.36
Time type → word (signed), double word (signed) type
conversion
TIME_TO_INT(_E), TIME_TO_DINT(_E)
Basic
TIME_TO_INT(_E)
TIME_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TIME_TO_INT_E
EN
TIME _TO_INT_E
TIME _TO_DINT
TIME _TO_DINT_E
ENO:= TIME_TO_INT_E (EN, s, d);
ENO
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_TIME):
Input
:Time
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
5
:Word (signed), double word (signed)
Function
TIME_TO_INT(_E),
TIME_TO_DINT(_E)
Operation processing
(1) TIME_TO_INT, TIME _TO_INT_E
(a) Converts time type data input to
operation result from
d
s
into word (signed) type data, and outputs the
.
s
d
T#1s234ms
1234
Time type
Word (signed) type
(b) When converting to word (signed) type data, high-order 16-bit (1 word) data of time type
is discarded.
5.1 Type Conversion Functions
5.1.36 Time type → word (signed), double word (signed) type conversion
APPLICATION
FUNCTIONS
s
TIME_TO_INT
5-109
TIME_TO_INT(_E), TIME_TO_DINT(_E)
(2) TIME _TO_DINT, TIME _TO_DINT_E
Converts time type data input to
operation result from
d
s
into double word (signed) type data, and outputs the
.
s
d
20m34s567ms
1234567
Time type
Double word (signed) type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-110
5.1 Type Conversion Functions
5.1.36 Time type → word (signed), double word (signed) type conversion
TIME_TO_INT(_E), TIME_TO_DINT(_E)
Operation Error
No operation error occurs in the execution of the TIME_TO_INT(_E) and
TIME_TO_DINT(_E) functions.
Program Example
(1) The program which converts time type data input to
outputs the operation result from
d
s
into word (signed) type data, and
.
(a) Function without EN/ENO (TIME _TO_INT)
[Structured ladder/FBD]
[ST]
g_int1 := TIME_TO_INT (g_time1);
(b) Function with EN/ENO (TIME_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := TIME_TO_INT_E (g_bool1, g_time1, g_int1);
(2) The program which converts time type data input to
and outputs the operation result from
d
s
into double word (signed) type data,
.
(a) Function without EN/ENO (TIME _TO_DINT)
[Structured ladder/FBD]
[ST]
g_dint1 := TIME_TO_DINT (g_time1);
5.1 Type Conversion Functions
5.1.36 Time type → word (signed), double word (signed) type conversion
5-111
TIME_TO_INT(_E),
TIME_TO_DINT(_E)
APPLICATION
FUNCTIONS
5
TIME_TO_STR(_E)
5.1.37
Time type → string type conversion
TIME_TO_STR(_E)
Basic
TIME_TO_STR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TIME_TO_STR
TIME _TO_STR_E
TIME_TO_STR_E
EN
ENO:= TIME_TO_STR_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_TIME):
Input
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (11)
Function
Operation processing
(1) Converts time type data input to
from
d
s
into string type data, and outputs the operation result
.
s
d
T#20m34s567ms
"
Time type
1234567"
String type
s
d
T#-20m34s567ms
"-
Time type
1234567"
String type
(2) When SM701 (signal for switching the number of output characters) is OFF, "00H" is stored
to the end of the character string.
(3) The operation results stored to
d
are as follows.
(a) For the first character, 20H (space) is stored if the BIN data is positive, and 2DH (-) is
stored if it is negative.
(b) 20H (space) is stored to the left of significant figures.
5-112
5.1 Type Conversion Functions
5.1.37 Time type → string type conversion
TIME_TO_STR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
FALSE
d
Operation output value
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
These functions consist of the following common instructions.
TIME_TO_STR(_E):DBINDA
In any of the following cases, an operation error occurs, the error flag (SM0) is turned ON,
and the corresponding error code is stored to SD0.
• The device specified for exceeds the corresponding device range.
(For Universal model QCPU and LCPU)
(Error code:4101)
Program Example
5
operation result from
d
s
into string type data, and outputs the
APPLICATION
FUNCTIONS
The program which converts time type data input to
.
(a) Function without EN/ENO (TIME_TO_STR)
TIME_TO_STR(_E)
[Structured ladder/FBD]
[ST]
g_string1 := TIME_TO_STR (g_time1);
(b) Function with EN/ENO (TIME_TO_STR_E)
[Structured ladder/FBD]
[ST]
g_bool3 := TIME_TO_STR_E (g_bool1, g_time1, g_string1);
5.1 Type Conversion Functions
5.1.37 Time type → string type conversion
5-113
TIME_TO_WORD(_E), TIME_TO_DWORD(_E)
5.1.38
Time type → word (unsigned)/16-bit string, double word
(unsigned)/32-bit string type conversion
TIME_TO_WORD(_E), TIME_TO_DWORD(_E)
Basic
TIME_TO_WORD(_E)
TIME_TO_DWORD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TIME_TO_WORD_E
EN
TIME _TO_WORD_E
TIME _TO_DWORD
TIME _TO_DWORD_E
ENO:= TIME_TO_WORD_E (EN, s, d);
ENO
s
TIME_TO_WORD
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_TIME):
Input
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Word (unsigned)/16-bit string, double word
(unsigned)/32-bit string
Function
Operation processing
(1) TIME_TO_WORD, TIME _TO_WORD_E
Converts time type data input to
the operation result from
d
s
into word (unsigned)/16-bit string type data, and outputs
.
s
d
T#1s234ms
1234H
Time type
Word (unsigned)/16-bit string type
(2) When converting to word (unsigned)/16-bit string type data, high-order 16-bit (1 word) data
is discarded.
5-114
5.1 Type Conversion Functions
5.1.38 Time type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
TIME_TO_WORD(_E), TIME_TO_DWORD(_E)
(3) TIME _TO_DWORD, TIME _TO_DWORD_E
Converts time type data input to
outputs the operation result from
s
d
into double word (unsigned)/32-bit string type data, and
.
s
d
T#20m34s567ms
1234567H
Time type
Double word (unsigned)/32-bit string type
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
FALSE
d
Operation output value
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
TIME_TO_WORD(_E),
TIME_TO_DWORD(_E)
APPLICATION
FUNCTIONS
5
5.1 Type Conversion Functions
5.1.38 Time type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
5-115
TIME_TO_WORD(_E), TIME_TO_DWORD(_E)
Operation Error
No operation error occurs in the execution of the TIME_TO_WORD(_E) and
TIME_TO_DWORD(_E) functions.
Program Example
(1) The program which converts time type data input to
type data, and outputs the operation result from
d
s
into word (unsigned)/16-bit string
.
(a) Function without EN/ENO (TIME _TO_WORD)
[Structured ladder/FBD]
[ST]
g_word1 := TIME_TO_WORD (g_time1);
(b) Function with EN/ENO (TIME_TO_WORD_E)
[Structured ladder/FBD]
[ST]
g_bool3 := TIME_TO_WORD_E (g_bool1, g_time1, g_word1);
(2) The program which converts time type data input to
s
string type data, and outputs the operation result from
into double word (unsigned)/32-bit
d
.
(a) Function without EN/ENO (TIME _TO_DWORD)
[Structured ladder/FBD]
[ST]
g_dword1 := TIME_TO_DWORD (g_time1);
5-116
5.1 Type Conversion Functions
5.1.38 Time type → word (unsigned)/16-bit string, double word (unsigned)/32-bit string type conversion
BITARR_TO_INT(_E), BITARR_TO_DINT(_E)
5.1.39
Bit array → word (signed) type, word (unsigned)/16-bit string
type, double word (signed) type, double word (unsigned)/32-bit
string type conversion
BITARR_TO_INT(_E), BITARR_TO_DINT(_E)
Basic
BITARR_TO_INT(_E)
BITARR_TO_DINT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
BITARR_TO_INT_E
EN
ENO
s
functions.
BITARR_TO_INT
BITARR_TO_INT_E
BITARR_TO_DINT
BITARR_TO_DINT_E
ENO:= BITARR_TO_INT_E (EN, s, n, d);
d
n
5
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s(_BitArr):
Input (Variables are applicable to element specification.)
:Bit
n:
Input (Only a constant 4, 8, 12, 16, 20, 24, 28 or 32 can be
:Word (signed)
:Bit
APPLICATION
FUNCTIONS
Input argument,
specified)
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
:ANY16, ANY32
BITARR_TO_INT(_E),
BITARR_TO_DINT(_E)
Output argument,
Function
Operation processing
(1) BITARR_TO_INT, BITARR_TO_INT_E
Converts number of bits specified for n starting from the bit array element input to s into
word (signed) type or word (unsigned)/16-bit string type data, and outputs the operation
result from d .
Only a constant 4, 8, 12 or 16 can be specified for n.
0 is set for the output bits higher than the specified number of bits.
(2) BITARR_TO_DINT, BITARR_TO_DINT_E
Converts number of bits specified for n starting from the bit array element input to s into
double word (signed) type or double word (unsigned)/32-bit string type data, and outputs the
operation result from d .
Only a constant 4, 8, 12, 16, 20, 24, 28 or 32 can be specified for n.
0 is set for the output bits higher than the specified number of bits.
5.1 Type Conversion Functions
5.1.39 Bit array → word (signed) type, word (unsigned)/16-bit string type, double word (signed) type, double word (unsigned)/32-bit string type conversion
5-117
BITARR_TO_INT(_E), BITARR_TO_DINT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
FALSE
d
Operation output value
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the BITARR_TO_INT(_E) and
BITARR_TO_DINT(_E) functions.
Program Example
The program which converts 8 bits from 0 of bit array input to
and outputs the operation result from
d
s
into word (signed) type data,
.
(a) Function without EN/ENO (BITARR_TO_INT)
[Structured ladder/FBD]
[ST]
g_int1 := BITARR_TO_INT(g_bool4[0], 8);
(b) Function with EN/ENO (BITARR_TO_INT_E)
[Structured ladder/FBD]
[ST]
g_bool2 := BITARR_TO_INT_E(g_bool1, g_bool4[0], 8, g_int1);
5-118
5.1 Type Conversion Functions
5.1.39 Bit array → word (signed) type, word (unsigned)/16-bit string type, double word (signed) type, double word (unsigned)/32-bit string type conversion
INT_TO_BITARR(_E), DINT_TO_BITARR(_E)
5.1.40
Word (signed) type, word (unsigned)/16-bit string type, double
word (signed) type, double word (unsigned)/32-bit string type
→ bit array conversion
INT_TO_BITARR(_E), DINT_TO_BITARR(_E)
Basic
INT_TO_BITARR(_E)
DINT_TO_BITARR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
INT_TO_BITARR_E
EN
ENO
s
functions.
INT_TO_BITARR
INT_TO_BITARR_E
DINT_TO_BITARR
DINT_TO_BITARR_E
ENO:= INT_TO_BITARR_E (EN, s, n, d);
d
n
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s:
Input
:ANY16, ANY32
n:
Input (Only a constant 4, 8, 12, 16, 20, 24, 28 or 32 can be
:Word (signed)
APPLICATION
FUNCTIONS
5
specified)
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d(_BitArr):
Output (Variables are applicable to element specification.)
:Bit
INT_TO_BITARR(_E),
DINT_TO_BITARR(_E)
Output argument,
Function
Operation processing
(1) INT_TO_BITARR, INT_TO_BITARR_E
Outputs low-order n bits of word (signed) type or word (unsigned)/16-bit string type data
specified for s to d .
Only a constant 4, 8, 12 or 16 can be specified for n.
The output bits higher than the specified number of bits do not change.
(2) DINT_TO_BITARR, DINT_TO_BITARR_E
Outputs low-order n bits of double word (signed) type or double word (unsigned)/32-bit string
type data specified for s to d .
Only a constant 4, 8, 12, 16, 20, 24, 28 or 32 can be specified for n.
The output bits higher than the specified number of bits do not change.
5.1 Type Conversion Functions
5.1.40 Word (signed) type, word (unsigned)/16-bit string type, double word (signed) type, double word (unsigned)/32-bit string type → bit array conversion
5-119
INT_TO_BITARR(_E), DINT_TO_BITARR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
FALSE
d
Operation output value
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the INT_TO_BITARR(_E) and
DINT_TO_BITARR(_E) functions.
Program Example
The program which outputs low-order 4 bits of word (signed) type data input to
s
to
d
.
(a) Function without EN/ENO (INT_TO_BITARR)
[Structured ladder/FBD]
[ST]
g_bool4[0] := INT_TO_BITARR(g_int1, 4);
(b) Function with EN/ENO (INT_TO_BITARR_E)
[Structured ladder/FBD]
[ST]
g_bool2 := INT_TO_BITARR_E(g_bool1, g_int1, 4, g_bool4[0]);
5-120
5.1 Type Conversion Functions
5.1.40 Word (signed) type, word (unsigned)/16-bit string type, double word (signed) type, double word (unsigned)/32-bit string type → bit array conversion
CPY_BITARR(_E)
5.1.41
Bit array copy
CPY_BITARR(_E)
High
performance
Basic
CPY_BITARR(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
CPY_BITARR
CPY_BITARR_E
EN
ENO
s
CPY_BITARR_E
ENO:= CPY_BITARR_E (EN, s, n, d);
d
n
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_BitArrIn):
Input
:Bit
n:
Input (Only a constant 4, 8, 12, 16, 20, 24, 28 or 32 can be
:Word (signed)
5
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d(_BitArrOut):
Output
APPLICATION
FUNCTIONS
specified)
Output argument,
:Bit
Function
Outputs n bits of bit array input to
s
to
d
CPY_BITARR(_E)
Operation processing
.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
FALSE
d
Operation output value
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.1 Type Conversion Functions
5.1.41 Bit array copy
5-121
CPY_BITARR(_E)
Operation Error
No operation error occurs in the execution of the CPY_BITARR(_E) function.
Program Example
The program which outputs 12 bits from num1 element of bit string input to
following bits of
d
s
to num2 and the
.
(a) Function without EN/ENO (CPY_BITARR)
[Structured ladder/FBD]
[ST]
g_bool5[num2] := CPY_BITARR(g_bool4[num1], 12);
(b) Function with EN/ENO (CPY_BITARR_E)
[Structured ladder/FBD]
[ST]
g_bool2 := CPY_BITARR_E(g_bool1, g_bool4[num1], 12, g_bool5[num2]);
5-122
5.1 Type Conversion Functions
5.1.41 Bit array copy
GET_BIT_OF_INT(_E)
5.1.42
Specified bit read of word (signed) type data
GET_BIT_OF_INT(_E)
Basic
GET_BIT_OF_INT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
GET_BIT_OF_INT
GET_BIT_OF_INT_E
EN
ENO
s
GET_BIT_OF_INT_E
ENO:= GET_BIT_OF_INT_E (EN, s, n, d);
d
n
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s:
Input
:Word (signed)
n:
Input (Only a constant between 0 and 15 can be specified)
:Word (signed)
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
5
:Bit
APPLICATION
FUNCTIONS
Input argument,
Function
Reads a value of nth bit of
s
, and outputs the operation result from
d
GET_BIT_OF_INT(_E)
Operation processing
.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE *1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.1 Type Conversion Functions
5.1.42 Specified bit read of word (signed) type data
5-123
GET_BIT_OF_INT(_E)
Operation Error
No operation error occurs in the execution of the GET_BIT_OF_INT(_E) function.
Program Example
The program which reads a value of 5th bit of data input to
result from
d
s
, and outputs the operation
.
(a) Function without EN/ENO (GET_BIT_OF_INT)
[Structured ladder/FBD]
[ST]
g_bool3 := GET_BIT_OF_INT(g_int1, 5);
(b) Function with EN/ENO (GET_BIT_OF_INT_E)
[Structured ladder/FBD]
[ST]
g_bool2 := GET_BIT_OF_INT_E(g_bool1, g_int1, 5, g_bool3);
5-124
5.1 Type Conversion Functions
5.1.42 Specified bit read of word (signed) type data
SET_BIT_OF_INT(_E)
5.1.43
Specified bit write of word (signed) type data
SET_BIT_OF_INT(_E)
Basic
SET_BIT_OF_INT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
SET_BIT_OF_INT
SET_BIT_OF_INT_E
EN
ENO
s
SET_BIT_OF_INT_E
ENO:= SET_BIT_OF_INT_E (EN, s, n, d);
d
n
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s:
Input
:Bit
n:
Input (Only a constant between 0 and 15 can be specified)
:Word (signed)
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
5
:Word (signed)
APPLICATION
FUNCTIONS
Input argument,
Function
Writes a value specified for
to the nth bit of
s
d
SET_BIT_OF_INT(_E)
Operation processing
.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
d
Operation output value
FALSE
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.1 Type Conversion Functions
5.1.43 Specified bit write of word (signed) type data
5-125
SET_BIT_OF_INT(_E)
Operation Error
No operation error occurs in the execution of the SET_BIT_OF_INT(_E) function.
Program Example
The program which writes a value specified for
s
to the 3rd bit of
(a) Function without EN/ENO (SET_BIT_OF_INT)
[Structured ladder/FBD]
[ST]
g_int3 := SET_BIT_OF_INT(g_bool1, 3);
(b) Function with EN/ENO (SET_BIT_OF_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := SET_BIT_OF_INT_E(g_bool2, g_bool1, 3, g_int3);
5-126
5.1 Type Conversion Functions
5.1.43 Specified bit write of word (signed) type data
d
.
CPY_BIT_OF_INT(_E)
5.1.44
Specified bit copy of word (signed) type data
CPY_BIT_OF_INT(_E)
Basic
CPY_BIT_OF_INT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
CPY_BIT_OF_INT
CPY_BIT_OF_INT_E
EN
ENO
s
CPY_BIT_OF_INT_E
ENO:= CPY_BIT_OF_INT_E (EN, s, n1, n2, d);
d
n1
n2
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s:
Input
:Word (signed)
n1:
Input (Only a constant between 0 and 15 can be specified)
:Word (signed)
n2:
Input (Only a constant between 0 and 15 can be specified)
:Word (signed)
ENO:
Execution result (TRUE: Normal execution, FALSE: Error or stop) :Bit
d:
Output
5
APPLICATION
FUNCTIONS
Input argument,
:Word (signed)
CPY_BIT_OF_INT(_E)
Function
Operation processing
Copies a value of (n1)th bit of input
s
to the (n2)th bit of output
d
.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
d
Operation output value
FALSE
*1
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.1 Type Conversion Functions
5.1.44 Specified bit copy of word (signed) type data
5-127
CPY_BIT_OF_INT(_E)
Operation Error
No operation error occurs in the execution of the CPY_BIT_OF_INT(_E) function.
Program Example
The program which writes a value of 5th bit of
s
to the 3rd bit of
d
(a) Function without EN/ENO (CPY_BIT_OF_INT)
[Structured ladder/FBD]
[ST]
g_int3 := CPY_BIT_OF_INT(g_int1, 5, 3);
(b) Function with EN/ENO (CPY_BIT_OF_INT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := CPY_BIT_OF_INT_E(g_bool2, g_int1, 5, 3, g_int3);
5-128
5.1 Type Conversion Functions
5.1.44 Specified bit copy of word (signed) type data
.
GET_BOOL_ADDR, GET_INT_ADDR, GET_WORD_ADDR
5.1.45
Nonessential type conversion
GET_BOOL_ADDR, GET_INT_ADDR, GET_WORD_ADDR
Basic
High
performance
Universal
L CPU
GET_BOOL_ADDR
GET_INT_ADDR
GET_WORD_ADDR
indicates any of the following
Structured ladder/FBD
functions.
ST
GET_BOOL_ADDR
GET_INT_ADDR
GET_BOOL_ADDR
s
GET_WORD_ADDR
ENO:= GET_BOOL_ADDR (s, d);
d
Input argument,
s:
Input
: ANY
Output argument,
d:
Output
: Bit, word (signed), word (unsigned)/16-bit string
5
Function
(1) Outputs data type of
Function name
GET_BOOL_ADDR
s
as data type of
d
APPLICATION
FUNCTIONS
Operation processing
.
Input data type
Output data type
Bit
Bit
Array of bit
GET_BOOL_ADDR,
GET_INT_ADDR,
GET_WORD_ADDR
Word (signed)
Double word (signed)
GET_INT_ADDR
Word (unsigned)/16-bit string
Word (signed)
Single-precision real number
String
Time type
Array of word (signed)
Array of double word (signed)
GET_WORD_ADDR
Array of word (unsigned)/16-bit string
Array of double word (unsigned)/32-bit string
Word (unsigned)/16-bit string
Array of real number
Array of time type
(2) Rounding error may occur when specifying the input value to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5.1 Type Conversion Functions
5.1.45 Nonessential type conversion
5-129
GET_BOOL_ADDR, GET_INT_ADDR, GET_WORD_ADDR
Operation result
An operation is executed and the operation value is output from
d
.
Operation Error
No operation error occurs in the execution of the GET_BOOL_ADDR, GET_INT_ADDR, and
GET_WORD_ADDR functions.
Program Example
The program which directly handles 32-bit input variable Var_D10 as 16-bit input data
without the type conversion.
GET_INT_ADDR
[Structured ladder/FBD]
[ST]
Var_D100 := GET_INT_ADDR(Var_D10);
5-130
5.1 Type Conversion Functions
5.1.45 Nonessential type conversion
ABS(_E)
5.2 Standard Functions of One Numeric Variable
5.2.1
Absolute value
ABS(_E)
Basic
ABS(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
ABS
ABS_E
ABS_E
EN
ENO:= ABS_E (EN, s, d);
ENO
s
d
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_IN):
Input
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_NUM
APPLICATION
FUNCTIONS
5
Function
(1) Outputs the absolute value of word (signed), double word (signed), single-precision real or
double-precision real type data input to
s
from
d
in the same data type as that of
s
.
Assuming that the input value is A and the operation output value is B, the relationship is
expressed by the following equality.
B= A
(2) The value to be input to s is word (signed), double word (signed), single-precision real or
double-precision real type data.
(3) When the data type of
output from
d
s
is word (signed) type and the input value is -32768, -32768 is
s
is double word (signed) type and the input value is -2147483648,
.
When the data type of
-2147483648 is output from d .
(No operation error occurs. In case of ABS_E, TRUE is output from ENO.)
5.2 Standard Functions of One Numeric Variable
5.2.1 Absolute value
5-131
ABS(_E)
Operation processing
ABS(_E)
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-132
5.2 Standard Functions of One Numeric Variable
5.2.1 Absolute value
ABS(_E)
Operation Error
No operation error occurs in the execution of the ABS(_E) function.
Program Example
(1) The program which outputs the absolute value of word (signed) type data input to
d
in the same data type as that of
s
s
from
.
(a) Function without EN/ENO (ABS)
[Structured ladder/FBD]
[ST]
g_int2:= ABS(g_int1);
(b) Function with EN/ENO (ABS_E)
[Structured ladder/FBD]
[ST]
g_bool3 := ABS_E(g_bool1, g_int1, g_int2);
(2) The program which outputs the absolute value of double word (signed) type data input to
from
d
in the same data type as that of
s
s
.
APPLICATION
FUNCTIONS
5
(a) Function without EN/ENO (ABS)
ABS(_E)
[Structured ladder/FBD]
[ST]
g_dint2:= ABS(g_dint1);
(b) Function with EN/ENO (ABS_E)
[Structured ladder/FBD]
[ST]
g_bool2 := ABS_E(g_bool1, g_dint1, g_dint2);
5.2 Standard Functions of One Numeric Variable
5.2.1 Absolute value
5-133
ABS(_E)
(3) The program which outputs the absolute value of single-precision real type data input to
from
d
in the same data type as that of
s
s
.
(a) Function without EN/ENO (ABS)
[Structured ladder/FBD]
[ST]
g_real2:= ABS(g_real1);
(b) Function with EN/ENO (ABS_E)
[Structured ladder/FBD]
[ST]
g_bool2 := ABS_E(g_bool1, g_real1, g_real2);
(4) The program which outputs the absolute value of double-precision real type data input to
from
d
in the same data type as that of
s
.
(a) Function without EN/ENO (ABS)
[Structured ladder/FBD]
[ST]
g_lreal2:= ABS(g_lreal1);
(b) Function with EN/ENO (ABS_E)
[Structured ladder/FBD]
[ST]
g_bool2 := ABS_E(g_bool1, g_lreal1, g_lreal2);
5-134
5.2 Standard Functions of One Numeric Variable
5.2.1 Absolute value
s
ADD_E
5.3 Standard Arithmetic Functions
5.3.1
Addition
ADD_E
Basic
ADD_E
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
ADD_E
EN
ADD_E
ENO
s1
ENO:= ADD_E (EN, s1, s2...s28, d);
d
s2
to
5
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop) :Bit
s1 to s28(_IN):
Input
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_NUM
APPLICATION
FUNCTIONS
s28
Function
(1) Performs addition ( s1 + s2 +···+ s28 ) on word (signed), double word (signed), single-precision
real or double-precision real type data input to
s1
from
s28
d
in the same data type as that of
s1
to
to
s28
, and outputs the operation result
.
(Example) Word (signed) type data
s1
1234
Word (signed) type
s2
d
5678
6912
Word (signed) type
Word (signed) type
+
(2) The values to be input to s1 to s28 are word (signed), double word (signed), single-precision
real or double-precision real type data.
(3) The number of pins for
s
can be changed in the range from 2 to 28.
5.3 Standard Arithmetic Functions
5.3.1 Addition
5-135
ADD_E
Operation processing
ADD_E
(4) If an underflow/overflow occurs in the operation result, data is output from
d
as follows.
(a) Word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of ADD_E, TRUE is output from ENO.
32767 +
2 = −32767
(7FFFH) (0002H) (8001H)
−32767 + (−2) = 32766
(8000H) (FFFEH) (7FFEH)
Since the highest-order bit is 1, the result
value is negative.
Since the highest-order bit is 0, the result
value is positive.
(b) Double word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of ADD_E, TRUE is output from ENO.
2147483647 + 2 = −2147483647
(7FFFFFFFH) (0002H) (80000001H)
−2147483648 + (−2) = 2147483646
(80000000H) (FFFEH) (7FFFFFFEH)
Since the highest-order bit is 1, the result
value is negative.
Since the highest-order bit is 0, the result
value is positive.
(5) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 through s28 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-136
5.3 Standard Arithmetic Functions
5.3.1 Addition
ADD_E
Operation Error
No operation error occurs in the execution of the ADD_E function.
Program Example
The program which performs addition ( s1 + s2 ) on double word (signed) type data input to
, and outputs the operation result from
d
in the same data type as that of
s1
and
s2
and
.
[Structured ladder/FBD]
[ST]
g_bool3 := ADD_E(g_bool1, g_dint1, g_dint2, g_dint3);
APPLICATION
FUNCTIONS
5
ADD_E
s2
s1
5.3 Standard Arithmetic Functions
5.3.1 Addition
5-137
MUL_E
5.3.2
Multiplication
MUL_E
Basic
MUL_E
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
MUL_E
EN
MUL_E
ENO
s1
ENO:= MUL_E (EN, s1, s2...s28, d);
d
s2
to
s28
Input argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s1 to s28(_IN): Input
Output argument,
:Bit
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_NUM
Function
Operation processing
(1) Performs multiplication ( s1
s2
···
s28
) on word (signed), double word (signed), single-
precision real or double-precision real type data input to
result from
d
in the same data type as that of
s1
to
s28
s1
to
s28
, and outputs the operation
.
(Example) Word (signed) type data
s1
s2
d
100
15
1500
Word (signed) type
Word (signed) type
Word (signed) type
(2) The values to be input to s1 to s28 are word (signed), double word (signed), single-precision
real or double-precision real type data.
(3) The number of pins for
5-138
s
5.3 Standard Arithmetic Functions
5.3.2 Multiplication
can be changed in the range from 2 to 28.
MUL_E
(4) If an underflow/overflow occurs in the operation result, data is output from
d
as follows.
(a) Word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of MUL_E, TRUE is output from ENO.
Even if the operation result exceeds the word (signed) type data range, data is output in
word (signed) type.
(Although the operation result is 32-bit data, data is output in word (signed) type with the
high-order 16 bits discarded.)
If the operation result exceeds the word (signed) type data range, convert the input
values to the double word (signed) type data by the INT_TO_DINT function and perform
the operation using the converted data.
(b) Double word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of MUL_E, TRUE is output from ENO.
Even if the operation result exceeds the double word (signed) data range, data is output
in double word (signed) type.
(Although the operation result is 64-bit data, data is output in double word (signed) type
with the high-order 32 bits discarded.)
If the operation result exceeds the double word (signed) type data range, convert the
input values to the single-precision real type data by the DINT_TO_REAL function and
perform the operation using the converted data.
Operation result
5
APPLICATION
FUNCTIONS
(5) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 through s28 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
MUL_E
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
If the operation result exceeds the data type range, convert the data type of the
input data before the operation.
5.3 Standard Arithmetic Functions
5.3.2 Multiplication
5-139
MUL_E
Operation Error
No operation error occurs in the execution of the MUL_E function.
Program Example
The program which performs multiplication ( s1
s1
and
s2
, and outputs the operation result from
s2
d
) on double word (signed) type data input to
in the same data type as that of
[Structured ladder/FBD]
[ST]
g_bool3 := MUL_E(g_bool1, g_dint1, g_dint2, g_dint3);
5-140
5.3 Standard Arithmetic Functions
5.3.2 Multiplication
s1
and
s2
.
SUB_E
5.3.3
Subtraction
SUB_E
Basic
SUB_E
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
SUB_E
EN
SUB_E
ENO
s1
ENO:= SUB_E (EN, s1, s2, d);
d
s2
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop) :Bit
s1(_IN1):
Input
s2(_IN2):
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_NUM
APPLICATION
FUNCTIONS
Output argument,
5
:ANY_NUM
Function
Operation processing
s2
) on word (signed), double word (signed), single-precision real
or double-precision real type data input to
d
in the same data type as that of
s1
and
s1
s2
and
s2
, and outputs the operation result from
.
(Example) Word (signed) type data
s1
12345
Word (signed) type
-
s2
d
6789
5556
Word (signed) type
Word (signed) type
(2) The values to be input to s1 and s2 are word (signed), double word (signed), singleprecision real or double-precision real type data.
5.3 Standard Arithmetic Functions
5.3.3 Subtraction
5-141
SUB_E
(1) Performs subtraction ( s1 −
SUB_E
(3) If an underflow/overflow occurs in the operation result, data is output from
d
as follows.
(a) Word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of SUB_E, TRUE is output from ENO.
32767−
(−2)=−32767
(7FFFH) (FFFEH) (8001H)
−32767 −
2 = 32766
Since the highest-order bit is 1, the result
value is negative.
Since the highest-order bit is 0, the result
value is positive.
(8000H) (0002H) (7FFEH)
(b) Double word (signed) type data
No operation error occurs even if an underflow/overflow occurs.
In case of SUB_E, TRUE is output from ENO.
2147483647 − (−2) = −2147483647
(7FFFFFFFH) (FFFEH) (80000001H)
−2147483648 − 2 = 2147483646
(80000000H) (0002H) (7FFFFFFEH)
Since the highest-order bit is 1, the result
value is negative.
Since the highest-order bit is 0, the result
value is positive.
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 , s2 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
d
Operation output value
*1
FALSE
Undefined value
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-142
5.3 Standard Arithmetic Functions
5.3.3 Subtraction
SUB_E
Operation Error
No operation error occurs in the execution of the SUB_E function.
Program Example
The program which performs subtraction ( s1 −
s2
, and outputs the operation result from
d
) on double word (signed) type data input to
in the same data type as that of
s1
and
s2
s1
.
[Structured ladder/FBD]
[ST]
g_bool3 := SUB_E(g_bool1, g_dint1, g_dint2, g_dint3);
APPLICATION
FUNCTIONS
5
SUB_E
and
s2
5.3 Standard Arithmetic Functions
5.3.3 Subtraction
5-143
DIV_E
5.3.4
Division
DIV_E
Basic
DIV_E
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
DIV_E
EN
DIV_E
ENO
s1
ENO:= DIV_E (EN, s1, s2, d);
d
s2
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_NUM
s1(_IN1):
s2(_IN2):
Output argument,
Function
Operation processing
(1) Performs division ( s1 ÷ s2 ) on word (signed), double word (signed), single-precision real or
double-precision real type data input to
result from
d
and
s2
in the same data type as that of
s1
s1
, and outputs the quotient of the operation
and
s2
.
(Example) Word (signed) type data
d
s1
s2
(Quotient)
(Remainder)
5
2
2
1
Word (signed) type
Word (signed) type
Word (signed) type
No output
(2) The values to be input to s1 and s2 are word (signed), double word (signed), singleprecision real or double-precision real type data.
(The value to be input to
s2
must be other than 0.)
(3) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 , s2 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5-144
5.3 Standard Arithmetic Functions
5.3.4 Division
DIV_E
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
DIV_E
APPLICATION
FUNCTIONS
5
5.3 Standard Arithmetic Functions
5.3.4 Division
5-145
DIV_E
Operation Error
An operation error occurs in the following case.
• The value to be input to
s2
is 0. (Division by 0)
(Error code: 4100)
Program Example
The program which performs division ( s1 ÷ s2 ) on double word (signed) type data input to
s2
, and outputs the quotient of the operation result from
and
s2
d
in the same data type as that of
.
[Structured ladder/FBD]
[ST]
g_bool3 := DIV_E(g_bool1, g_dint1, g_dint2, g_dint3);
5-146
5.3 Standard Arithmetic Functions
5.3.4 Division
s1
and
s1
MOD(_E)
5.3.5
Modulus operation
MOD(_E)
Basic
MOD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
MOD_E
EN
MOD
ENO
s1
MOD_E
ENO:= MOD_E (EN, s1, s2, d);
d
s2
Input argument,
EN:
s1(_IN1):
s2(_IN2):
:Bit
Input
:ANY_INT
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_INT
5
APPLICATION
FUNCTIONS
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
Function
Operation processing
and
s2
that of
, and outputs the remainder of the operation result from
s1
and
s2
s1
in the same data type as
d
.
(Example) Word (signed) type data
d
s1
s2
(Quotient)
(Remainder)
5
2
2
1
Word (signed) type
Word (signed) type
No output
Word (signed) type
(2) The values to be input to
s1
and
(Note that the value to be input to
s2
s2
are word (signed) or double word (signed) type data.
must be other than 0.)
5.3 Standard Arithmetic Functions
5.3.5 Modulus operation
5-147
MOD(_E)
(1) Performs division ( s1 ÷ s2 ) on word (signed) or double word (signed) type data input to
MOD(_E)
Operation result
(1) Function without EN/ENO
The following table shows the operation results.
Operation result
d
No operation error
Operation output value
Operation error
Undefined value
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE (No operation error)
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-148
5.3 Standard Arithmetic Functions
5.3.5 Modulus operation
MOD(_E)
Operation Error
An operation error occurs in the following case.
• The value to be input to
s2
is 0. (Division by 0)
(Error code: 4100)
Program Example
The program which performs division ( s1 ÷ s2 ) on double word (signed) type data input to
, and outputs the remainder of the operation result from
s2
in the same data type as that of
s1
.
(a) Function without EN/ENO (MOD)
[Structured ladder/FBD]
[ST]
g_dint3:= g_dint1 MOD g_dint2;
(b) Function with EN/ENO (MOD_E)
[Structured ladder/FBD]
5
APPLICATION
FUNCTIONS
and
d
and
[ST]
g_bool3 := MOD_E(g_bool1, g_dint1, g_dint2, g_dint3);
MOD(_E)
s2
s1
5.3 Standard Arithmetic Functions
5.3.5 Modulus operation
5-149
EXPT(_E)
5.3.6
Exponentiation
EXPT(_E)
Basic
EXPT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
EXPT_E
EN
EXPT
ENO
s1
EXPT _E
ENO:= EXPT_E (EN, s1, s2, d);
d
s2
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1(_IN1):
Input
:ANY_REAL
s2(_IN2):
Input
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_REAL
Function
Operation processing
(1) Performs exponentiation
to
s2
s2
on single-precision real or double-precision real type data input
and word (signed), double word (signed), single-precision real or double-precision real
type data input to
s1
, and outputs the operation result from
d
.
s2
s1
2
4.0
Word (signed) type
Single-precision real type
d
16.0
Single-precision real type
(2) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 , s2 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5-150
5.3 Standard Arithmetic Functions
5.3.6 Exponentiation
EXPT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
These functions consist of the following common instructions.
s1
is single-precision real number,
s2
is word (signed): LOG, FLT
When
s1
is single-precision real number,
s2
is double word (signed): LOG, DFLT
When
s1
is single-precision real number,
s2
is single-precision real number: LOG
s2
is double-precision real number: LOGD,
When s1 is single-precision real number,
DFLTD
When
s1
is double-precision real number,
s2
is word (signed): LOGD
When
s1
is double-precision real number,
s2
is double word (signed): LOGD, FLTD
s2
is single-precision real number: LOGD,
s2
is double-precision real number: LOGD
When s1 is double-precision real number,
DFLTD
When
s1
is double-precision real number,
5
EXPT(_E)
For details of an error which occurs when the function is executed, refer to MELSEC-Q/L
Structured Programming Manual (Common Instructions).
APPLICATION
FUNCTIONS
When
5.3 Standard Arithmetic Functions
5.3.6 Exponentiation
5-151
EXPT(_E)
Program Example
The program which performs exponentiation and outputs the operation result from
same data type as that of
s1
and
s2
.
(a) Function without EN/ENO (EXPT)
[Structured ladder/FBD]
[ST]
g_real2:= EXPT(g_real1, g_int1);
(b) Function with EN/ENO (EXPT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := EXPT_E(g_bool1, g_real1, g_int1, g_real2);
5-152
5.3 Standard Arithmetic Functions
5.3.6 Exponentiation
d
in the
MOVE(_E)
5.3.7
Move operation
MOVE(_E)
Basic
MOVE(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
MOVE
MOVE_E
MOVE_E
s
Output argument,
d
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1(_IN1):
Input
:ANY
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY
5
APPLICATION
FUNCTIONS
Input argument,
ENO:= MOVE_E (EN, s, d);
ENO
MOVE(_E)
EN
5.3 Standard Arithmetic Functions
5.3.7 Move operation
5-153
MOVE(_E)
Function
Operation processing
(1) Moves the data input for
s
from
d
in the same data type as that of
s
.
(2) The values to be specified to s and d are word (signed), double word (signed),
word(unsigned)/16-bit string, double word (unsigned)/32-bit string, single-precision real,
double-precision real, string, or time type data. Only the same data type can be specified for
s
and
d
.
s
d
12
12
Word (signed) type
Word (signed) type
s
d
2147483647
2147483647
Double word (signed) type
Double word (signed) type
s
d
65535
65535
Word (unsigned)/16-bit string type
Word (unsigned)/16-bit string type
s
d
4294967295
4294967295
Double word (unsigned)/32-bit string type
Double word (unsigned)/32-bit string type
s
d
3.402823+38
3.402823+38
Single-precision real type
Single-precision real type
s
d
1.79769313486231+308
1.79769313486231+308
Double-precision real type
Double-precision real type
(3) Rounding error may occur when specifying single-precision real or double-precision real
type data to s by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5-154
5.3 Standard Arithmetic Functions
5.3.7 Move operation
MOVE(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
MOVE(_E)
APPLICATION
FUNCTIONS
5
5.3 Standard Arithmetic Functions
5.3.7 Move operation
5-155
MOVE(_E)
Operation Error
No operation error occurs in the execution of the MOVE(_E) function.
Program Example
The program which moves the word (signed) type data input to
(a) Function without EN/ENO (MOVE)
[Structured ladder/FBD]
[ST]
g_int2:= MOVE(g_int1);
(b) Function with EN/ENO (MOVE_E)
[Structured ladder/FBD]
[ST]
g_bool3 := MOVE_E(g_bool1, g_int1, g_int2);
5-156
5.3 Standard Arithmetic Functions
5.3.7 Move operation
s
to
d
.
AND_E, OR_E, XOR_E, NOT(_E)
5.4 Standard Bitwise Boolean Functions
5.4.1
Boolean AND, boolean OR, boolean exclusive OR, and
boolean NOT
AND_E, OR_E, XOR_E, NOT(_E)
Basic
AND_E
OR_E
XOR_E
NOT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
AND_E
EN
AND_E
ENO
s1
OR_E
ENO:= AND_E (EN, s1, s2...s28, d);
XOR_E
d
NOT
s2
5
NOT_E
to
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1 to s28(_IN1): Input
:ANY_BIT
(s1 only for NOT(_E))
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_BIT
AND_E, OR_E,
XOR_E, NOT(_E)
Output argument,
APPLICATION
FUNCTIONS
s28
Function
Operation processing
(1) AND_E
(a) Performs Boolean AND on bit, word (unsigned)/16-bit string or double word (unsigned)/
32-bit string type data input to
s1
to
s28
bit by bit, and outputs the operation result from
d
in the same data type as that of s1 to s28 .
(Example) Word (unsigned)/16-bit string type data
s1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
1
1
0
1
0
0
0
1
0
0
AND
s2
0
0
0
1
0
0
1
0
0
Boolean AND
d
0
0
0
1
0
0
1
0
0
0
0
0
5.4 Standard Bitwise Boolean Functions
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
5-157
AND_E, OR_E, XOR_E, NOT(_E)
(b) The number of pins of variable 's' can be changed in the range from 2 to 28.
(2) OR_E
(a) Performs Boolean OR on bit, word (unsigned)/16-bit string or double word (unsigned)/
32-bit string type data input to
to
s1
bit by bit, and outputs the operation result from
s28
d in the same data type as that of s1 to s28 .
(Example) Word (unsigned)/16-bit string type data
1
s1
1
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
1
1
0
1
0
0
1
1
1
1
OR
0
s2
0
0
0
0
0
1
0
0
Boolean OR
1
d
1
0
0
1
1
1
1
0
0
1
1
(b) The number of pins of variable 's' can be changed in the range from 2 to 28.
(3) XOR_E
(a) Performs Boolean exclusive OR on bit, word (unsigned)/16-bit string or double word
(unsigned)/32-bit string type data input to
s1
to
bit by bit, and outputs the operation
s28
result from d in the same data type as that of s1 to
(Example) Word (unsigned)/16-bit string type data
1
s1
0
1
0
1
0
1
0
1
s28
.
0
1
0
1
0
1
0
1
1
1
0
0
0
0
1
0
OR
0
s2
0
0
1
1
0
1
1
1
Boolean exclusive OR
1
d
0
1
1
0
0
0
1
0
1
0
1
1
0
(b) The number of pins of variable 's' can be changed in the range from 2 to 28.
(c) When three or more variables 's' exist, XOR is performed between
XOR is successively performed between the result and
When the expression includes
and
s4
s4
s3
s1
and
s2
first, and
.
, XOR is performed between the result of XOR with
.
In this manner, XOR is repeated by the number of variables 's' in the order with
and so on.
(Example) Bit type data
s1 FALSE
For 3 INs
For 4 INs
For 5 INs
TRUE
TRUE
FALSE
XOR
XOR
XOR
XOR
s2 TRUE
s3 TRUE
s4 TRUE
s5 TRUE
Hereafter, XOR is repeated
by the number of s.
Result
5-158
s3
TRUE Result FALSE Result TRUE Result FALSE
5.4 Standard Bitwise Boolean Functions
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
s5
,
s6
AND_E, OR_E, XOR_E, NOT(_E)
(4) NOT, NOT_E
(a) Performs Boolean NOT on bit, word (unsigned)/16-bit string or double word (unsigned)/
32-bit string type data input to
s1
bit by bit, and outputs the operation result from
d
in
the same data type as that of s1 .
(Example) Word (unsigned)/16-bit string type data
s1
0
1
1
0
1
0
1
1
0
0
0
0
1
1
1
1
1
1
1
0
0
0
0
NOT
d
1
0
0
1
0
1
0
0
1
(b) The value to be input to variables s1 to s28 is bit, word (unsigned)/16-bit string or double
word (unsigned)/32-bit string type data.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
d
Operation output value
*1
FALSE
Undefined value
5
AND_E, OR_E,
XOR_E, NOT(_E)
APPLICATION
FUNCTIONS
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.4 Standard Bitwise Boolean Functions
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
5-159
AND_E, OR_E, XOR_E, NOT(_E)
Operation Error
No operation error occurs in the execution of the AND_E, OR_E, XOR_E, and NOT(_E)
functions.
Program Example
(1) The program which performs Boolean AND on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
d
.
[Structured ladder/FBD]
[ST]
g_bool2 := AND_E (g_bool1, g_word1, g_word2, g_word3);
5-160
5.4 Standard Bitwise Boolean Functions
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
in the same data type as
AND_E, OR_E, XOR_E, NOT(_E)
(2) The program which performs Boolean OR on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
d
in the same data type as
.
[Structured ladder/FBD]
[ST]
g_bool2 := OR_E(g_bool1, g_word1, g_word2, g_word3);
(3) The program which performs Boolean XOR on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
d
in the same data type as
.
[Structured ladder/FBD]
[ST]
g_bool2 := XOR_E(g_bool1, g_word1, g_word2, g_word3);
5
input to
of
s1
s1
bit by bit, and outputs the operation result from
d
in the same data type as that
.
(a) Function without EN/ENO (NOT)
APPLICATION
FUNCTIONS
(4) The program which performs Boolean NOT on bit, word (unsigned)/16-bit string type data
AND_E, OR_E,
XOR_E, NOT(_E)
[Structured ladder/FBD]
[ST]
g_word2 :=NOT (g_word1);
(b) Function with EN/ENO (NOT_E)
[Structured ladder/FBD]
[ST]
g_bool2 := NOT_E (g_bool1, g_word1, g_word2);
5.4 Standard Bitwise Boolean Functions
5.4.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
5-161
SEL(_E)
5.5 Standard Selection Functions
5.5.1
Selection
SEL(_E)
Basic
SEL(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
SEL_E
EN
SEL
ENO
s1
SEL_E
ENO:= SEL_E (EN, s1, s2, s3, d);
d
s2
s3
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1(_G):
Output condition (TRUE: s3 output, FALSE: s2 output)
:Bit
Input
:ANY
s2(_IN0):
s3(_IN1):
Output argument,
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY
Function
Operation processing
(1) Selects either of values input to
outputs the operation result from
d
s3
according to the bit type data input to
in the same data type as that of
When the input value of
s1
is FALSE, the value input to
When the input value of
s1
is TRUE, the value input to
(Example)
and
s2
s1
s2 to s3
s3
s2
s3
FALSE
Bit type
1234
Word (signed) type
5.5 Standard Selection Functions
5.5.1 Selection
SEL
_G
OUT
_IN0
_IN1
s2
and
is output from
is output from
are word (signed) type data
5678
Word (signed) type
5-162
and
s2
d
1234
Word (signed) type
.
d
d
s3
.
.
s1
, and
SEL(_E)
(2) The input value to
s1
is data value of bit type.
(3) The input value to s2 , s3 is data value of bit type/word (signed) type/double word (signed)
type/word (unsigned) type/16-bit string type/double word (unsigned) type/32-bit string type/
single-precision real number type/double-precision real number type/string type/time type/
structured data type/array type.
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s2 , s3 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
SEL(_E)
APPLICATION
FUNCTIONS
5
5.5 Standard Selection Functions
5.5.1 Selection
5-163
SEL(_E)
Operation Error
No operation error occurs in the execution of the SEL(_E) function.
Program Example
The program which selects either of values input to
and outputs the operation result from
d
s2
and
s3
according to the value input to
in the same data type as that of
s2
and
(a) Function without EN/ENO (SEL)
[Structured ladder/FBD]
[ST]
g_word3 := SEL (g_bool1, g_word1, g_word2);
(b) Function with EN/ENO (SEL_E)
[Structured ladder/FBD]
[ST]
g_bool3 := SEL_E (g_bool1, g_bool2, g_word1, g_word2, g_word3);
5-164
5.5 Standard Selection Functions
5.5.1 Selection
s3
.
s1
,
MAXIMUM(_E), MINIMUM(_E)
5.5.2
Maximum/Minimum selection
MAXIMUM(_E), MINIMUM(_E)
Basic
MAXIMUM(_E)
MINIMUM(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
MAXIMUM_E
EN
ENO
s1
ENO:= MAXIMUM_E (EN, s1, s2
s28, d);
MAXIMUM
MAXIMUM_E
MINIMUM
MINIMUM_E
d
s2
to
s28
EN:
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1 to s28(_IN1): Input
:ANY_SIMPLE
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_SIMPLE
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
Selects the maximum value to be output among the bit, word (signed), double word (signed),
word(unsigned)/16-bit string, double word(unsigned)/32-bit string, single-precision real,
double-precision real, string, or time type data input to
result from d in the same data type as that of
(Example) Word (signed) type data
s1
to
s28
s1
to
s28
, and outputs the operation
.
s1 to s28
1234
Word (signed) type
5678
Word (signed) type
MAXIMUM
_IN
OUT
_IN
d
5678
Word (signed) type
5.5 Standard Selection Functions
5.5.2 Maximum/Minimum selection
5-165
MAXIMUM(_E),
MINIMUM(_E)
(1) MAXIMUM, MAXIMUM_E
MAXIMUM(_E), MINIMUM(_E)
(2) MINIMUM, MINIMUM_E
Selects the minimum value to be output among the word (signed), double word (signed) or
single-precision real type data input to
the same data type as that of s1 to
(Example) Word (signed) type data
s28
s1
to
s28
, and outputs the operation result from
d
.
s1 to s28
1234
Word (signed) type
5678
Word (signed) type
MINIMUM
_IN
OUT
_IN
d
5678
Word (signed) type
(3) The values to be input to s1 to s28 are bit, word (signed), double word (signed),
word(unsigned)/16-bit string, double word (unsigned)/32-bit string, single-precision real,
double-precision real, string, or time type data.
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 through s28 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(5) The number of pins of variable 's' can be changed in the range from 2 to 28.
(6) If word (unsigned) type/16-bit string type/double word (unsigned) type/32-bit string type is
specified for
d
, warning C9026 occurs.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-166
5.5 Standard Selection Functions
5.5.2 Maximum/Minimum selection
in
MAXIMUM(_E), MINIMUM(_E)
Operation Error
No operation error occurs in the execution of the MAXIMUM(_E) and MINIMUM(_E)
function.
Program Example
(1) The program which outputs the maximum value of the word (signed) data input to variables
s1
to
s28
from
d
in the same data type as that of
s1
to
s28
.
(a) Function without EN/ENO (MAXIMUM)
[Structured ladder/FBD]
[ST]
g_int3 := MAXIMUM(g_int1, g_int2);
(b) Function with EN/ENO (MAXIMUM_E)
[Structured ladder/FBD]
[ST]
g_bool3 := MAXIMUM_E (g_bool1, g_int1, g_int2, g_int3);
(2) The program which outputs the minimum value of the word (signed) data input to variables
s1
to
s28
from
d
in the same data type as that of
s1
to
s28
APPLICATION
FUNCTIONS
5
.
MAXIMUM(_E),
MINIMUM(_E)
(a) Function without EN/ENO (MINIMUM)
[Structured ladder/FBD]
[ST]
g_int3 := MINIMUM(g_int1, g_int2);
5.5 Standard Selection Functions
5.5.2 Maximum/Minimum selection
5-167
LIMITATION(_E)
5.5.3
Upper/Lower limit control
LIMITATION(_E)
Basic
LIMITATION(_E)
High
performance
L CPU
Universal
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
LIMITATION_E
EN
LIMITATION
ENO
s1
LIMITATION_E
ENO:= LIMITATION_E (EN, s1, s2, s3, d);
d
s2
s3
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s1(_MN):
Lower limit value (minimum output limit value)
:ANY_SIMPLE
s2(_IN):
Input controlled by the upper/lower limit control
:ANY_SIMPLE
s3(_MX):
Upper limit value (maximum output limit value)
:ANY_SIMPLE
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY_SIMPLE
:Bit
Function
Operation processing
(1) Selects the value to be output among the bit, word (signed), double word (signed), word
(unsigned)/16-bit string, double word (unsigned)/32-bit string, or single-precision realtype,
double-precision real, string, or time type data input to
values, and outputs the operation result from
,
s2
, and
s3
according to their
in the same data type as that of
s1
to
s3
.
(a) When the input value of
s2
> the input value of
s3
, outputs the input value
s3
from
d
.
(b) When the input value of
s2
< the input value of
s1
, outputs the input value
s1
from
d
.
(c) When the input value of
s1
the input value of
5-168
d
s1
s2
5.5 Standard Selection Functions
5.5.3 Upper/Lower limit control
from
the input value of
d
.
s2
the input value of
s3
, outputs
LIMITATION(_E)
(Example) Word (signed) type data
Output value
-100
Word (signed) type
s1
s2
120
Word (signed) type
LIMITATION
_MN
OUT
_IN
_MX
d
100
Word (signed) type
MN input value
Input value
MX input value
s3
100
Word (signed) type
(2) The values to be input to s1 , s2 , and s3 are bit, word (signed), double word (signed), word
(unsigned)/16-bit string, double word (unsigned)/32-bit string, single-precision real, doubleprecision real, string, or time type data. (the input value of
s1
< the input value of
s3
)
(3) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 , s2 , or s3 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(4) If word (unsigned) type/16-bit string type/double word (unsigned) type/32-bit string type is
specified for
d
, warning C9026 occurs.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
APPLICATION
FUNCTIONS
EN
5
d
LIMITATION(_E)
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.5 Standard Selection Functions
5.5.3 Upper/Lower limit control
5-169
LIMITATION(_E)
Operation Error
No operation error occurs in the execution of the LIMITATION(_E) function.
Program Example
The program which outputs the values input to variables
s1
(signed) data from
,
d
in the same data type as that of
s1
,
s2
s2
, and
, and
s3
s3
according to the word
.
(a) Function without EN/ENO (LIMITATION)
[Structured ladder/FBD]
[ST]
g_int4 := LIMITATION (g_int1, g_int2, g_int3);
(b) Function with EN/ENO (LIMITATION_E)
[Structured ladder/FBD]
[ST]
g_bool3 := LIMITATION_E (g_bool1, g_int1, g_int2, g_int3, g_int4);
5-170
5.5 Standard Selection Functions
5.5.3 Upper/Lower limit control
MUX(_E)
5.5.4
Multiplexer
MUX(_E)
High
performance
Basic
MUX(_E)
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
MUX_E
EN
MUX
ENO
n
MUX_E
ENO:= MUX_E (EN, n, s1, s2...s28, d);
d
s1
s2
to
s28
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
n(_K):
Output value selection
:Word (signed)
s1 to s28(_IN): Input
:ANY
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:ANY
5
APPLICATION
FUNCTIONS
Input argument,
Function
Operation processing
value input to n, and outputs the operation result from
variables
s1
to
s28
When the input value of n is n, the value input to
(Example) Word (signed) type data
s1 to s28
to
s28
according to the
in the same data type as that of
d
.
When the input value of n is 1, the value input to
n
s1
1
Word (signed) type
1234
Word (signed) type
MUX
_K
OUT
_IN
_IN
s1
is output from
d
.
sn
is output from
d
.
d
1234
Word (signed) type
5678
Word (signed) type
(2) If a value input to n is outside the range of number of pins of variable 's', an undefined value
is output from
d
.
(No operation error occurs. In case of MUX_E, FALSE is output from ENO.)
5.5 Standard Selection Functions
5.5.4 Multiplexer
5-171
MUX(_E)
(1) Selects the value to be output among the values input to variables
MUX(_E)
(3) The value to be input to n is word (signed) type data within the range from 1 to 28 (within the
range of the number of pins of variable 's').
(4) The value to be input to variable 's' is bit, word (signed), double word (signed), word
(unsigned)/16-bit string, double word (unsigned)/32-bit string, single-precision real, doubleprecision real, string, time, structure, or array type data.
(5) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 through s28 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(6) The number of pins of variable 's' can be changed in the range from 2 to 28.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-172
5.5 Standard Selection Functions
5.5.4 Multiplexer
MUX(_E)
Operation Error
No operation error occurs in the execution of the MUX(_E) function.
Program Example
The program which selects the value to be output among the values input to variables
according to the value input to n, and outputs the operation result from
as that of
s1
or
s2
d
s1
and
s2
in the same data type
.
(a) Function without EN/ENO (MUX)
[Structured ladder/FBD]
[ST]
g_int4 := MUX (g_int1, g_int2, g_int3);
(b) Function with EN/ENO (MUX_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
MUX(_E)
g_bool3 := MUX_E (g_bool1, g_int1, g_int2, g_int3, g_int4);
5.5 Standard Selection Functions
5.5.4 Multiplexer
5-173
GT_E, GE_E, EQ_E, LE_E, LT_E, NE_E
5.6 Standard Comparison Functions
5.6.1
Comparison
GT_E, GE_E, EQ_E, LE_E, LT_E, NE_E
Basic
GT_E
GE_E
EQ_E
LE_E
LT_E
NE_E
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
GT_E
EN
functions.
GT_E
ENO
s1
Not supported
GE_E
EQ_E
d
LE_E
s2
LT_E
to
s28
NE_E
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1 to s28(_IN):
Input
:ANY_SIMPLE
(s1 and s2 only for NE(_E))
Output argument,
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output (TRUE: True value, FALSE: False value)
:Bit
Function
Operation processing
(1) Performs comparison operation between the values input to variables
the operation result from
5-174
d
5.6 Standard Comparison Functions
5.6.1 Comparison
in bit type as that of variables
s1
to
s28
.
s1
to
s28
, and outputs
GT_E, GE_E, EQ_E, LE_E, LT_E, NE_E
Performs comparison of [ s1 >
s2
]&[ s2 >
• Outputs TRUE if all of comparisons satisfy
s
(n−1) >
(b) GE_E(
)
Performs comparison of [ s1
• Outputs TRUE if all of comparisons satisfy
Performs comparison of [ s1 =
• Outputs TRUE if all of comparisons satisfy
)
Performs comparison of [ s1
• Outputs TRUE if all comparisons satisfy
Performs comparison of [ s1 <
• Outputs TRUE if all comparisons satisfy
s
NE_E(< >)
Performs comparison of [ s1
• Outputs TRUE if
• Outputs FALSE if
s1
s1
s2
s
s3
(n−1) <
]&[ s2 =
s
(n−1) =
s
s
s
s2
s3
s
(n)].
s
s
(n−1)
s
(n−1) =
s
(n−1)
s
(n)].
s
(n)].
(n).
]&···&[
s
(n)].
(n).
(n−1) >
s
>
(n).
]&···&[
(n−1)
]&[ s2 <
(n−1) <
s
(n).
s
(n−1)
(n).
]&···&[
s
(n−1)
s2
s3
]&[ s2
s
(n).
s
s2
• Outputs FALSE if any of comparisons satisfies
(f)
s
(n−1)
• Outputs FALSE if any of comparisons satisfies
(e) LT_E(<)
(n−1)
s
s2
s
(n).
]&[ s2
• Outputs FALSE if any of comparisons satisfies
(d) LE_E(
s
s2
• Outputs FALSE if any of comparisons satisfies
(c) EQ_E(=)
s
]&···&[
s3
s
(n).
]&···&[
s
(n−1) <
s
(n)].
(n).
(n−1)
s
(n).
5
].
.
= s2 .
(2) The values to be input to s is bit, word (signed), double word (signed), word (unsigned), 16bit string, double word (unsigned), 32-bit string, single-precision real, double-precision real,
string, time type data.
(3) Rounding error may occur when specifying single-precision real or double-precision real
type data to s1 through s28 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
(4) The number of pins of
s
s
can be changed in the range from 2 to 28. (The number of pins of
for comparison operator NE(_E)) is fixed at
s1
and
s2
.
5.6 Standard Comparison Functions
5.6.1 Comparison
5-175
APPLICATION
FUNCTIONS
• Outputs FALSE if any of comparisons satisfies
s3
GT_E, GE_E, EQ_E,
LE_E, LT_E, NE_E
(a) GT_E(>)
GT_E, GE_E, EQ_E, LE_E, LT_E, NE_E
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-176
5.6 Standard Comparison Functions
5.6.1 Comparison
GT_E, GE_E, EQ_E, LE_E, LT_E, NE_E
Operation Error
No operation error occurs in the execution of the GT_E, GE_E, EQ_E, LE_E, LT_E, and
NE_E functions.
Program Example
The program which performs comparison operation between the values input to
outputs the operation result from
d
s1
and
s2
, and
.
[Structured ladder/FBD]
[ST]
g_bool3 := GT_E (g_bool1, g_int1, g_int2, g_bool2);
GT_E, GE_E, EQ_E,
LE_E, LT_E, NE_E
APPLICATION
FUNCTIONS
5
5.6 Standard Comparison Functions
5.6.1 Comparison
5-177
MID(_E)
5.7 Standard Character String Functions
5.7.1
Extract mid string
MID(_E)
Basic
MID(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
MID_E
EN
functions.
MID
ENO
s
MID_E
ENO:= MID_E (EN, s, n1, n2, d);
d
n1
n2
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_IN):
Input
:String (255)
n1(_L):
Number of characters to be extracted
:Word (signed)
n2(_P):
Start position to be extracted
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (255)
Function
Operation processing
(1) Extracts the specified number of characters from the specified start position in the character
string input to
s
, and outputs the operation result from
d
.
The number of characters to be extracted is specified by the value input to n1.
The start position of the characters to be extracted is specified by the value input to n2.
5-178
5.7 Standard Character String Functions
5.7.1 Extract mid string
MID(_E)
(Example) Values input to n1 and n2 are 5
'ABCDEF12345'
'EF123'
High-order byte Low-order byte
High-order byte Low-order byte
1st word
42H(B)
41H(A)
46H(F)
45H(E)
1st word
2nd word
44H(D)
43H(C)
32H(2)
31H(1)
2nd word
3rd word
46H(F)
45H(E)
00H
33H(3)
3rd word
4th word
32H(2)
31H(1)
5th word
34H(4)
33H(3)
6th word
00H
35H(5)
(2) The value to be input to
s
Start position to
be extracted n2:
5th character
Number of characters to be extracted n1: 5 characters
is string type data within the range from 0 to 255 bytes.
(3) The value to be input to n1 is word (signed) type data within the range from 0 to 255.
(The input value must not exceed the number of characters of character string input to
s
.)
s
.)
(4) The value to be input to n2 is word (signed) type data within the range from 1 to 255.
(The input value must not exceed the number of characters of character string input to
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
5
APPLICATION
FUNCTIONS
d
MID(_E)
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.7 Standard Character String Functions
5.7.1 Extract mid string
5-179
MID(_E)
Operation Error
These functions consist of the following instructions.
MID(_E): MIDR
For details of an error which occurs when the function is executed, refer to MELSEC-Q/L
Structured Programming Manual (Common Instructions).
Program Example
The program which extracts the specified number of characters from the specified start position
in the character string input to
s
, and outputs the operation result from
d
(a) Function without EN/ENO (MID)
[Structured ladder/FBD]
[ST]
g_string2:=MID(g_string1, g_int1, g_int2);
(b) Function with EN/ENO (MID_E)
[Structured ladder/FBD]
[ST]
g_bool3 := MID_E(g_bool1, g_string1, g_int1, g_int2, g_string2);
5-180
5.7 Standard Character String Functions
5.7.1 Extract mid string
.
CONCAT(_E)
5.7.2
String concatenation
CONCAT(_E)
Basic
CONCAT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
CONCAT_E
EN
CONCAT
ENO
s1
ENO:= CONCAT_E (EN, s1, s2
CONCAT_E
n28, d);
d
s2
to
s28
Input argument,
EN:
s1 to s28(_IN):
s2:
:Bit
Input
:String (255)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (255)
5
APPLICATION
FUNCTIONS
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
Function
(1) Concatenates the character string input to
outputs the operation result from
d
to
s2
s28
following the one input to
s1
, and
.
This function concatenates character string
s2
to
s28
with ignoring '00H', which indicates the
end of character string s1 .
If the concatenated character string has over 255 bytes, the character string up to 255 bytes
is output.
s1
+
'ABCDE'
s2
d
'123456'
'ABCDE123456'
High-order byte Low-order byte
High-order byte Low-order byte
High-order byte Low-order byte
1st word
42H(B)
41H(A)
1st word
32H(2)
31H(1)
1st word
42H(B)
41H(A)
2nd word
44H(D)
43H(C)
2nd word
34H(4)
33H(3)
2nd word
44H(D)
43H(C)
3rd word
00H
45H(E)
3rd word
36H(6)
35H(5)
3rd word
31H(1)
45H(E)
4th word
33H(3)
32H(2)
5th word
35H(5)
34H(4)
6th word
00H
36H(6)
4th word
(2) The values to be input to
bytes.
(3) The number of pins for
s
s1
and
s2
to
00H
s28
are string type data within the range from 0 to 255
can be changed in the range from 2 to 28.
5.7 Standard Character String Functions
5.7.2 String concatenation
5-181
CONCAT(_E)
Operation processing
CONCAT(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-182
5.7 Standard Character String Functions
5.7.2 String concatenation
CONCAT(_E)
Operation Error
No operation error occurs in the execution of the CONCAT(_E) function.
Program Example
The program which concatenates the character string input to
and outputs the operation result from
d
s2
following the one input to
s1
,
.
(a) Function without EN/ENO (CONCAT)
[Structured ladder/FBD]
[ST]
g_string3:=CONCAT(g_string1, g_string2);
(b) Function with EN/ENO (CONCAT_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
CONCAT(_E)
g_bool3 := CONCAT_E(g_bool1, g_string1, g_string2, g_string3);
5.7 Standard Character String Functions
5.7.2 String concatenation
5-183
INSERT(_E)
5.7.3
String insertion
INSERT(_E)
Basic
INSERT(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
INSERT_E
EN
INSERT
ENO
s1
INSERT_E
ENO:= INSERT_E (EN, s1, s2, n, d);
d
s2
n
Input argument,
EN:
s1(_IN1):
s2(_IN2):
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:String (255)
n(_P):
Start position to be inserted
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (255)
Function
Operation processing
(1) Inserts the character string input to
to
s1
s2
to the specified position in the character string input
, and outputs the operation result from
d
.
Specify the start position of the character string to be inserted by the value input to n.
After the insertion of character string
s2
to character string
s1
, '00H' that indicates the end of
character string s2 is ignored. If the character string after insertion has over 255 bytes, the
character string up to 255 bytes is output.
5-184
5.7 Standard Character String Functions
5.7.3 String insertion
INSERT(_E)
(Example) Value input to n is 4
d
Input value to s1
'ABCDE'
Output value
'ABC123456DE'
High-order byte Low-order byte
High-order byte Low-order byte
1st word
42H(B)
41H(A)
2nd word
44H(D)
43H(C)
3rd word
00H
45H(E)
Start position to
be inserted n:
4th character
Input value to s2
'123456'
42H(B)
41H(A)
1st word
31H(1)
43H(C)
2nd word
33H(3)
32H(2)
3rd word
35H(5)
34H(4)
4th word
44H(D)
36H(6)
5th word
00H
45H(E)
6th word
High-order byte Low-order byte
1st word
32H(2)
31H(1)
2nd word
34H(4)
33H(3)
3rd word
36H(6)
35H(5)
4th word
00H
(2) The values to be input to
bytes.
s1
and
s2
are string type data within the range from 0 to 255
(3) The value to be input to n is word (signed) type data within the range from 1 to 255.
(The input value must not exceed the number of characters of character string input to
s1
.)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
5
.
EN
ENO
TRUE (Operation execution)
TRUE
FALSE (Operation stop)
APPLICATION
FUNCTIONS
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
d
Operation output value
*1
FALSE
Undefined value
5.7 Standard Character String Functions
5.7.3 String insertion
INSERT(_E)
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-185
INSERT(_E)
Operation Error
No operation error occurs in the execution of the INSERT(_E) function.
Program Example
The program which inserts the character string input to
character string input to
s1
s2
to the specified position in the
, and outputs the operation result from
d
.
(a) Function without EN/ENO (INSERT)
[Structured ladder/FBD]
[ST]
g_string3:=INSERT(g_string1, g_string2, g_int1);
(b) Function with EN/ENO (INSERT_E)
[Structured ladder/FBD]
[ST]
g_bool3 := INSERT_E(g_bool1, g_string1, g_string2, g_int1, g_string3);
5-186
5.7 Standard Character String Functions
5.7.3 String insertion
DELETE(_E)
5.7.4
String deletion
DELETE(_E)
Basic
DELETE(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
DELETE_E
EN
DELETE
ENO
s
DELETE_E
ENO:= DELETE_E (EN, s, n1, n2, d);
d
n1
n2
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(_IN):
Input
:String (255)
n1(_L):
Number of characters to be deleted
:Word (signed)
n2(_P):
Start position to be deleted
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (255)
5
APPLICATION
FUNCTIONS
Input argument,
Function
(1) Deletes the specified number of characters from the specified position in the character string
input to
s
, and outputs the remaining character string from
d
.
The number of characters to be deleted is specified by the value input to n1.
The start position to be deleted in the character string is specified by the value input to n2.
5.7 Standard Character String Functions
5.7.4 String deletion
5-187
DELETE(_E)
Operation processing
DELETE(_E)
(Example) Values input to n1 and n2 are 5
s
d
'ABCDEF12345'
'ABCD45'
High-order byte Low-order byte
High-order byte Low-order byte
1st word
42H(B)
41H(A)
42H(B)
41H(A)
1st word
2nd word
44H(D)
43H(C)
44H(D)
43H(C)
2nd word
3rd word
46H(F)
45H(E)
35H(5)
34H(4)
3rd word
4th word
32H(2)
31H(1)
5th word
34H(4)
33H(3)
6th word
00H
35H(5)
(2) The value to be input to
s
Start position to
be deleted n2:
5th character
4th word
00H
Number of characters to be deleted n1: 5 characters
is string type data within the range from 0 to 255 bytes.
(3) The value to be input to n1 is word (signed) type data within the range from 0 to 255.
(The input value must not exceed the number of characters of character string input to
s
.)
s
.)
(4) The value to be input to n2 is word (signed) type data within the range from 1 to 255.
(The input value must not exceed the number of characters of character string input to
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-188
5.7 Standard Character String Functions
5.7.4 String deletion
DELETE(_E)
Operation Error
No operation error occurs in the execution of the DELETE(_E) function.
Program Example
The program which deletes the specified number of characters from the specified position in the
character string input to
s
, and outputs the remaining character string from
d
.
(a) Function without EN/ENO (DELETE)
[Structured ladder/FBD]
[ST]
g_string2:=DELETE(g_string1, g_int1, g_int2);
(b) Function with EN/ENO (DELETE_E)
[Structured ladder/FBD]
APPLICATION
FUNCTIONS
5
[ST]
DELETE(_E)
g_bool3 := DELETE_E(g_bool1, g_string1, g_int1, g_int2, g_string2);
5.7 Standard Character String Functions
5.7.4 String deletion
5-189
REPLACE(_E)
5.7.5
String replacement
REPLACE(_E)
Basic
REPLACE(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
REPLACE_E
EN
REPLACE
ENO
s1
REPLACE_E
ENO:= REPLACE_E (EN, s1, s2, n1, n2, d);
d
s2
n1
n2
Input argument,
EN:
s1(_IN1):
s2(_IN2):
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:String (255)
n1(_L):
Number of characters to be replaced
:Word (signed)
n2(_P):
Start position to be replaced
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:String (255)
Function
Operation processing
(1) Replaces the specified number of characters from the specified position in the character
string input to
d
s1
with the character string input to
s2
, and outputs the operation result from
.
The number of characters to be replaced is specified by the value input to n1.
The start position to be replaced in the character string is specified by the value input to n2.
5-190
5.7 Standard Character String Functions
5.7.5 String replacement
REPLACE(_E)
(Example) Values input to n1 and n2 are 5
d
Input value to s1
'ABCDEFGH123'
Output value
'ABCD1234523'
High-order byte Low-order byte
High-order byte Low-order byte
1st word
42H(B)
41H(A)
42H(B)
41H(A)
1st word
2nd word
44H(D)
43H(C)
44H(D)
43H(C)
2nd word
3rd word
46H(F)
45H(E)
4th word
48H(H)
47H(G)
5th word
32H(2)
6th word
00H
Start position to
be replaced n2:
5th character
32H(2)
31H(1)
3rd word
34H(4)
33H(3)
4th word
31H(1)
32H(2)
35H(5)
5th word
33H(3)
00H
33H(3)
6th word
Number of characters to be replaced n1: 5 characters
Input value to s2
'123456'
High-order byte Low-order byte
1st word
32H(2)
31H(1)
2nd word
34H(4)
33H(3)
3rd word
36H(6)
4th word
35H(5)
00H
(2) The values to be input to
bytes.
s1
and
s2
are string type data within the range from 0 to 255
(3) The value to be input to n1 is word (signed) type data within the range from 0 to 255.
(The input value must not exceed the number of characters of character string input to input
variable
s1
.)
5
(4) The value to be input to n2 is word (signed) type data within the range from 1 to 255.
s1
.)
APPLICATION
FUNCTIONS
(The input value must not exceed the number of characters of character string input to
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
REPLACE(_E)
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5.7 Standard Character String Functions
5.7.5 String replacement
5-191
REPLACE(_E)
Operation Error
No operation error occurs in the execution of the REPLACE(_E) function.
Program Example
The program which replaces the specified number of characters from the specified position in the
character string input to
from
d
s1
with the character string input to
s2
, and outputs the operation result
.
(a) Function without EN/ENO (REPLACE)
[Structured ladder/FBD]
[ST]
g_string3:=REPLACE(g_string1, g_string2, g_int1, g_int2);
(b) Function with EN/ENO (REPLACE_E)
[Structured ladder/FBD]
[ST]
g_bool3 := REPLACE_E(g_bool1, g_string1, g_string2, g_int1, g_int2, g_string3);
5-192
5.7 Standard Character String Functions
5.7.5 String replacement
ADD_TIME(_E)
5.8 Functions of Time Data Type
5.8.1
Addition
ADD_TIME(_E)
Basic
ADD_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
ADD_TIME
ADD_TIME_E
EN
ENO
s1
ADD_TIME_E
ENO:= ADD_TIME_E (EN, s1, s2, d);
d
s2
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
s1(_IN1):
s2(_IN2):
Output argument,
Function
Operation processing
(1) Performs addition ( s1 + s2 ) on time type data input to
result from
d
s1
and
s2
, and outputs the operation
in time type.
(Example) When the input value to s1 and s2 are T#1d2h33m44s55ms (1 day 2 hours 33
minutes 44 seconds 55 milliseconds) and T#2ms (2 milliseconds).
s1
T#1d2h33m44s55ms
+
Time type
(2) The value to be input to
s2
d
T#2ms
T#1d2h33m44s57ms
Time type
Time type
s1
,
s2
are time type data.
5.8 Functions of Time Data Type
5.8.1 Addition
5-193
ADD_TIME(_E)
Input argument,
APPLICATION
FUNCTIONS
5
ADD_TIME(_E)
(3) No operation error occurs even if an underflow/overflow occurs. Data is output from
follows.
In case of ADD_TIME_E, TRUE is output from ENO.
(Example) Overflow
T#24d20h31m23s647m +
T#2ms
(7FFFFFFFH)
(00000002H)
T#-24d20h31m23s647m
(80000001H)
Since the highest-order bit is 1, the result value is negative.
(Example) Underflow
T#-24d20h31m23s648ms
(80000000H)
+
T#-2ms
(FFFFFFFEH)
T#24d20h31m23s646ms
(7FFFFFFEH)
Since the highest-order bit is 0, the result value is positive.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
No operation error occurs in the execution of the ADD_TIME(_E) function.
5-194
5.8 Functions of Time Data Type
5.8.1 Addition
d
as
ADD_TIME(_E)
Program Example
The program which performs addition ( s1 + s2 ) on time type data input to
the operation result from
d
s1
and
s2
, and outputs
in time type.
(a) Function without EN/ENO (ADD_TIME)
[Structured ladder/FBD]
[ST]
g_time3:= ADD_TIME(g_time1, g_time2);
(b) Function with EN/ENO (ADD_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := ADD_TIME_E(g_bool1, g_time1, g_time2, g_time3);
ADD_TIME(_E)
APPLICATION
FUNCTIONS
5
5.8 Functions of Time Data Type
5.8.1 Addition
5-195
SUB_TIME(_E)
5.8.2
Subtraction
SUB_TIME(_E)
Basic
SUB_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
SUB_TIME
SUB_TIME_E
EN
ENO
s1
SUB_TIME_E
ENO:= SUB_TIME_E (EN, s1, s2, d);
d
s2
Input argument,
EN:
s1(_IN1):
s2(_IN2):
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
Function
Operation processing
(1) Performs subtraction ( s1 − s2 ) on time type data input to
operation result from
d
s1
and
s2
, and outputs the
in time type.
(Example) When the input value to s1 and s2 are T#1d2h33m44s55ms (1 day 2 hours 33
minutes 44 seconds 55 milliseconds) and T#2ms (2 milliseconds).
s1
T#1d2h33m44s55ms
Time type
(2) The value to be input to
5-196
s2
d
T#2ms
T#1d2h33m44s53ms
Time type
Time type
-
s1
5.8 Functions of Time Data Type
5.8.2 Subtraction
,
s2
are time type data.
SUB_TIME(_E)
(3) No operation error occurs even if an underflow/overflow occurs. Data is output from
follows.
d
as
In case of SUB_TIME_E, TRUE is output from ENO.
(Example) Overflow
T#24d20h31m23s647ms
(7FFFFFFFH)
T#-2ms
(FFFFFFFEH)
T#-24d20h31m23s647ms
(80000001H)
Since the highest-order bit is 1, the result value is negative.
(Example) Underflow
T#-24d20h31m23s648ms
(80000000H)
T#2ms
(00000002H)
T#24d20h31m23s646ms
(7FFFFFFEH)
Since the highest-order bit is 0, the result value is positive.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
APPLICATION
FUNCTIONS
5
Operation Error
SUB_TIME(_E)
No operation error occurs in the execution of the SUB_TIME(_E) function.
5.8 Functions of Time Data Type
5.8.2 Subtraction
5-197
SUB_TIME(_E)
Program Example
The program which performs subtraction ( s1 − s2 ) on time type data input to
outputs the operation result from
d
in time type.
(a) Function without EN/ENO (SUB_TIME)
[Structured ladder/FBD]
[ST]
g_time3:= SUB_TIME(g_time1, g_time2);
(b) Function with EN/ENO (SUB_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := SUB_TIME_E(g_bool1, g_time1, g_time2, g_time3);
5-198
5.8 Functions of Time Data Type
5.8.2 Subtraction
s1
and
s2
, and
MUL_TIME(_E)
5.8.3
Multiplication
MUL_TIME(_E)
Basic
MUL_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
MUL_TIME
MUL_TIME_E
EN
ENO
s1
MUL_TIME_E
ENO:= MUL_TIME_E (EN, s1, s2, d);
d
s2
EN:
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1(_IN1): Input
:Time
s2(_IN2): Input
:ANY_NUM
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
5
APPLICATION
FUNCTIONS
Input argument,
Function
(1) Performs multiplication ( s1
s2
) on time type data input to
s1
and the word (signed), double
word (signed), single-precision real or double-precision real type data input to
outputs the operation result from
d
s2
, and
in time type.
(Example) When the input value to s1 and s2 are T#1d2h33m44s55ms (1 day 2 hours 33
minutes 44 seconds 55 milliseconds) and 2.
s1
s2
d
T#1d2h33m44s55ms
2
T#2d5h7m28s110m
Time type
Word (signed)
Time type
(2) The value to be input to
s1
is time type data.
(3) The value to be input to s2 is word (signed), double word (signed), single-precision real or
double-precision real type data.
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s2 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
5.8 Functions of Time Data Type
5.8.3 Multiplication
5-199
MUL_TIME(_E)
Operation processing
MUL_TIME(_E)
(5) No operation error occurs even if an underflow/overflow occurs. Data is output from
follows.
d
as
In case of MUL_TIME_E, TRUE is output from ENO.
(Although the operation result is 64-bit data, data is output in time type with the high-order 32
bits discarded.)
(Example) Overflow
T#24d20h31m23s647ms
(7FFFFFFFH)
2
(00000002H)
T#-2ms
(FFFFFFFEH)
Since the highest-order bit is 1, the result value is negative.
(Example) Underflow
T#-24d20h31m23s648ms
(80000000H)
2
(00000002H)
T#0ms
(00000000H)
Since the highest-order bit is 0, the result value is positive.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
5-200
5.8 Functions of Time Data Type
5.8.3 Multiplication
MUL_TIME(_E)
Operation Error
No operation error occurs in the execution of the MUL_TIME(_E) function.
Program Example
The program which performs multiplication ( s1
(signed) type data input to
s2
s2
) on time type data input to
, and outputs the operation result from
d
s1
and the word
in time type.
(a) Function without EN/ENO (MUL_TIME)
[Structured ladder/FBD]
[ST]
g_time2:= MUL_TIME(g_time1, g_int1);
(b) Function with EN/ENO (MUL_TIME_E)
[Structured ladder/FBD]
5
APPLICATION
FUNCTIONS
[ST]
MUL_TIME(_E)
g_bool3 := MUL_TIME_E(g_bool1, g_time1, g_int1, g_time2);
5.8 Functions of Time Data Type
5.8.3 Multiplication
5-201
DIV_TIME(_E)
5.8.4
Division
DIV_TIME(_E)
Basic
DIV_TIME(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
DIV_TIME
DIV_TIME_E
EN
ENO
s1
DIV_TIME_E
ENO:= DIV_TIME_E (EN, s1, s2, d);
d
s2
Input argument,
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s1(_IN1): Input
:Time
s2(_IN2): Input
:ANY_NUM
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error)
:Bit
d:
Output
:Time
Function
Operation processing
(1) Performs division ( s1 ÷ s2 ) on time type data input to
s1
and the word (signed), double word
(signed), single-precision real or double-precision real type data input to
quotient of the operation result from
d
s2
, and outputs the
in time type. Remainder is rounded down.
(Example) When the input value to s1 and s2 are T#1d2h33m44s55ms (1 day 2 hours 33
minutes 44 seconds 55 milliseconds) and 2.
s1
s2
T#1d2h33m44s55ms
2
d (Quotient)
T#13h16m63s27ms
(Remainder)
T#1ms
Discarded
Time type
(2) The value to be input to
Word (signed)
s1
Time type
is time type data.
(3) The value to be input to s2 is word (signed), double word (signed), single-precision real or
double-precision real type data.
(The value to be input to
5-202
5.8 Functions of Time Data Type
5.8.4 Division
s2
must be other than 0.)
DIV_TIME(_E)
(4) Rounding error may occur when specifying single-precision real or double-precision real
type data to s2 by programming tool.
For the precautions on setting the input value by the programming tool, refer to
MELSEC-Q/L/F Structured Programming Manual (Fundamentals).
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d
.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE*1
Undefined value
d
*1: When FALSE is output from ENO, the data output from d is undefined.
In this case, create a program so that the data output from d is not used.
Operation Error
An operation error occurs in the following cases.
s2
is 0. (Division by zero)
(Error code: 4100)
Program Example
5
The program which performs division ( s1 ÷ s2 ) on time type data input to
(signed) type data input to
type.
s2
s1
and the word
, and outputs the quotient of the operation result from
d
in time
(a) Function without EN/ENO (DIV_TIME)
APPLICATION
FUNCTIONS
• The value input to
DIV_TIME(_E)
[Structured ladder/FBD]
[ST]
g_time2:= DIV_TIME(g_time1, g_int1);
(b) Function with EN/ENO (DIV_TIME_E)
[Structured ladder/FBD]
[ST]
g_bool3 := DIV_TIME_E(g_bool1, g_time1, g_int1, g_time2);
5.8 Functions of Time Data Type
5.8.4 Division
5-203
SR(_E)
5.9 Standard Bistable Function Blocks
5.9.1
Standard bistable function blocks (Set-dominant)
SR(_E)
Basic
SR(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
SR
SR_E
EN
ENO
s1
SR_E
SR_E (EN, s1, s2, ENO, d);
d
s2
Input argument,
EN:
s1(_S1):
s2(RESET):
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d(Q1):
Output
:Bit
Function
Operation processing
Sets
d
5-204
d
when
s1
is turned ON, and resets
is not reset even when
s2
d
when
is turned ON while
5.9 Standard Bistable Function Blocks
5.9.1 Standard bistable function blocks (Set-dominant)
s1
s2
is turned ON while
is ON.
s1
is OFF.
SR(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
ON
s1
OFF
s2
OFF
ON
ON
OFF
OFF
ON
ON
OFF
OFF
.
ON
OFF
ON
ON
OFF
ON
ON
OFF
Sets d when s1 = ON.
OFF
ON
ON
d
ON
d
ON
ON
ON
OFF
OFF
ON
OFF
Resets d when s1 = OFF and s2 = ON.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
[Timing chart]
ON
ON
ON
ON
ON
EN
5
s1
OFF
s2
OFF
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ON
APPLICATION
FUNCTIONS
ON
ON
ENO
ON
OFF
OFF
Sets d when EN = ON and s1 = ON.
ON
OFF
SR(_E)
ON
d
Resets d when EN = ON, s1 = OFF and s2 = ON.
5.9 Standard Bistable Function Blocks
5.9.1 Standard bistable function blocks (Set-dominant)
5-205
SR(_E)
Operation Error
No operation error occurs in the execution of the SR (_E) function.
Program Example
The program which outputs bit type data input to
value of
d
only when bit type data input to
s2
s1
from
d
and holds the output, and resets the
is 1 and the data input to
s1
is 0.
(a) Function without EN/ENO (SR)
[Structured ladder/FBD]
[ST]
SR_Inst(_S1:= g_bool1 ,RESET:= g_bool2 ,Q1:= g_bool3 );
(b) Function with EN/ENO (SR_E)
[Structured ladder/FBD]
[ST]
SR_E_Inst(EN:= X0 ,_S1:= g_bool1 ,_R:= g_bool2 ,Q1:= g_bool3 ,ENO:= Y20 );
5-206
5.9 Standard Bistable Function Blocks
5.9.1 Standard bistable function blocks (Set-dominant)
RS(_E)
5.9.2
Standard bistable function blocks (Reset-dominant)
RS(_E)
Basic
RS(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
RS
RS_E
EN
ENO
s1
RS_E
RS_E (EN, s1, s2, ENO, d);
d
s2
Input argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
Input
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d(Q1):
Output
:Bit
s1(_S):
s2(_R1):
APPLICATION
FUNCTIONS
Output argument,
5
Function
Operation processing
d
d
when
s1
is turned ON, and resets
is not set even when
s1
d
when
is turned ON while
s2
s2
is turned ON.
is ON.
5.9 Standard Bistable Function Blocks
5.9.2 Standard bistable function blocks (Reset-dominant)
RS(_E)
Sets
5-207
RS(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
ON
ON
s1
OFF
s2
OFF
ON
ON
ON
OFF
OFF
ON
ON
OFF
ON
ON
OFF
OFF
ON
ON
OFF
ON
OFF
.
ON
ON
ON
OFF
ON
d
ON
d
ON
ON
OFF
OFF
Turns d ON when s1 = ON Turns d OFF when s2 = ON.
and s2 = OFF.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
[Timing chart]
ON
ON
ON
ON
ON
EN
ON
ON
s1
OFF
s2
OFF
ON
OFF
ON
OFF
ENO
ON
d
OFF
Turns d ON when EN = ON,
s1 = ON and s2 = OFF.
5-208
ON
OFF
Turns d OFF when EN = ON and s2 = ON.
5.9 Standard Bistable Function Blocks
5.9.2 Standard bistable function blocks (Reset-dominant)
OFF
RS(_E)
Operation Error
No operation error occurs in the execution of the RS (_E) function.
Program Example
The program which outputs bit type data input to
forcibly the value of
d
from
s1
when bit type data input to
s2
d
and holds the output, and resets
is 1.
(a) Function without EN/ENO (RS)
[Structured ladder/FBD]
[ST]
RS_Inst(_S:= g_bool1 ,_R1:= g_bool2 ,Q1:= g_bool3 );
(b) Function with EN/ENO (RS_E)
[Structured ladder/FBD]
[ST]
RS(_E)
RS_E_Inst(EN:= X0 ,_S:= g_bool1 ,_R1:= g_bool2 ,Q1:= g_bool3 ,ENO:= Y20 );
APPLICATION
FUNCTIONS
5
5.9 Standard Bistable Function Blocks
5.9.2 Standard bistable function blocks (Reset-dominant)
5-209
R_TRIG(_E)
5.10 Standard Edge Detection Function Blocks
5.10.1
Rising edge detector
R_TRIG(_E)
Basic
R_TRIG(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
R_TRIG
R_TRIG_E
EN
R_TRIG_E (EN, s, ENO, d);
ENO
s
d
Input argument,
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
EN:
s(_CLK): Input
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d(Q):
Output
:Bit
Function
Operation processing
Turns ON
5-210
:Bit
:Bit
d
for one scan when
s
is turned ON.
5.10 Standard Edge Detection Function Blocks
5.10.1 Rising edge detector
R_TRIG_E
R_TRIG(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
ON
ON
s
OFF
d
OFF
ON
ON
ON
OFF
ON
ON
OFF
.
ON
ON
OFF
d
ON
ON
OFF
ON
OFF
OFF
Turns d ON at Turns d OFF at the next scan.
the rising of s .
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
d
[Timing chart]
ON
ON
ON
ON
EN
ON
ON
s
ON
ON
5
OFF
ON
Turns d ON when
EN = ON and the
rising of s .
ON
OFF
Turns d OFF at the next scan.
ON
ON
OFF
OFF
When EN = OFF, d retains the previous scan output result.
R_TRIG(_E)
d
APPLICATION
FUNCTIONS
ENO OFF
Operation Error
No operation error occurs in the execution of the R_TRIG (_E) function.
5.10 Standard Edge Detection Function Blocks
5.10.1 Rising edge detector
5-211
R_TRIG(_E)
Program Example
The program which turns ON
to ON.
d
for one scan when bit type data input to
s
is turned from OFF
(a) Function without EN/ENO (R_TRIG)
[Structured ladder/FBD]
[ST]
R_TRIG_Inst(_CLK:= g_bool1 ,Q:= g_bool2 );
(b) Function with EN/ENO (R_TRIG_E)
[Structured ladder/FBD]
[ST]
R_TRIG_E_Inst(EN:= X0 ,_CLK:= g_bool1 ,Q:= g_bool2 ,ENO:= Y20 );
5-212
5.10 Standard Edge Detection Function Blocks
5.10.1 Rising edge detector
F_TRIG(_E)
5.10.2
Falling edge detector
F_TRIG(_E)
Basic
F_TRIG(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
F_TRIG
F_TRIG_E
F_TRIG_E
EN
F_TRIG_E (EN, s, ENO, d);
ENO
s
d
Input argument,
EN:
:Bit
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d(Q):
Output
:Bit
5
APPLICATION
FUNCTIONS
Output argument,
Executing condition (TRUE: Execution, FALSE: Stop)
s(_CLK): Input
Function
Operation processing
d
for one scan when
s
is turned OFF.
F_TRIG(_E)
Turns ON
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
ON
s
OFF
d
OFF
ON
OFF
ON
Turns d ON at the
falling of s .
ON
OFF
ON
ON
OFF
ON
d
.
ON
OFF
ON
ON
OFF
OFF
ON
ON
OFF
Turns d OFF at the next scan.
5.10 Standard Edge Detection Function Blocks
5.10.2 Falling edge detector
5-213
F_TRIG(_E)
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
d
[Timing chart]
ON
ON
EN
OFF
s
OFF
ON
ON
ON
ON
OFF
ON
ON
ON
ON
ON
OFF
OFF
ON
ON
ON
ON
OFF
ON
ENO OFF
ON
d
ON
OFF
OFF
ON
OFF
OFF
Turns d ON when EN = ON Turns d OFF at When EN = OFF, d retains the previous scan output result.
and the falling of s .
the next scan.
Operation Error
No operation error occurs in the execution of the F_TRIG (_E) function.
Program Example
The program which turns ON
OFF.
d
for one scan when bit type data input to
s
is turned from ON to
(a) Function without EN/ENO (F_TRIG)
[Structured ladder/FBD]
[ST]
F_TRIG_Inst(_CLK:= g_bool1 ,Q:= g_bool2 );
(b) Function with EN/ENO (F_TRIG_E)
[Structured ladder/FBD]
[ST]
F_TRIG_E_Inst(EN:= X0 ,_CLK:= g_bool1 ,Q:= g_bool2 ,ENO:= Y20 );
5-214
5.10 Standard Edge Detection Function Blocks
5.10.2 Falling edge detector
CTU(_E)
5.11 Standard Counter Function Blocks
5.11.1
Up counter
CTU(_E)
Basic
CTU(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
CTU_E
EN
CTU
ENO
s1
d1
s2
d2
CTU_E
ENO:= CTU_E (EN, s1, s2, n, d1, d2);
5
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s1(CU):
Count signal input
:Bit
s2(RESET): Count reset
:Bit
n(PV):
Maximum count value
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d1(Q):
Count match output
:Bit
d2(CV):
Count value
:Word (signed)
APPLICATION
FUNCTIONS
n
CTU(_E)
Function
Operation processing
(1) Counts
d2
when
s1
is turned ON.
When the count value
When
s2
d2
is turned ON,
reaches the value input to n,
d1
turns OFF and count value
d2
d1
turns ON.
is reset.
(2) Valid setting range for n is -32768 to 32767.
However, if 0 or less is set,
d1
is turned on regardless of the count value of
5.11 Standard Counter Function Blocks
5.11.1 Up counter
d2
.
5-215
CTU(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
ON
s1
OFF
s2
OFF
d1
OFF
ON
ON
OFF
ON
ON
OFF
d1
and
.
ON
ON
OFF
d2
ON
OFF
ON
OFF
ON
d2
OFF
0
1
2
3
0
Counts d2 up when s1 = ON.
1
2
Clears d2 0 when s2 = ON.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
,
d2
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
[Timing chart]
ON
s1
OFF
s2
OFF
ON
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
OFF
ON
OFF
ON
ON
ON
ON
ON
ENO OFF
ON
d1
OFF
d2
OFF
0
1
Turns d2 ON when EN = ON and s1 = ON.
2
3
0
Clears d2 0 when s2 = ON.
Operation Error
No operation error occurs in the execution of the CTU (_E) function.
5-216
5.11 Standard Counter Function Blocks
5.11.1 Up counter
1
CTU(_E)
Program Example
The program which counts the number of times that bit type data input to
to ON, and outputs the count value from
d2
s1
is turned from OFF
.
(a) Function without EN/ENO (CTU)
[Structured ladder/FBD]
[ST]
CTU_Inst(CU:= g_bool1 ,RESET:= g_bool2 ,PV:= g_int1 ,Q:= g_bool3 ,CV:= g_int2 );
(b) Function with EN/ENO (CTU_E)
[Structured ladder/FBD]
[ST]
5
CTU(_E)
APPLICATION
FUNCTIONS
CTU_E_Inst(EN:= M10 ,CU:= g_bool1 ,RESET:= g_bool2 ,PV:= g_int1, Q:= g_bool3,
CV:= g_int2 ,ENO:= M11 );
5.11 Standard Counter Function Blocks
5.11.1 Up counter
5-217
CTD(_E)
5.11.2
Down counter
CTD(_E)
Basic
CTD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
functions.
CTD_E
EN
CTD
ENO
s1
d1
s2
d2
CTD_E
CTD_E (EN, s1, s2, n, ENO, d1, d2);
n
Input argument,
Output argument,
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s1(CU):
Count signal input
:Bit
s2(LOAD):
Count reset
:Bit
n(PV):
Count start value
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d1(Q):
Count match output
:Bit
d2(CV):
Count value
:Word (signed)
:Bit
Function
Operation processing
(1) Counts down (-1)
d2
when
s1
is turned ON.
n sets the initial value for subtraction.
turns ON when count value
d1
When
d2
s2
is turned ON,
d1
d2
reaches 0.
turns OFF and initial value for subtraction n is set for count value
.
(2) Valid setting range for n is -32768 to 32767.
However, if 0 or less is set,
5-218
d1
is turned on regardless of the count value of
5.11 Standard Counter Function Blocks
5.11.2 Down counter
d2
.
CTD(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
d1
and
d2
.
When n=3
ON
s1
OFF
s2
OFF
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ON
ON
OFF
OFF
ON
OFF
OFF
ON
ON
d1
OFF
d2
ON
OFF
0
OFF
3
2
Initializes d2 when s2 = ON.
1
0
3
2
1
Counts d2 down at the falling of s1 .
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
,
d2
[Timing chart]
5
When n=3
OFF
s1
OFF
s2
OFF
ON
ON
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
OFF
ON
OFF
APPLICATION
FUNCTIONS
ON
ON
EN
ON
OFF
OFF
ON
ON
d1
d2
CTD(_E)
ENO OFF
OFF
0
OFF
3
Initializes d2 when EN = ON
and s2 = ON.
2
1
0
-1
-2
-3
Counts d2 down when EN = ON and the falling of s1 .
Operation Error
No operation error occurs in the execution of the CTD (_E) function.
5.11 Standard Counter Function Blocks
5.11.2 Down counter
5-219
CTD(_E)
Program Example
The program which counts the number of times that bit type data input to
to ON, and turns ON
d1
when the value of
d2
s1
is turned from OFF
reaches 0.
(a) Function without EN/ENO (CTD)
[Structured ladder/FBD]
[ST]
CTD_Inst(CD:= g_bool1 ,LOAD:= g_bool2 ,PV:= g_int1 ,Q:= g_bool3, CV:= g_int2 );
(b) Function with EN/ENO (CTD_E)
[Structured ladder/FBD]
[ST]
CTD_E_Inst(EN:= M10 ,CD:= g_bool1 ,LOAD:= g_bool2 ,PV:= g_int1, Q:= g_bool3,
CV:= g_int2 ,ENO:= M11 );
5-220
5.11 Standard Counter Function Blocks
5.11.2 Down counter
CTUD(_E)
5.11.3
Up/Down counter
CTUD(_E)
Basic
CTUD(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
functions.
CTUD
Structured ladder/FBD
CTUD_E
ST
CTUD_E
ENO
d1
s2
d2
s3
s4
n
d3
Output argument,
(EN, s1, s2, s3, s4, n,
ENO, d1, d2, d3);
5
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
s1(CU):
Count-up signal input
:Bit
s2(CD):
Count-down signal input
:Bit
s3(RESET):
Count-up reset
:Bit
s4(LOAD):
Count-down reset
:Bit
n(PV):
Maximum count value
:Word (signed)
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d1(QU):
Count-up match output
:Bit
d2(QD):
Count-down match output
:Bit
d3(CV):
Current count value
:Word (signed)
:Bit
CTUD(_E)
Input argument,
CTUD_E
APPLICATION
FUNCTIONS
EN
s1
Function
Operation processing
(1) Counts up (+1) d3 when s1 is turned ON, and counts down (−1)
n sets the maximum value of counter.
d2
turns ON when
d3
reaches 0.
d1
turns ON when
d3
reaches the maximum value n.
Resets
d3
when
s3
d3
when
s2
is turned ON.
turns ON.
The value of n is set to
d3
when
s4
is turned ON.
(2) Valid setting range for n is -32768 to 32767.
However, if 0 or less is set,
d1
,
d2
are turned on regardless of the count value of
5.11 Standard Counter Function Blocks
5.11.3 Up/Down counter
d3
.
5-221
CTUD(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
d1
,
d2
, and
d3
ON
ON
.
When n=3
ON
s1
OFF
s2
OFF
s3
OFF
s4
OFF
d1
OFF
ON
ON
OFF
OFF
ON
OFF
ON
ON
OFF
OFF
ON
ON
ON
OFF
OFF
OFF
OFF
ON
OFF
ON
OFF
ON
OFF
OFF
d2
d3
0
1
2
0
1
2
3
2
3
2
1
0
Counts d3 up when s1 is Initializes d3 when s3
Counts d3 down when s2 Initializes d3 when s4 is turned from
turned from OFF to ON.
is turned from OFF to ON. is turned from OFF to ON. OFF to ON.
5-222
5.11 Standard Counter Function Blocks
5.11.3 Up/Down counter
CTUD(_E)
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
,
d2
,
d3
[Timing chart]
When n=3
ON
ON
EN
OFF
s1
OFF
s2
OFF
s3
OFF
s4
OFF
ON
ON
OFF
ON
OFF
ON
ON
OFF
ON
OFF
ON
ON
OFF
ON
ON
OFF
ON
ON
ON
OFF
ON
ON
OFF
OFF
ON
OFF
OFF
ON
ON
OFF
ON
ON
ON
OFF
ON
OFF
ON
ON
ENO OFF
ON
d1
5
OFF
OFF
d3
0
1
2
0
1
0
2
1
Initializes d3 when EN = ON
and s4 is turned from OFF to ON.
CTUD(_E)
Clears d3 0 when
Counts d3 up when EN = ON
Counts d3 down when
and s1 is turned from OFF to ON. EN = ON and s3 is
EN = ON and s2 is turned
turned from OFF to ON. from OFF to ON.
3
APPLICATION
FUNCTIONS
d2
5.11 Standard Counter Function Blocks
5.11.3 Up/Down counter
5-223
CTUD(_E)
Operation Error
No operation error occurs in the execution of the CTUD (_E) function.
Program Example
The program which counts the number of times that bit type data input to
to ON, and turns ON
d1
when the value of
d3
reaches the value set at
counts the number of times that bit type data input to
d2
when the value of
d3
s2
n
s1
is turned from OFF
. Simultaneously, it
is turned from OFF to ON, and turns ON
reaches 0.
(a) Function without EN/ENO (CTD)
[Structured ladder/FBD]
[ST]
CTUD_Inst(CU:= g_bool1 ,CD :=g_bool2 ,RESET:= g_bool3 ,LOAD:= g_bool4,
PV:= g_int1 ,QU:= g_bool5 ,QD:= g_bool6 ,CV:= g_int2 );
(b) Function with EN/ENO (CTD_E)
[Structured ladder/FBD]
[ST]
CTUD_E_Inst(EN:= M0 ,CU:= g_bool1 ,CD:= g_bool2 ,RESET:= g_bool3,
LOAD:= g_bool4 ,PV:= g_int1 ,QU:= g_bool5 ,QD:= g_bool6 ,CV:= g_int2,
ENO:= M10 );
5-224
5.11 Standard Counter Function Blocks
5.11.3 Up/Down counter
COUNTER_FB_M
5.11.4
Counter function blocks
COUNTER_FB_M
Basic
High
performance
Universal
L CPU
COUNTER_FB_M
indicates the following function.
COUNTER_FB_M
Structured ladder/FBD
ST
COUNTER_FB_M
s1
d1
s2
d2
COUNTER_FB_M (s1, s2, s3, d1, d2)
s3
Output argument,
s1(Coil):
Executing condition (TRUE: Execution, FALSE: Stop)
s2(Preset):
Counter setting value
:Word (signed)
s3(ValueIn):
Counter initial value
:Word (signed)
d1(ValueOut):
Counter current value
:ANY16
d2(Status):
Output
:Bit
5
:Bit
APPLICATION
FUNCTIONS
Input argument,
Operation processing
(1) Counts the detected rising edge (from OFF to ON) of
ON. The count starts from the value input to
input to
s2
,
d2
s3
s1
(3) Valid setting range for
initial value is 0.
s1
stays
and when the count value reaches the value
turns ON. The current value is stored in
(2) Valid setting range for
. It is not counted when
d1
.
s2
is 0 to 32767.
s3
is -32768 to 32767. however, if negative value is specified, the
5.11 Standard Counter Function Blocks
5.11.4 Counter function blocks
5-225
COUNTER_FB_M
Function
COUNTER_FB_M
(4) When resetting the current value of the counter, reset
s1
.
(Example) When instance name is COUNTER_FB_M_1.
[Structured ladder/FBD]
Resets s1 (Coil)
[ST]
COUNTER_FB_M_1(Coil:=Var_M0, Preset:=10, ValueIn:=0, ValueOut:=Var_D10,
Status:=Var_M10);
RST(M15, COUNTER_FB_M_1.Coil);
Operation Error
No operation error occurs in the execution of the counter function blocks.
Program Example
The program which counts the number of times that bit type data input to
to ON, and outputs the count value from
d1
s1
.
[Structured ladder/FBD]
[ST]
COUNTER_FB_M_Inst(Coil:= Var_M0 ,Preset:= 10 ,ValueIn:= 0,
ValueOut:= Var_D10 ,Status:= Var_M10 );
[Timing chart]
ON
Var_M0
OFF
Value of Var_D10
1
2
3
10
ON
Var_M10 OFF
5-226
5.11 Standard Counter Function Blocks
5.11.4 Counter function blocks
is turned from OFF
TP(_E), TP_HIGH(_E)
5.12 Standard Timer Function Blocks
5.12.1
Pulse timer
TP(_E), TP_HIGH(_E)
Basic
TP(_E)
TP_HIGH(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TP_HIGH_E
ENO
s
d1
n
d2
Input argument,
Output argument,
TP_E
TP_HIGH
TP_HIGH_E
ENO:= TP_HIGH_E (EN, s, n, d1, d2);
5
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(IN):
Input
:Bit
n(PT):
Output time setting value
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d1(Q):
Output
:Bit
d2(ET):
Elapsed time
:Time
APPLICATION
FUNCTIONS
EN
TP
TP(_E),
TP_HIGH(_E)
Function
Operation processing
Turns ON
which
d1
d1
for the duration set to n after
stays ON is set to
d2
s
is turned ON. The duration (elapsed time) during
.
When the elapsed time reaches the preset time,
The elapsed time is not reset even when
After
d1
turns OFF, it is reset when
s
d1
d1
turns OFF.
turns OFF.
is OFF.
5.12 Standard Timer Function Blocks
5.12.1 Pulse timer
5-227
TP(_E), TP_HIGH(_E)
(1) TP(_E)
Uses a low-speed timer to count the elapsed time.
Output time can be set between 1ms and 1000ms. The unit is set in Timer limit setting on the
PLC system of PLC parameter.
Valid setting range for n is T#0ms to T#3276700ms.
(2) TP_HIGH(_E)
Uses a high-speed timer to count the elapsed time.
Output time can be set between 0.01ms and 100ms for Universal model QCPU, 0.1ms and
100ms for High Performance model QCPU.
Valid setting range for n is T#0ms to T#327670ms.
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
d1
and
d2
.
When n = T#5s (5 seconds)
ON
s
OFF
d1
OFF
ON
ON
OFF
ON
d2
ON
OFF
0
0
1
2
3
Turns d1 ON when s = ON.
Starts measuring d2 when s = ON.
4
5
0
Turns d1 OFF when d2
reaches the time set to n.
0
1
2
3
4
Initializes d2 when s = OFF and d1 = OFF.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
,
d2
[Timing chart]
When n = T#5s (5 seconds)
ON
ON
ON
ON
ON
EN OFF
ON
s
OFF
OFF
ENO OFF
ON
d1
d2
ON
OFF
0
OFF
0
1
2
3
4
Measuring time counts up every time when
EN = ON after starting measuring.
Turns d1 ON when EN = ON and s = ON.
Starts measuring d2 when EN = ON and s = ON.
5-228
5.12 Standard Timer Function Blocks
5.12.1 Pulse timer
5
0
1
2
3
Initializes d2 when EN = ON, s = OFF and d1 = OFF.
Turns d1 OFF when d2 reaches the time set to n .
TP(_E), TP_HIGH(_E)
Operation Error
No operation error occurs in the execution of the TP (_E) function.
Program Example
The program which turns ON bit type data of
turned ON.
d1
for 10 seconds after bit type data input to
s
is
(a) Function without EN/ENO (TP)
[Structured ladder/FBD]
[ST]
TP_Inst(IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1 );
(b) Function with EN/ENO (TP_E)
[Structured ladder/FBD]
5
APPLICATION
FUNCTIONS
[ST]
TP(_E),
TP_HIGH(_E)
TP_E_Inst(EN:= M0 ,IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1,
ENO:= M10 );
5.12 Standard Timer Function Blocks
5.12.1 Pulse timer
5-229
TON(_E), TON_HIGH(_E)
5.12.2
On delay timer
TON(_E), TON_HIGH(_E)
Basic
TON(_E)
TON_HIGH(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
ST
TON_HIGH_E
EN
ENO
s
d1
n
d2
Input argument,
Output argument,
functions.
TON
TON_E
TON_HIGH
TON_HIGH_E
ENO:= TON_HIGH_E (EN, s, n, d1, d2);
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(IN):
Input
:Bit
n(PT):
Delay time setting value
:Time
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
:Bit
d1(Q):
Output
:Bit
d2(ET):
Elapsed time
:Time
Function
Operation processing
Turns ON
d1
d1
when
s
is turned ON after the elapse of the time set to n. Elapsed delay time until
is turned ON is set to
When
s
is turned OFF,
d2
d1
.
turns OFF and the elapsed delay time is reset.
(1) TON(_E)
Uses a low-speed timer to count the elapsed time.
Output time can be set between 1ms and 1000ms. The unit is set in Timer limit setting on the
PLC system of PLC parameter.
Valid setting range for n is T#0ms to T#3276700ms.
(2) TON_HIGH(_E)
Uses a high-speed timer to count the elapsed time.
Output time can be set between 0.01ms and 100ms for Universal model QCPU, 0.1ms and
100ms for High Performance model QCPU. The unit is set in Timer limit setting on the PLC
system of PLC parameter.
Valid setting range for n is T#0ms to T#327670ms.
5-230
5.12 Standard Timer Function Blocks
5.12.2 On delay timer
TON(_E), TON_HIGH(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
d1
and
d2
.
[Timing chart]
When n = T#5s (5 seconds)
ON
ON
s
OFF
OFF
ON
d1
OFF
d2
OFF
0
0
1
2
Starts measuring d2 when s = ON.
3
4
5
0
Turns d1 ON when d2
reaches the time set to n .
0
1
2
3
0
Resets d2 at the falling of s .
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
,
d2
[Timing chart]
When n = T#5s (5 seconds)
ON
OFF
s
OFF
ON
ON
ON
ON
5
ON
ON
OFF
APPLICATION
FUNCTIONS
EN
OFF
ENO
ON
d2
OFF
OFF
0
0
1
2
Starts measuring d2 when EN = ON and s = ON.
3
4
5
Turns d1 ON when d2 reaches
the time set to n .
0
Turns d1 OFF and resets d2
when EN = ON and s = OFF.
5.12 Standard Timer Function Blocks
5.12.2 On delay timer
5-231
TON(_E),
TON_HIGH(_E)
d1
TON(_E), TON_HIGH(_E)
Operation Error
No operation error occurs in the execution of the TON (_E) function.
Program Example
The program which turns ON bit type data of
turned ON.
d1
10 seconds after bit type data input to
(a) Function without EN/ENO (TON)
[Structured ladder/FBD]
[ST]
TON_Inst(IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1 );
(b) Function with EN/ENO (TON_E)
[Structured ladder/FBD]
[ST]
TON_E_Inst(EN:= M0 ,IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1,
ENO:= M10 );
5-232
5.12 Standard Timer Function Blocks
5.12.2 On delay timer
s
is
TOF(_E), TOF_HIGH(_E)
5.12.3
Off delay timer
TOF(_E), TOF_HIGH(_E)
Basic
TOF(_E)
TOF_HIGH(_E)
High
performance
Universal
L CPU
_E: With EN/ENO
indicates any of the following
Structured ladder/FBD
functions.
ST
TOF_HIGH_E
ENO
s
d1
n
d2
Input argument,
Output argument,
TOF_E
TOF_HIGH
TOF_HIGH_E
ENO:= TOF_HIGH_E (EN, s, n, d1, d2);
EN:
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s(IN):
Input
:Bit
n(PT):
Delay time setting value
:Time
:Bit
ENO:
Execution result (TRUE: Normal, FALSE: Error or stop)
d1(Q):
Output
:Bit
d2(ET):
Elapsed time
:Time
5
APPLICATION
FUNCTIONS
EN
TOF
Function
Turns ON
when
d1
Turns OFF
d1
when
is turned ON.
s
s
is turned from ON to OFF after the elapse of the time set to n. Elapsed
time until
d1
When
is turned ON again,
s
is turned OFF is set to
d1
d2
.
turns ON and the elapsed time is reset.
(1) TOF(_E)
Uses a low-speed timer to count the elapsed time.
Output time can be set between 1ms and 1000ms. The unit is set in Timer limit setting on the
PLC system of PLC parameter.
Valid setting range for n is T#0ms to T#3276700ms.
(2) TOF_HIGH(_E)
Uses a high-speed timer to count the elapsed time.
Output time can be set between 0.01ms and 100ms for Universal model QCPU, 0.1ms and
100ms for High Performance model QCPU. The unit is set in Timer limit setting on the PLC
system of PLC parameter.
Valid setting range for n is T#0ms to T#327670ms.
5.12 Standard Timer Function Blocks
5.12.3 Off delay timer
5-233
TOF(_E),
TOF_HIGH(_E)
Operation processing
TOF(_E), TOF_HIGH(_E)
Operation result
(1) Function without EN/ENO
An operation is executed and the operation value is output from
[Timing chart]
d1
and
d2
.
When n = T#5s (5 seconds)
ON
s
OFF
d1
OFF
ON
ON
OFF
OFF
ON
ON
OFF
d2
0
0
1
2
Starts measuring d2
when s = OFF.
3
4
5
0
Turns d1 OFF when d2 reaches
the time set to n .
1
2
3
4
0
1
Resets d2 when s = ON.
(2) Function with EN/ENO
The following table shows the executing conditions and operation results.
EN
ENO
d1
,
d2
TRUE (Operation execution)
TRUE
Operation output value
FALSE (Operation stop)
FALSE
Previous output value
[Timing chart]
When n = T#5s (5 seconds)
ON
EN
OFF
s
OFF
ON
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ON
ON
OFF
OFF
ON
ON
ON
ENO OFF
OFF
ON
OFF
ON
OFF
OFF
ON
d1
OFF
d2
0
0
1
Starts measuring d2
when EN = ON and s = OFF.
2
3
4
0
No operation error occurs in the execution of the TOF(_E) function.
5.12 Standard Timer Function Blocks
5.12.3 Off delay timer
1
Resets d2 when EN = ON and s = ON.
Operation Error
5-234
0
0
TOF(_E), TOF_HIGH(_E)
Program Example
The program which turns ON bit type data of
turns
d1
OFF 10 seconds after
s
d1
when bit type data input to
s
is turned ON, and
is turned OFF.
(a) Function without EN/ENO (TOF)
[Structured ladder/FBD]
[ST]
TOF_Inst(IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1 );
(b) Function with EN/ENO (TOF_E)
[Structured ladder/FBD]
[ST]
TOF_E_Inst(EN:= M0 ,IN:= g_bool1 ,PT:= T#10s ,Q:= g_bool2 ,ET:= g_time1,
ENO:= M10 );
TOF(_E),
TOF_HIGH(_E)
APPLICATION
FUNCTIONS
5
5.12 Standard Timer Function Blocks
5.12.3 Off delay timer
5-235
TIMER_10_FB_M
5.12.4
Timer function blocks
TIMER_10_FB_M
Basic
High
performance
Universal
L CPU
TIMER_10_FB_M
TIMER_100_FB_M
TIMER_HIGH_FB_M
TIMER_LOW_FB_M
TIMER_CONT_FB_M
TIMER_CONTHFB_M
indicates any of the following
Structured ladder/FBD
functions.
ST
TIMER_10_FB_M
s1
d1
s2
d2
CAL
TIMER_10_FB_M (s1, s2, s3, d1, d2)
TIMER_10_FB_M
TIMER_100_FB_M
TIMER_HIGH_FB_M
TIMER_LOW_FB_M
TIMER_CONT_FB_M
TIMER_CONTHFB_M
s3
Input argument,
Output argument,
s1(Coil):
Executing condition (TRUE: Execution, FALSE: Stop)
:Bit
s2(Preset):
Timer setting value
:Word (signed)
s3(ValueIn):
Timer initial value
:Word (signed)
d1(ValueOut): Timer current value
:ANY16
d2(Status):
:Bit
Output
Function
Operation processing
(1) TIMER_10_FB_M
(a) Starts measuring the current value when the executing condition of
Starts measuring from the value input to
reaches to the value input to
s3
10ms,
s2
d2
s1
turns ON.
10ms, and when the measuring value
turns ON.
The current value is output from
d1
.
(b) When the executing condition of
s1
turns OFF, the current value is set to the value input
to
s3
, and
d2
turns OFF.
(c) When the unit of measurement (time period) for the high-speed timer is changed from
default value of PLC parameter, warning C9047 occurs in compilation.
(d) Valid setting range for
(e) Valid setting range for
the initial value is 0.
5-236
s2
is 0 to 32767.
s3
is -32768 to 32767. However, if negative value is specified,
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
TIMER_10_FB_M
(2) TIMER_100_FB_M
(a) Starts measuring the current value when the executing condition of
Starts measuring from the value input to
reaches to the value input to
turns ON.
100ms, and when the measuring value
s3
100ms,
s2
s1
d2
turns ON.
The current value is output from
d1
.
(b) When the executing condition of
s1
turns OFF, the current value is set to the value input
to
s3
, and
d2
turns OFF.
(c) When the unit of measurement (time period) for the low-speed timer is changed from
default value of PLC parameter, warning C9047 occurs in compilation.
(d) Valid setting range for
(e) Valid setting range for
the initial value is 0.
s2
is 0 to 32767.
s3
is -32768 to 32767. However, if negative value is specified,
(3) TIMER_HIGH_FB_M
(a) The high-speed timer with the unit of measurement from 0.1 to 100ms. Starts
measuring the current value when the executing condition of
s1
turns ON.
Starts measuring from the value input to
s3
value reaches to the value input to
s2
0.1 to 100ms,
The current value is output from
d1
.
(b) When the executing condition of
s1
turns OFF, the current value is set to the value input
, and
d2
turns ON.
5
turns OFF.
(c) The default value of the unit of measurement (time period) for the high-speed timer is
10ms.
The unit of measurement can be changed within the range of 0.01ms to 100ms for
Universal model QCPU, 0.1ms to 100ms for High Performance model QCPU.
This setting is set in the PLC system setting of the PLC parameter.
(d) Valid setting range for
(e) Valid setting range for
the initial value is 0.
s2
is 0 to 32767.
s3
is -32768 to 32767. However, if negative value is specified,
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
5-237
APPLICATION
FUNCTIONS
s3
d2
TIMER_10_FB_M
to
0.1 to 100ms, and when the measuring
TIMER_10_FB_M
(4) TIMER_LOW_FB_M
(a) The low-speed timer with the unit of measurement from 1 to 1000ms. Starts measuring
the current value when the executing condition of
s1
turns ON.
Starts measuring from the value input to
s3
value reaches to the value input to
s2
1 to 1000ms,
The current value is output from
d1
.
(b) When the executing condition of
s1
turns OFF, the current value is set to the value input
to
s3
, and
d2
1 to 1000ms, and when the measuring
d2
turns ON.
turns OFF.
(c) The default value of the unit of measurement (time period) for the low-speed timer is
100ms.
The unit of measurement is from 1 to 1000ms and it can be changed by unit of 1ms.
This setting is set in the PLC system setting of the PLC parameter.
(d) Valid setting range for
(e) Valid setting range for
the initial value is 0.
s2
is 0 to 32767.
s3
is -32768 to 32767. However, if negative value is specified,
(5) TIMER_CONT_FB_M, TIMER_CONTHFB_M
(a) The retentive timer that measures the time during variable is ON. Starts measuring the
current value when the executing condition of s1 turns ON. The low-speed retentive
timer (TIMER_CONT_FB_M) and the high-speed retentive timer
(TIMER_CONTHFB_M) are the two types of retentive timer.
Starts measuring from the value input to
reaches to the value input to
1 to 1000ms, and when the count value
1 to 1000ms,
s2
The current value is output from
s3
d1
d2
turns ON.
.
(b) Even when the executing condition of
s1
turns OFF, the ON/OFF statuses of measuring
value d1 and d2 are retained. When the executing condition of
restarts measuring from the values that are retained.
s1
turns ON again,
(c) The unit of measurement (time period) for retentive timer is same as the low-speed
timer (TIMER_LOW_FB_M) and the high-speed timer (TIMER_HIGH_FB_M).
• Low-speed retentive timer : Low-speed timer
• High-speed retentive timer : High-speed timer
(d) Valid setting range for
(e) Valid setting range for
the initial value is 0.
5-238
s2
is 0 to 32767.
s3
is -32768 to 32767. However, if negative value is specified,
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
TIMER_10_FB_M
(f)
When resetting the current value of the retentive timer, reset
(Example) When instance name is TIMER_CONT_FB_M_1.
[Structured ladder/FBD]
s1
.
Resets s1 (Coil)
[ST]
TIMER_CONT_FB_M_1(Coil:=Var_M0, Preset:=10, ValueIn:=0, ValueOut:=Var_D10,
Status:=Var_M10);
RST(M15,TIMER_CONT_FB_M_1.Coil);
Operation Error
No operation error occurs in the execution of the timer function blocks.
TIMER_10_FB_M
APPLICATION
FUNCTIONS
5
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
5-239
TIMER_10_FB_M
Program Example
(1) TIMER_10_FB_M
The program which starts measuring from
s3
10ms when the executing condition of
turns ON, and when the measuring value reaches to the value input to
ON.
s2
10ms,
d2
s1
turns
[Structured ladder/FBD]
[ST]
TIMER_10_FB_M_Inst(Coil:= Var_M0 ,Preset:= 10 ,ValueIn:= 1 ,ValueOut:=
Var_D10 ,Status:= Var_M10 );
[Timing chart]
ON
Var_M0
OFF
10
Value of Var_D10 1
90ms
Var_M10 OFF
(2) TIMER_HIGH_FB_M
The program which starts measuring from
s3
10ms when the executing condition of
turns ON, and when the measuring value reaches to the value input to
ON.
s2
10ms,
d2
[Structured ladder/FBD]
[ST]
TIMER_HIGH_FB_M_Inst(Coil:= Var_M0 ,Preset:= 10 ,ValueIn:= 1 ,ValueOut:=
Var_D10 ,Status:= Var_M10);
[Timing chart]
ON
Var_M0
OFF
Value of Var_D10 1
10
90ms
Var_M10 OFF
5-240
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
s1
turns
TIMER_10_FB_M
(3) TIMER_LOW_FB_M
The program which starts measuring from
s3
10ms when the executing condition of
turns ON, and when the measuring value reaches to the value input to
turns ON.
s2
100ms,
s1
d2
[Structured ladder/FBD]
[ST]
TIMER_LOW_FB_M_Inst(Coil:= Var_M0 ,Preset:= 10 ,ValueIn:= 1 ,ValueOut:=
Var_D10 ,Status:= Var_M10);
[Timing chart]
ON
Var_M0
OFF
10
Value of Var_D10 1
900ms
Var_M10 OFF
(4) TIMER_CONT_FB_M
The program which measures from
the value input to
100ms,
s2
d2
s3
10ms, and when the measuring value reaches to
5
turns ON.
APPLICATION
FUNCTIONS
[Structured ladder/FBD]
[ST]
TIMER_10_FB_M
TIMER_CONT_FB_M_Inst(Coil:= Var_M0 ,Preset:= 200 ,ValueIn:= 0 ,Value
Out:= Var_D10 ,Status:= Var_M10);
[Timing chart]
ON
Var_M0
15sec
OFF
Value of Var_D10
0
1
to
5sec
150
151 to 200
ON
Var_M10 OFF
5.12 Standard Timer Function Blocks
5.12.4 Timer function blocks
5-241
MEMO
5-242
6
OVERVIEW
1
OPERATOR
FUNCTION TABLES
2
6.3
Comparison Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16
4
HOW TO READ
FUNCTIONS
Logical Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
5
APPLICATION
FUNCTIONS
6.2
6
OPERATOR
Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
I
INDEX
6.1
CONFIGURATION
OF FUNCTIONS
3
6-1
ADD, +
6.1 Arithmetic Operations
6.1.1
Addition
ADD, +
Basic
High
performance
Universal
L CPU
ADD
+
indicates any of the following
Structured ladder/FBD
operator.
ST
ADD
ADD
s1
d
Not supported
s2
s28
indicates any of the following
Structured ladder/FBD
operator.
ST
+
d:=s1 + s2
Not supported
s28;
Input argument,
s1 to s28:
Input
:ANY_NUM
Output argument,
d:
Output
:ANY_NUM
Function
Operation processing
For details of the operation processing, refer to Section 5.3.1.
Operation Error
No operation error occurs in the execution of the ADD and + operations.
6-2
6.1 Arithmetic Operations
6.1.1 Addition
ADD, +
Program Example
The program which performs addition ( s1 + s2 ) on double word (signed) type data input to
, and outputs the operation result from
d
in the same data type as that of
s1
and
s2
and
.
[Structured ladder/FBD]
[ST]
g_dint3:= (g_dint1) + (g_dint2);
OPERATOR
6
ADD, +
s2
s1
6.1 Arithmetic Operations
6.1.1 Addition
6-3
MUL, *
6.1.2
Multiplication
MUL, *
Basic
High
performance
Universal
L CPU
MUL
*
indicates any of the following
Structured ladder/FBD
operator.
ST
MUL
MUL
s1
d
Not supported
s2
s28
indicates any of the following
Structured ladder/FBD
operator.
ST
*
d:=s1 * s2
Not supported
s28;
Input argument,
s1 to s28:
Input
:ANY_NUM
Output argument,
d:
Output
:ANY_NUM
Function
Operation processing
For details of the operation processing, refer to Section 5.3.2.
Operation Error
No operation error occurs in the execution of the MUL and * operations.
6-4
6.1 Arithmetic Operations
6.1.2 Multiplication
MUL, *
Program Example
The program which performs multiplication ( s1
and
s2
, and outputs the operation result from
d
) on double word (signed) type data input to
in the same data type as that of
s1
and
s2
.
[Structured ladder/FBD]
[ST]
g_dint3:= (g_dint1) * (g_dint2);
OPERATOR
6
MUL, *
s1
s2
6.1 Arithmetic Operations
6.1.2 Multiplication
6-5
SUB, -
6.1.3
Subtraction
SUB, Basic
High
performance
Universal
L CPU
SUB
-
indicates any of the following
Structured ladder/FBD
ST
operator.
SUB
SUB
s1
Not supported
d
s2
indicates any of the following
Structured ladder/FBD
ST
operator.
-
d:=s1 - s2;
Not supported
Input argument,
s1:
s2:
Output argument,
d:
Input
:ANY_NUM
Output
:ANY_NUM
Function
Operation processing
For details of the operation processing, refer to Section 5.3.3.
Operation Error
No operation error occurs in the execution of the SUB and - operations.
6-6
6.1 Arithmetic Operations
6.1.3 Subtraction
SUB, -
Program Example
The program which performs subtraction ( s1 −
s2
, and outputs the operation result from
d
) on double word (signed) type data input to
in the same data type as that of
s1
and
s2
s1
.
[Structured ladder/FBD]
[ST]
g_dint3:= (g_dint1) - (g_dint2);
OPERATOR
6
SUB, -
and
s2
6.1 Arithmetic Operations
6.1.3 Subtraction
6-7
DIV, /
6.1.4
Division
DIV, /
Basic
High
performance
Universal
L CPU
DIV
/
indicates any of the following
Structured ladder/FBD
operator.
ST
DIV
DIV
s1
Not supported
d
s2
indicates any of the following
Structured ladder/FBD
operator.
ST
/
d:=s1 /
Not supported
Input argument,
s1:
s2:
Output argument,
d:
s2;
Input
:ANY_NUM
Output
:ANY_NUM
Function
Operation processing
For details of the operation processing, refer to Section 5.3.4.
Operation Error
An operation error occurs in the following case.
• The value to be input to
6-8
6.1 Arithmetic Operations
6.1.4 Division
s2
is 0. (Division by 0)
(Error code: 4100)
DIV, /
Program Example
The program which performs division ( s1 ÷ s2 ) on double word (signed) type data input to
, and outputs the quotient of the operation result from
s2
in the same data type as that of
s1
.
[Structured ladder/FBD]
[ST]
g_dint3:= (g_dint1) / (g_dint2);
6
OPERATOR
and
d
and
DIV, /
s2
s1
6.1 Arithmetic Operations
6.1.4 Division
6-9
MOD
6.1.5
Modulus operation
MOD
Basic
High
performance
Universal
L CPU
MOD
indicates any of the following
Structured ladder/FBD
ST
operator.
MOD
d:=s1 MOD s2;
Not supported
Input argument,
s1:
s2:
Output argument,
d:
Input
:ANY_INT
Output
:ANY_INT
Function
Operation processing
For details of the operation processing, refer to Section 5.3.5.
Operation Error
An operation error occurs in the following case.
• The value to be input to
s2
is 0. (Division by 0)
(Error code: 4100)
Program Example
The program which performs division ( s1 ÷ s2 ) on double word (signed) type data input to
s2
, and outputs the remainder of the operation result from
and
s2
.
[ST]
g_dint3:= (g_dint1) MOD (g_dint2);
6-10
6.1 Arithmetic Operations
6.1.5 Modulus operation
d
s1
and
in the same data type as that of
s1
**
6.1.6
Exponentiation
**
Basic
High
performance
Universal
L CPU
**
indicates any of the following
Structured ladder/FBD
operator.
ST
**
d:=s1 ** s2;
Not supported
Input argument,
Output argument,
s1:
Input
:ANY_REAL
s2:
Input
:ANY_NUM
d:
Output
:ANY_REAL
Function
Operation processing
6
For details of the operation processing, refer to Section 5.3.6.
OPERATOR
Operation Error
These operator consist of the following common instructions.
s1
is single-precision real number,
s2
is word (signed): LOG, FLT
When
s1
is single-precision real number,
s2
is double word (signed): LOG, DFLT
When
s1
is single-precision real number,
s2
is single-precision real number: LOG
When
s1
is single-precision real number,
s2
is double-precision real number: LOGD, DFLTD
When
s1
is double-precision real number,
s2
is word (signed): LOGD
When
s1
is double-precision real number,
s2
is double word (signed): LOGD, FLTD
When
s1
is double-precision real number,
s2
is single-precision real number: LOGD, DFLTD
When
s1
is double-precision real number,
s2
is double-precision real number: LOGD
**
When
For details of an error which occurs when the operation is executed, refer to MELSEC-Q/L
Structured Programming Manual (Common Instructions).
6.1 Arithmetic Operations
6.1.6 Exponentiation
6-11
**
Program Example
The program which performs exponentiation and outputs the operation result from
same data type as that of
s1
and
s2
.
[ST]
g_real2:= (g_real1) ** ( g_int1);
6-12
6.1 Arithmetic Operations
6.1.6 Exponentiation
d
in the
AND, &, OR, XOR, NOT
6.2 Logical Operations
6.2.1
Boolean AND, boolean OR, boolean exclusive OR, and
boolean NOT
AND, &, OR, XOR, NOT
Basic
High
performance
Universal
L CPU
AND
$
OR
XOR
NOT
indicates any of the following
Structured ladder/FBD
operators.
ST
AND
AND
OR
s1
d
Not supported
XOR
s2
s28
indicates any of the following
Structured ladder/FBD
operators.
ST
AND
&
6
OR
d:=s1 AND s2
Not supported
s28,d);
XOR
s1 to s28:
Input
(s1 only for NOT)
Output argument,
d:
Output
:ANY_BIT
:ANY_BIT
AND, &, OR, XOR,
NOT
Input argument,
OPERATOR
NOT
Function
Operation processing
For details of the operation processing, refer to Section 5.4.1.
Operation Error
No operation error occurs in the execution of the AND, &, OR, XOR, and NOT operations.
6.2 Logical Operations
6.2.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
6-13
AND, &, OR, XOR, NOT
Program Example
(1) The program which performs Boolean AND on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
d
in the same data type as
.
[Structured ladder/FBD]
[ST]
g_word3 :=(g_word1) AND (g_word2);
or
g_word3 :=(g_word1) & (g_word2);
(2) The program which performs Boolean OR on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
d
in the same data type as
.
[Structured ladder/FBD]
[ST]
g_word3 :=(g_word1) OR (g_word2);
(3) The program which performs Boolean XOR on bit, word (unsigned)/16-bit string type data
input to
that of
s1
s1
to
to
s28
s28
bit by bit, and outputs the operation result from
.
[Structured ladder/FBD]
[ST]
g_word3 :=(g_word1) XOR (g_word2);
6-14
6.2 Logical Operations
6.2.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
d
in the same data type as
AND, &, OR, XOR, NOT
(4) The program which performs Boolean NOT on bit, word (unsigned)/16-bit string type data
input to
of
s1
s1
bit by bit, and outputs the operation result from
d
in the same data type as that
.
[Structured ladder/FBD]
[ST]
g_word2 :=NOT (g_word1);
AND, &, OR, XOR,
NOT
OPERATOR
6
6.2 Logical Operations
6.2.1 Boolean AND, boolean OR, boolean exclusive OR, and boolean NOT
6-15
GT, GE, EQ, LE, LT, NE, >, >=, =, <=, <, <>
6.3 Comparison Operations
6.3.1
Comparison
GT, GE, EQ, LE, LT, NE,
>, >=, =, <=, <, <>
Basic
GT
GE
EQ
LE
LT
NE
High
performance
Universal
L CPU
>
>=
=
<=
<
<>
indicates any of the following
Structured ladder/FBD
operators.
ST
GT
GT
GE
s1
d
Not supported
EQ
s2
LE
s28
LT
NE
indicates any of the following
Structured ladder/FBD
operators.
ST
>
>=
d:=s1 > s2
Not supported
s28;
=
<=
<
<>
Input argument,
s1 to s28(_IN):
Input
:ANY_SIMPLE
(s1 and s2 only for NE and <>)
Output argument,
d:
Output (TRUE: True value, FALSE: False value)
:Bit
Function
Operation processing
For details of the operation processing, refer to Section 5.6.1.
Operation Error
No operation error occurs in the execution of the GT, GE, EQ, LE, LT, NE, >, >=, =, <=, < and <>
operations.
6-16
6.3 Comparison Operations
6.3.1 Comparison
GT, GE, EQ, LE, LT, NE, >, >=, =, <=, <, <>
Program Example
The program which performs comparison operation between the values input to
outputs the operation result from
d
s1
and
s2
, and
.
[Structured ladder/FBD]
[ST]
g_bool1:= (g_int1) > (g_int2);
GT, GE, EQ, LE, LT,
NE, >, >=, =, <=, <, <>
OPERATOR
6
6.3 Comparison Operations
6.3.1 Comparison
6-17
MEMO
6-18
INDEX
OPERATOR
APPLICATION
FUNCTIONS
HOW TO READ
FUNCTIONS
CONFIGURATION
OF FUNCTIONS
FUNCTION TABLES
I
INDEX
OVERVIEW
1
2
3
4
5
6
I
Index-1
[Symbols]
- ............................................................................... 6-6
&............................................................................ 6-13
*............................................................................... 6-4
** ........................................................................... 6-11
+ .............................................................................. 6-2
/ ............................................................................... 6-8
< ............................................................................ 6-16
<= .......................................................................... 6-16
<> .......................................................................... 6-16
= ............................................................................ 6-16
> ............................................................................ 6-16
>= .......................................................................... 6-16
[A]
ABS(_E) .............................................................. 5-131
ADD......................................................................... 6-2
ADD(_E).............................................................. 5-135
ADD_TIME(_E) ................................................... 5-193
AND....................................................................... 6-13
AND(_E).............................................................. 5-157
Arithmetic Operations.............................................. 6-2
Arithmetic operations table...................................... 2-8
[B]
BCD_TO_DINT(_E) ............................................ 5-100
BCD_TO_INT(_E) ............................................... 5-100
BCD_TO_STR(_E).............................................. 5-104
BITARR_TO_DINT(_E)....................................... 5-117
BITARR_TO_INT(_E) ......................................... 5-117
BOOL_TO_DINT(_E) .............................................. 5-2
BOOL_TO_DWORD(_E) ........................................ 5-7
BOOL_TO_INT(_E)................................................. 5-2
BOOL_TO_STR(_E) ............................................... 5-5
BOOL_TO_TIME(_E)............................................ 5-10
BOOL_TO_WORD(_E) ........................................... 5-7
[C]
Comparison operations table .................................. 2-8
CONCAT(_E) ...................................................... 5-181
Configuration of Functions ...................................... 3-2
COUNTER_FB_M............................................... 5-225
CPY_BITARR(_E)............................................... 5-121
CPY_BIT_OF_INT(_E)........................................ 5-127
CTD(_E) .............................................................. 5-218
CTU(_E) .............................................................. 5-215
CTUD(_E) ........................................................... 5-221
[D]
DELETE(_E) ....................................................... 5-187
DINT_TO_BCD(_E) .............................................. 5-35
DINT_TO_BITARR(_E)....................................... 5-119
DINT_TO_BOOL(_E) ............................................ 5-16
Index - 2
DINT_TO_DWORD(_E) ........................................ 5-32
DINT_TO_INT(_E) ................................................ 5-14
DINT_TO_LREAL(_E)........................................... 5-22
DINT_TO_REAL(_E)............................................. 5-19
DINT_TO_STR(_E) ............................................... 5-25
DINT_TO_TIME(_E).............................................. 5-38
DINT_TO_WORD(_E)........................................... 5-29
DIV .......................................................................... 6-8
DIV(_E)................................................................ 5-144
DIV_TIME(_E) ..................................................... 5-202
DWORD_TO_BOOL(_E)....................................... 5-57
DWORD_TO_DINT(_E) ........................................ 5-63
DWORD_TO_INT(_E)........................................... 5-63
DWORD_TO_STR(_E) ......................................... 5-72
DWORD_TO_TIME(_E) ........................................ 5-75
DWORD_TO_WORD(_E) ..................................... 5-69
[E]
EQ ......................................................................... 6-16
EQ(_E) ................................................................ 5-174
EXPT(_E) ............................................................ 5-150
[F]
F_TRIG(_E)......................................................... 5-213
FUNCTION TABLES ............................................... 2-1
Functions of time data types table........................... 2-6
[G]
GE ......................................................................... 6-16
GE(_E) ................................................................ 5-174
GET_BIT_OF_INT(_E)........................................ 5-123
GET_BOOL_ADDR............................................. 5-129
GET_INT_ADDR ................................................. 5-129
GET_WORD_ADDR ........................................... 5-129
GT ......................................................................... 6-16
GT(_E)................................................................. 5-174
[H]
How to Read Function Tables ................................. 2-2
HOW TO READ FUNCTIONS................................. 4-1
[I]
Input Pins Variable Function ................................... 3-3
INSERT(_E) ........................................................ 5-184
INT_TO_BCD(_E) ................................................. 5-35
INT_TO_BITARR(_E).......................................... 5-119
INT_TO_BOOL(_E)............................................... 5-16
INT_TO_DINT(_E) ................................................ 5-12
INT_TO_DWORD(_E)........................................... 5-32
INT_TO_LREAL(_E) ............................................. 5-22
INT_TO_REAL(_E) ............................................... 5-19
INT_TO_STR(_E).................................................. 5-25
INT_TO_TIME(_E) ................................................ 5-38
INT_TO_WORD(_E) ............................................. 5-29
[L]
LE.......................................................................... 6-16
LE(_E) ................................................................. 5-174
LIMITATION(_E) ................................................. 5-168
Logical operations table .......................................... 2-8
LREAL_TO_DINT(_E)........................................... 5-44
LREAL_TO_INT(_E) ............................................. 5-44
LREAL_TO_REAL(_E).......................................... 5-50
LT .......................................................................... 6-16
LT(_E) ................................................................. 5-174
[M]
MAXIMUM(_E) .................................................... 5-165
MID(_E)............................................................... 5-178
MINIMUM(_E) ..................................................... 5-165
MOD...................................................................... 6-10
MOD(_E) ............................................................. 5-147
MOVE(_E)........................................................... 5-153
MUL......................................................................... 6-4
MUL(_E).............................................................. 5-138
MUL_TIME(_E) ................................................... 5-199
MUX(_E) ............................................................. 5-171
[N]
NE ......................................................................... 6-16
NE(_E) ................................................................ 5-174
NOT....................................................................... 6-13
NOT(_E).............................................................. 5-157
[O]
OR......................................................................... 6-13
OR(_E) ................................................................ 5-157
[R]
REAL_TO_DINT(_E)............................................. 5-41
REAL_TO_INT(_E) ............................................... 5-41
REAL_TO_LREAL(_E).......................................... 5-47
REAL_TO_STR(_E).............................................. 5-53
REPLACE(_E)..................................................... 5-190
RS(_E) ................................................................ 5-207
R_TRIG(_E) ........................................................ 5-210
Standard edge detection function blocks table ....... 2-7
Standard functions of one numeric variable table ... 2-5
Standard selection functions table .......................... 2-5
Standard timer function blocks table ....................... 2-7
STR_TO_BCD(_E)................................................ 5-95
STR_TO_BOOL(_E) ............................................. 5-78
STR_TO_DINT(_E) ............................................... 5-81
STR_TO_DWORD(_E) ......................................... 5-88
STR_TO_INT(_E) ................................................. 5-81
STR_TO_REAL(_E) .............................................. 5-84
STR_TO_TIME(_E)............................................... 5-92
STR_TO_WORD(_E) ............................................ 5-88
SUB ......................................................................... 6-6
SUB(_E) .............................................................. 5-141
SUB_TIME(_E) ................................................... 5-196
[T]
TIME_TO_BOOL(_E) .......................................... 5-107
TIME_TO_DINT(_E) ........................................... 5-109
TIME_TO_DWORD(_E) ...................................... 5-114
TIME_TO_INT(_E) .............................................. 5-109
TIME_TO_STR(_E)............................................. 5-112
TIME_TO_WORD(_E)......................................... 5-114
TOF(_E) .............................................................. 5-233
TOF_HIGH(_E) ................................................... 5-233
TON(_E) .............................................................. 5-230
TON_HIGH(_E) ................................................... 5-230
TP(_E) ................................................................. 5-227
TP_HIGH(_E) ...................................................... 5-227
Type conversion functions table.............................. 2-3
[W]
WORD_TO_BOOL(_E) ......................................... 5-57
WORD_TO_DINT(_E)........................................... 5-60
WORD_TO_DWORD(_E) ..................................... 5-66
WORD_TO_INT(_E) ............................................. 5-60
WORD_TO_STR(_E) ............................................ 5-72
WORD_TO_TIME(_E)........................................... 5-75
I
[X]
XOR ...................................................................... 6-13
XOR(_E).............................................................. 5-157
INDEX
[S]
SEL(_E)............................................................... 5-162
SET_BIT_OF_INT(_E) ........................................ 5-125
SR(_E) ................................................................ 5-204
Standard arithmetic functions table......................... 2-5
Standard bistable function blocks table................... 2-6
Standard bitwise Boolean functions table ............... 2-5
Standard character string functions table................ 2-6
Standard comparison functions table...................... 2-6
Standard counter function blocks table ................... 2-7
Index-3
MEMO
Index-4
WARRANTY
Please confirm the following product warranty details before using this product.
1. Gratis Warranty Term and Gratis Warranty Range
If any faults or defects (hereinafter "Failure") found to be the responsibility of Mitsubishi occurs during use of the product within the
gratis warranty term, the product shall be repaired at no cost via the sales representative or Mitsubishi Service Company.
However, if repairs are required onsite at domestic or overseas location, expenses to send an engineer will be solely at the
customer's discretion. Mitsubishi shall not be held responsible for any re-commissioning, maintenance, or testing onsite that
involves replacement of the failed module.
[Gratis Warranty Term]
The gratis warranty term of the product shall be for one year after the date of purchase or delivery to a designated place.
Note that after manufacture and shipment from Mitsubishi, the maximum distribution period shall be six (6) months, and the
longest gratis warranty term after manufacturing shall be eighteen (18) months. The gratis warranty term of repair parts shall not
exceed the gratis warranty term before repairs.
[Gratis Warranty Range]
(1) The range shall be limited to normal use within the usage state, usage methods and usage environment, etc., which follow
the conditions and precautions, etc., given in the instruction manual, user's manual and caution labels on the product.
(2) Even within the gratis warranty term, repairs shall be charged for in the following cases.
1. Failure occurring from inappropriate storage or handling, carelessness or negligence by the user. Failure caused by the
user's hardware or software design.
2. Failure caused by unapproved modifications, etc., to the product by the user.
3. When the Mitsubishi product is assembled into a user's device, Failure that could have been avoided if functions or
structures, judged as necessary in the legal safety measures the user's device is subject to or as necessary by industry
standards, had been provided.
4. Failure that could have been avoided if consumable parts (battery, backlight, fuse, etc.) designated in the instruction
manual had been correctly serviced or replaced.
5. Failure caused by external irresistible forces such as fires or abnormal voltages, and Failure caused by force majeure
such as earthquakes, lightning, wind and water damage.
6. Failure caused by reasons unpredictable by scientific technology standards at time of shipment from Mitsubishi.
7. Any other failure found not to be the responsibility of Mitsubishi or that admitted not to be so by the user.
2. Onerous repair term after discontinuation of production
(1) Mitsubishi shall accept onerous product repairs for seven (7) years after production of the product is discontinued.
Discontinuation of production shall be notified with Mitsubishi Technical Bulletins, etc.
(2) Product supply (including repair parts) is not available after production is discontinued.
3. Overseas service
Overseas, repairs shall be accepted by Mitsubishi's local overseas FA Center. Note that the repair conditions at each FA Center
may differ.
4. Exclusion of loss in opportunity and secondary loss from warranty liability
Regardless of the gratis warranty term, Mitsubishi shall not be liable for compensation to damages caused by any cause found not
to be the responsibility of Mitsubishi, loss in opportunity, lost profits incurred to the user by Failures of Mitsubishi products, special
damages and secondary damages whether foreseeable or not, compensation for accidents, and compensation for damages to
products other than Mitsubishi products, replacement by the user, maintenance of on-site equipment, start-up test run and other
tasks.
5. Changes in product specifications
The specifications given in the catalogs, manuals or technical documents are subject to change without prior notice.
Microsoft, Windows are registered trademarks of Microsoft Corporation in the United States and other countries.
All other company names and product names used in this manual are trademarks or registered trademarks of their
respective companies.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement