FXCPU Structured Programming Manual [Application Functions]

FXCPU Structured Programming Manual [Application Functions]
MITSUBISHI ELECTRIC
Programmable Controllers
Structured Programming Manual
[Application Functions]
FXCPU
01 07 2009
JY997D34801
Version B
MITSUBISHI ELECTRIC
INDUSTRIAL AUTOMATION
FXCPU Structured Programming Manual
(Application Functions)
FXCPU Structured Programming Manual
(Application Functions)
Manual number
JY997D34801
Manual revision
B
Date
7/2009
Foreword
This manual contains text, diagrams and explanations which will guide the reader through the safe and
correct installation, use, and operation of the FX Series function for structured programs. It should be read
and understood before attempting to install or use the unit.
Store this manual in a safe place so that you can take it out and read it whenever necessary. Always forward
it to the end user.
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.
© 2009 MITSUBISHI ELECTRIC CORPORATION
1
FXCPU Structured Programming Manual
(Application Functions)
Outline Precautions
• This manual provides information for the use of the FX Series Programmable Controllers. The manual has
been written to be used by trained and competent personnel. The definition of such a person or persons is
as follows;
a) Any engineer who is responsible for the planning, design and construction of automatic equipment
using the product associated with this manual should be of a competent nature, trained and qualified
to the local and national standards required to fulfill that role. These engineers should be fully aware of
all aspects of safety with regards to automated equipment.
b) Any commissioning or service engineer must be of a competent nature, trained and qualified to the
local and national standards required to fulfill that job. These engineers should also be trained in the
use and maintenance of the completed product. This includes being completely familiar with all
associated documentation for the said product. All maintenance should be carried out in accordance
with established safety practices.
c) All operators of the completed equipment should be trained to use that product in a safe and
coordinated manner in compliance to established safety practices. The operators should also be
familiar with documentation which is connected with the actual operation of the completed equipment.
Note: the term 'completed equipment' refers to a third party constructed device which contains or uses
the product associated with this manual
• This product has been manufactured as a general-purpose part for general industries, and has not been
designed or manufactured to be incorporated in a device or system used in purposes related to human life.
• Before using the product for special purposes such as nuclear power, electric power, aerospace, medicine
or passenger movement vehicles, consult with Mitsubishi Electric.
• This product has been manufactured under strict quality control. However when installing the product
where major accidents or losses could occur if the product fails, install appropriate backup or failsafe
functions in the system.
• When combining this product with other products, please confirm the standard and the code, or regulations
with which the user should follow. Moreover, please confirm the compatibility of this product to the system,
machine, and apparatus with which a user is using.
• If in doubt at any stage during the installation of the product, always consult a professional electrical
engineer who is qualified and trained to the local and national standards. If in doubt about the operation or
use, please consult the nearest Mitsubishi Electric distributor.
• Since the examples indicated by this manual, technical bulletin, catalog, etc. are used as a reference,
please use it after confirming the function and safety of the equipment and system. Mitsubishi Electric will
accept no responsibility for actual use of the product based on these illustrative examples.
• This manual content, specification etc. may be changed without a notice for improvement.
• The information in this manual has been carefully checked and is believed to be accurate; however, you
have noticed a doubtful point, a doubtful error, etc., please contact the nearest Mitsubishi Electric
distributor.
Registration
• Microsoft® and Windows® are either registered trademarks or trademarks of Microsoft Corporation in the
United States and/or other countries.
• CompactFlash is a trademark of SanDisk Corporation in the United States and other countries.
• The company name and the product name to be described in this manual are the registered trademarks or
trademarks of each company.
2
FXCPU Structured Programming Manual
(Application Functions)
Table of Contents
Table of Contents
Positioning of This Manual....................................................................................................... 7
Related Manuals ...................................................................................................................... 10
Generic Names and Abbreviations Used in Manuals .......................................................... 13
1. Outline
14
1.1 Outline of Structured Programs and Programming Languages .................................................... 14
1.1.1 Outline of structured programs ...................................................................................................... 14
1.1.2 Programming languages ............................................................................................................... 15
1.2 PLC Series and Programming Software Version .......................................................................... 15
1.3 Cautions on Creation of Fundamental Programs.......................................................................... 16
1.3.1
1.3.2
1.3.3
1.3.4
1.3.5
I/O processing and response delay ............................................................................................... 16
Double output (double coil) operation and countermeasures........................................................ 17
Circuits not available in structured ladder programs and countermeasures.................................. 18
Handling of general flags............................................................................................................... 18
Handling of operation error flag ..................................................................................................... 21
2. Function List
22
2.1 Type Conversion Functions .......................................................................................................... 22
2.2 Standard Functions Of One Numeric Variable.............................................................................. 24
2.3 Standard Arithmetic Functions ...................................................................................................... 24
2.4 Standard Bit Shift Functions.......................................................................................................... 25
2.5 Standard Bitwise Boolean Functions ............................................................................................ 25
2.6 Standard Selection Functions ....................................................................................................... 25
2.7 Standard Comparison Functions................................................................................................... 26
2.8 Standard Character String Functions............................................................................................ 26
2.9 Functions Of Time Data Types ..................................................................................................... 26
2.10 Standard Function Blocks ........................................................................................................... 27
3. Function Construction
3.1
3.2
3.3
3.4
28
Applied Function Expression and Execution Type........................................................................ 28
Labels............................................................................................................................................ 29
Device and Address ...................................................................................................................... 32
EN and ENO ................................................................................................................................. 33
4. How to Read Explanation of Functions
34
3
FXCPU Structured Programming Manual
(Application Functions)
5. Applied Functions
Table of Contents
36
5.1 Type Conversion Functions .......................................................................................................... 36
5.1.1 BOOL_TO_INT(_E) ....................................................................................................................... 36
5.1.2 BOOL_TO_DINT(_E) .................................................................................................................... 38
5.1.3 BOOL_TO_STR(_E)...................................................................................................................... 40
5.1.4 BOOL_TO_WORD(_E) ................................................................................................................. 42
5.1.5 BOOL_TO_DWORD(_E)............................................................................................................... 44
5.1.6 BOOL_TO_TIME(_E) .................................................................................................................... 46
5.1.7 INT_TO_DINT(_E)......................................................................................................................... 48
5.1.8 DINT_TO_INT(_E)......................................................................................................................... 50
5.1.9 INT_TO_BOOL(_E) ....................................................................................................................... 52
5.1.10 DINT_TO_BOOL(_E) .................................................................................................................. 54
5.1.11 INT_TO_REAL(_E)...................................................................................................................... 56
5.1.12 DINT_TO_REAL(_E) ................................................................................................................... 58
5.1.13 INT_TO_STR(_E)........................................................................................................................ 60
5.1.14 DINT_TO_STR(_E) ..................................................................................................................... 62
5.1.15 INT_TO_WORD(_E).................................................................................................................... 64
5.1.16 DINT_TO_WORD(_E) ................................................................................................................. 66
5.1.17 INT_TO_DWORD(_E) ................................................................................................................. 68
5.1.18 DINT_TO_DWORD(_E) .............................................................................................................. 70
5.1.19 INT_TO_BCD(_E) ....................................................................................................................... 72
5.1.20 DINT_TO_BCD(_E)..................................................................................................................... 74
5.1.21 INT_TO_TIME(_E) ...................................................................................................................... 76
5.1.22 DINT_TO_TIME(_E).................................................................................................................... 78
5.1.23 REAL_TO_INT(_E)...................................................................................................................... 80
5.1.24 REAL_TO_DINT(_E) ................................................................................................................... 82
5.1.25 REAL_TO_STR(_E) .................................................................................................................... 84
5.1.26 WORD_TO_BOOL(_E) ............................................................................................................... 87
5.1.27 DWORD_TO_BOOL(_E)............................................................................................................. 89
5.1.28 WORD_TO_INT(_E).................................................................................................................... 91
5.1.29 WORD_TO_DINT(_E) ................................................................................................................. 93
5.1.30 DWORD_TO_INT(_E) ................................................................................................................. 95
5.1.31 DWORD_TO_DINT(_E) .............................................................................................................. 97
5.1.32 WORD_TO_DWORD(_E) ........................................................................................................... 99
5.1.33 DWORD_TO_WORD(_E) ......................................................................................................... 101
5.1.34 WORD_TO_TIME(_E)............................................................................................................... 103
5.1.35 DWORD_TO_TIME(_E) ............................................................................................................ 105
5.1.36 STR_TO_BOOL(_E).................................................................................................................. 107
5.1.37 STR_TO_INT(_E)...................................................................................................................... 109
5.1.38 STR_TO_DINT(_E) ................................................................................................................... 111
5.1.39 STR_TO_REAL(_E) .................................................................................................................. 113
5.1.40 STR_TO_TIME(_E) ................................................................................................................... 116
5.1.41 BCD_TO_INT(_E) ..................................................................................................................... 118
5.1.42 BCD_TO_DINT(_E)................................................................................................................... 120
5.1.43 TIME_TO_BOOL(_E) ................................................................................................................ 122
5.1.44 TIME_TO_INT(_E) .................................................................................................................... 124
5.1.45 TIME_TO_DINT(_E).................................................................................................................. 126
5.1.46 TIME_TO_STR(_E) ................................................................................................................... 128
5.1.47 TIME_TO_WORD(_E)............................................................................................................... 130
5.1.48 TIME_TO_DWORD(_E) ............................................................................................................ 132
4
FXCPU Structured Programming Manual
(Application Functions)
Table of Contents
5.2 Standard Functions Of One Numeric Variable............................................................................ 134
5.2.1 ABS(_E)....................................................................................................................................... 134
5.3 Standard Arithmetic Functions .................................................................................................... 136
5.3.1
5.3.2
5.3.3
5.3.4
5.3.5
5.3.6
5.3.7
ADD_E......................................................................................................................................... 136
SUB_E......................................................................................................................................... 138
MUL_E......................................................................................................................................... 140
DIV_E .......................................................................................................................................... 142
MOD(_E) ..................................................................................................................................... 144
EXPT(_E) .................................................................................................................................... 146
MOVE(_E) ................................................................................................................................... 148
5.4 Standard Bit Shift Functions........................................................................................................ 150
5.4.1 SHL(_E)....................................................................................................................................... 150
5.4.2 SHR(_E) ...................................................................................................................................... 152
5.5 Standard Bitwise Boolean Functions .......................................................................................... 154
5.5.1
5.5.2
5.5.3
5.5.4
AND_E......................................................................................................................................... 154
OR_E........................................................................................................................................... 156
XOR_E ........................................................................................................................................ 158
NOT(_E) ...................................................................................................................................... 160
5.6 Standard Selection Functions ..................................................................................................... 162
5.6.1
5.6.2
5.6.3
5.6.4
5.6.5
SEL(_E) ....................................................................................................................................... 162
MAXIMUM(_E) ............................................................................................................................ 164
MINIMUM(_E).............................................................................................................................. 166
LIMITATION(_E).......................................................................................................................... 168
MUX(_E)...................................................................................................................................... 170
5.7 Standard Comparison Functions................................................................................................. 172
5.7.1
5.7.2
5.7.3
5.7.4
5.7.5
5.7.6
GT_E ........................................................................................................................................... 172
GE_E ........................................................................................................................................... 174
EQ_E ........................................................................................................................................... 175
LE_E............................................................................................................................................ 176
LT_E ............................................................................................................................................ 178
NE_E ........................................................................................................................................... 179
5.8 Standard Character String Functions.......................................................................................... 181
5.8.1
5.8.2
5.8.3
5.8.4
5.8.5
5.8.6
MID(_E) ....................................................................................................................................... 181
CONCAT(_E)............................................................................................................................... 184
INSERT(_E)................................................................................................................................. 187
DELETE(_E)................................................................................................................................ 190
REPLACE(_E) ............................................................................................................................. 192
FIND(_E) ..................................................................................................................................... 195
5.9 Functions Of Time Data Types ................................................................................................... 198
5.9.1
5.9.2
5.9.3
5.9.4
ADD_TIME(_E)............................................................................................................................ 198
SUB_TIME(_E)............................................................................................................................ 200
MUL_TIME(_E)............................................................................................................................ 202
DIV_TIME(_E) ............................................................................................................................. 204
5
FXCPU Structured Programming Manual
(Application Functions)
Table of Contents
6. Standard Function Blocks
206
6.1 R_TRIG(_E) ................................................................................................................................ 206
6.2 F_TRIG(_E)................................................................................................................................. 208
6.3 CTU(_E) ...................................................................................................................................... 210
6.4 CTD(_E) ...................................................................................................................................... 212
6.5 CTUD(_E) ................................................................................................................................... 214
6.6 TP(_E)......................................................................................................................................... 217
6.7 TON(_E)...................................................................................................................................... 219
6.8 TOF(_E) ...................................................................................................................................... 221
6.9 COUNTER_FB_M....................................................................................................................... 223
6.10 TIMER_10_FB_M ..................................................................................................................... 225
6.11 TIMER_CONT_FB_M ............................................................................................................... 226
6.12 TIMER_100_FB_M ................................................................................................................... 228
Appendix A: Correspondence between Devices and Addresses
229
Warranty................................................................................................................................. 230
Revision History .................................................................................................................... 231
6
FXCPU Structured Programming Manual
(Application Functions)
Positioning of This Manual
This manual explains application functions for structured programs provided by GX Works2. Refer to other
manuals for devices, parameters and sequence instructions.
Refer to each corresponding manual for analog, communication, positioning control and special units and
blocks.
1. When using FX3U/FX3UC/FX3G PLCs
QCPU/FXCPU Structured Programming Manual (Fundamentals) (Additional Manual)
Q/FX
This manual explains programming methods, specifications, functions, etc. required to create
structured programs.
Structured
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
FX
This manual explains devices and parameters for structured programs provided
by GX Works2.
Structured
FXCPU Structured Programming Manual (Basic & Applied Instruction)
FX
Structured
(Additional Manual)
This manual explains sequence instructions for structured programs provided
by GX Works2.
(This manual)
FX
FXCPU Structured Programming Manual (Application Functions)
(Additional Manual)
This manual explains application functions for structured programs provided
by GX Works2.
Structured
FX3G/FX3U/FX3UC User's Manual- Analog Control Edition (Additional Manual)
FX3U
FX3UC
FX3G
This manual explains details of analog special function blocks and analog special
adapters for FX3U/FX3UC/FX3G PLCs and PID instruction.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer.
FX Series User's Manual -Data Communication Edition (Additional Manual)
FX
This manual explains details of simple N:N link, parallel link, computer link, no-protocol
communication (RS and RS2 instructions), programming communication and inverter
communication for FX PLCs.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer.
FX3G/FX3U/FX3UC Series User's Manual -Positioning Edition (Additional Manual)
FX3U
FX3UC
FX3G
This manual explains details of wiring, instructions and operations of the positioning
function built in FX3U/FX3UC/FX3G PLC main units.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer.
Individual manuals (Manual supplied with product or additional Manual *1)
Special
unit/block
This manual explains details of each special unit/block.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer.
*1. Detailed explanation may be provided by a separate manual in some products.
7
FXCPU Structured Programming Manual
(Application Functions)
2. When using FX1S/FX1N/FXU/FX1NC/FX2NC PLCs
QCPU/FXCPU Structured Programming Manual (Fundamentals) (Additional Manual)
Q/FX
This manual explains programming methods, specifications, functions, etc. required to create
structured programs.
Structured
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
FX
This manual explains devices and parameters for structured programs provided
by GX Works2.
Structured
FX
FXCPU Structured Programming Manual (Basic & Applied Instruction)
(Additional Manual)
This manual explains sequence instructions for structured programs provided
by GX Works2.
Structured
(This manual)
FX
FXCPU Structured Programming Manual (Application Functions)
(Additional Manual)
This manual explains application functions for structured programs provided
by GX Works2.
Structured
FX Series User's Manual -Data Communication Edition (Additional Manual)
FX
This manual explains details of simple N:N link, parallel link, computer link, no-protocol
communication (RS instruction), programming communication and inverter communication
for FX PLCs.
Explanation of instructions and instructions used in program examples are expressed for
GX Developer and FX-PCS/WIN.
Individual manuals (Manual supplied with product or additional Manual *1 )
Special
unit/block
This manual explains details of each special unit/block.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer and FX-PCS/WIN.
*1. Detailed explanation may be provided by a separate manual in some products.
8
FXCPU Structured Programming Manual
(Application Functions)
3. When using FX0/FX0S/FX0N/FXU/FX2C PLCs
QCPU/FXCPU Structured Programming Manual (Fundamentals) (Additional Manual)
Q/FX
This manual explains programming methods, specifications, functions, etc. required to create
structured programs.
Structured
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
FX
This manual explains devices and parameters for structured programs provided
by GX Works2.
Structured
FX
FXCPU Structured Programming Manual (Basic & Applied Instruction)
(Additional Manual)
This manual explains sequence instructions for structured programs provided
by GX Works2.
Structured
(This manual)
FX
Structured
FXCPU Structured Programming Manual (Application Functions)
(Additional Manual)
This manual explains application functions for structured programs provided
by GX Works2.
FX Series User's Manual -Data Communication Edition (Additional Manual)
FX
This manual explains details of parallel link, computer link, no-protocol communication
(RS instruction) and programming communication for FX PLCs.
Explanation of instructions and instructions used in program examples are expressed for
GX Developer and FX-PCS/WIN.
Individual manuals (Manual supplied with product or additional Manual *1)
Special
unit/block
This manual explains details of each special unit/block.
Explanation of instructions and instructions used in program examples are expressed
for GX Developer and FX-PCS/WIN.
*1. Detailed explanation may be provided by a separate manual in some products.
9
FXCPU Structured Programming Manual
(Application Functions)
Related Manuals
This manual explains devices and parameters for structured programs provided by GX Works2.
Refer to other manuals for sequence instructions and applied functions.
This chapter introduces only reference manuals for this manual and manuals which describe the hardware
information of PLC main units.
Manuals not introduced here may be required in some applications.
Refer to the manual of the used PLC main unit and manuals supplied together with used products.
Contact the distributor for acquiring required manuals.
Common among FX PLCs [structured]
Manual name
Manual number
Supplied with product
or Additional Manual
Contents
Model
name code
QCPU/FXCPU Structured
Programming Manual (Fundamentals)
SH-080782
Additional Manual
Programming methods, specifications, functions,
etc. required to create structured programs
13JW06
FXCPU Structured Programming
Manual (Device & Common)
JY997D26001
Additional Manual
Devices, parameters, etc. provided in structured
projects of GX Works2
09R920
FXCPU Structured Programming
Manual (Basic & Applied Instruction)
JY997D34701
Additional Manual
Sequence instructions provided in structured
projects of GX Works2
09R921
FXCPU Structured Programming
Manual (Application Functions)
JY997D34801
Additional Manual
Application functions provided in structured
projects of GX Works2
09R922
Manual number
Supplied with product
or Additional Manual
FX3U/FX3UC/FX3G PLCs
Manual name
Contents
Model
name code
PLC main unit
FX3U Series Hardware Manual
JY997D18801
Supplied with product
FX3U Series User's Manual- Hardware
Edition
JY997D16501
Additional Manual
FX3UC (D, DSS) Series Hardware
Manual
JY997D28601
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX3U PLC main unit.
-
09R516
Supplied with product
I/O specifications, wiring and installation of the
PLC main unit FX3UC (D, DSS) extracted from the
FX3UC Series User’s Manual - Hardware Edition.
For detailed explanation, refer to the FX3UC
Series User’s Manual - Hardware Edition.
-
I/O specifications, wiring and installation of the
PLC main unit FX3UC-32MT-LT-2 extracted from
the FX3UC Series User’s Manual - Hardware
Edition. For detailed explanation, refer to the
FX3UC Series User’s Manual - Hardware Edition.
-
FX3UC-32MT-LT-2 Hardware Manual
JY997D31601
Supplied with product
FX3UC Series User's Manual Hardware Edition
JY997D28701
Additional Manual
FX3G Series Hardware Manual
JY997D33401
Supplied with product
FX3G Series User's Manual- Hardware
Edition
JY997D31301
Additional Manual
10
I/O specifications, wiring and installation of the
PLC main unit FX3U extracted from the FX3U
Series User’s Manual - Hardware Edition. For
detailed explanation, refer to the FX3U Series
User’s Manual - Hardware Edition.
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX3UC PLC main unit.
I/O specifications, wiring and installation of the
PLC main unit FX3G extracted from the FX3G
Series User’s Manual - Hardware Edition. For
detailed explanation, refer to the FX3G Series
User’s Manual - Hardware Edition.
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX3G PLC main unit.
09R519
-
09R521
FXCPU Structured Programming Manual
(Application Functions)
Manual number
Supplied with product
or Additional Manual
Contents
Model
name code
FX3G/FX3U/FX3UC User's ManualAnalog Control Edition
JY997D16701
Additional Manual
Detaileds about the analog special function block
(FX3U-4AD, FX3U-4DA, FX3UC-4AD) and analog
special adapter
(FX3U-****-ADP).
09R619
FX Series User's Manual -Data
Communication Edition
JY997D16901
Additional Manual
Details about simple N : N link, parallel link,
computer link and no-protocol communication
(RS instruction and FX2N-232IF).
09R715
FX3G/FX3U/FX3UC Series User's
Manual -Positioning Edition
JY997D16801
Additional Manual
Details about the positioning function built in the
FX3G/FX3U/FX3UC Series.
09R620
FX3U-CF-ADP User's Manual
JY997D35401
Additional Manual
Describes details of the FX3U-CF-ADP CF card
special adapter.
09R720
Manual name
Programming
FX1S/FX1N/FX2N/FX1NC/FX2NC PLCs
Manual number
Supplied with product
or Additional Manual
FX1S HARDWARE MANUAL
JY992D83901
Additional Manual
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX1S PLC main unit.
-
FX1N HARDWARE MANUAL
JY992D89301
Additional Manual
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX1N PLC main unit.
-
FX2N HARDWARE MANUAL
JY992D66301
Additional Manual
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX2N PLC main unit.
09R508
09R505
Manual name
Contents
Model
name code
PLC main unit
FX1NC HARDWARE MANUAL
JY992D92101
Additional Manual
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX1NC PLC main unit.
(Japanese only)
FX2NC HARDWARE MANUAL
JY992D76401
Additional Manual
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX2NC PLC main unit.
09R509
JY997D16901
Additional Manual
Details about simple N : N link, parallel link,
computer link and no-protocol communication
(RS instruction and FX2N-232IF).
09R715
Programming
FX Series User's Manual -Data
Communication Edition
11
FXCPU Structured Programming Manual
(Application Functions)
FX0/FX0S/FX0N/FXU/FX2C PLCs [whose production is finished]
Manual number
Supplied with product
or Additional Manual
FX0/FX0N HARDWARE MANUAL
JY992D47501
Supplied with product
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX0/FX0N PLC main unit.
-
FX0S HARDWARE MANUAL
JY992D55301
Supplied with product
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FX0S PLC main unit.
-
FX/FX2C HARDWARE MANUAL
JY992D47401
Supplied with product
Details about the hardware including I/O
specifications, wiring, installation and
maintenance of the FXU/FX2C PLC main unit.
-
JY997D16901
Additional Manual
Details about simple N : N link, parallel link,
computer link and no-protocol communication
(RS instruction and FX2N-232IF).
09R715
Manual name
Contents
Model
name code
PLC main unit
Programming
FX Series User's Manual -Data
Communication Edition
Manuals of models whose production is finished
Production is finished for FX0/FX0S/FX0N/FXU/FX2C PLCs.
12
FXCPU Structured Programming Manual
(Application Functions)
Generic Names and Abbreviations Used in Manuals
Abbreviation/generic name
Name
PLCs
FX3U Series or FX3U PLC
Generic name of FX3U Series PLCs
FX3UC Series or FX3UC PLC
Generic name of FX3UC Series PLCs
FX3G Series or FX3G PLC
Generic name of FX3G Series PLCs
FX2N Series or FX2N PLC
Generic name of FX2N Series PLCs
FX2NC Series or FX2NC PLC
Generic name of FX2NC Series PLCs
FX1N Series or FX1N PLC
Generic name of FX1N Series PLCs
FX1NC Series or FX1NC PLC
Generic name of FX1NC Series PLCs
These products can only used in Japan.
FX1S Series or FX1S PLC
Generic name of FX1S Series PLCs
FXU Series or FXU PLC
Generic name of FXU(FX,FX2) Series PLCs
FX2C Series or FX2C PLC
Generic name of FX2C Series PLCs
FX0N Series or FX0N PLC
Generic name of FX0N Series PLCs
FX0S Series or FX0S PLC
Generic name of FX0S Series PLCs
FX0 Series or FX0 PLC
Generic name of FX0 Series PLCs
Special adapters
CF card special adapter
CF-ADP
Generic name of CF card special adapters
FX3U-CF-ADP
Programming language
ST
Abbreviation of structured text language
Structured ladder
Abbreviation of ladder diagram language
Manuals
Q/FX Structured Programming Manual
Abbreviation of QCPU/FXCPU Structured Programming Manual (Fundamentals)
(Fundamentals)
FX Structured Programming Manual
(Device & Common)
Abbreviation of FXCPU Structured Programming Manual (Device & Common)
FX Structured Programming Manual
(Basic & Applied Instruction)
Abbreviation of FXCPU Structured Programming Manual (Basic & Applied Instruction)
FX Structured Programming Manual
(Application Functions)
Abbreviation of FXCPU Structured Programming Manual (Application Functions)
COMMUNICATION CONTROL
EDITION
Abbreviation of FX Series User's Manual-DATA COMMUNICATION CONTROL EDITION
ANALOG CONTROL EDITION
Abbreviation of FX3G/FX3U/FX3UC Series User's Manual-ANALOG CONTROL EDITION
POSITIONING CONTROL EDITION
Abbreviation of FX3G/FX3U/FX3UC Series User's Manual-POSITIONING CONTROL EDITION
13
FXCPU Structured Programming Manual
(Application Functions)
1.
1 Outline
1.1 Outline of Structured Programs and Programming
Outline
This manual explains applied functions for structured programs provided by GX Works2.
Refer to a different manual for devices, parameters and sequence instructions.
Refer to the following manual for labels, data types and programming languages for structured programs:
→ Q/FX Structured Programming Manual (Fundamentals)
1.1
Outline of Structured Programs and Programming Languages
1.1.1
Outline of structured programs
You can construct two or more programs (program blocks) into one program.
Because you can divide the entire machine processing into small sub processes and create a program for
each sub process, you can efficiently create a program for a large system.
1. Structured program
Program structuring is a technique to divide the contents of control executed by the PLC CPU into
hierarchical small units (blocks) of processing, and then construct a program. By using this technique, you
can design a program while recognizing structuring of a sequence program.
Advantages of hierarchical program
• You can examine the outline of a program at first, and then design its details gradually.
• Program blocks located at the lowest level in the hierarchy are extremely simple and highly independent.
Advantages of program consisting of program blocks
• Because the processing of each block is clear, the entire program is easy to understand.
• The entire program can be divided into several blocks that are created by several people.
• The program reusability is improved, and the development efficiency is improved accordingly.
2. Improved reusability of programs
You can save program blocks in a library. Program resources in the library can be shared, and often used
again.
14
FXCPU Structured Programming Manual
(Application Functions)
1.2 PLC Series and Programming Software Version
1
Programming languages
Outline
1.1.2
1 Outline
The following programming languages can be used in each program block.
Graphic languages
2
This graphic language is created based on the relay circuit design technology.
Any circuit always starts from the bus line located on the leftmost.
The structured ladder language consists of contacts, coils, functions and function blocks. These components
are connected with vertical lines and horizontal lines.
X000
1
X001
Y000
3
Function
Construction
Output Y000
Y000
2
X001
D0
EN
s
MOV
ENO
d
4
D2
How to Read
Explanation of
Functions
When X001 is ON, the contents
of D0 are transferred to D2.
Text language
5
The ST language can describe control achieved by syntax using selective branches with conditional
statements and repetition by repetitive statements in the same way as high-level languages such as C
language.
By using the ST language, you can create simple programs easy to understand.
6
Standard
Function Blocks
Y000:=(X000 OR Y000) AND NOT X001;
IF X001 THEN
D2:=D0; (When X001 is ON, the contents of D0 are transferred to D2.)
END_IF;
IF X002 THEN
D4:=D4+1; (When X002 is ON, the contents of D4 are added by "1".)
ELSE
D6:=D6+1; (When X002 is OFF, the contents of D6 are added by "1".)
END_IF;
A
Correspondence
between Devices
and Addresses
PLC Series and Programming Software Version
PLC Series
Software package name
(model name)
GX Works2 version
FX3U•FX3UC
FX3G
FX2N•FX2NC
FX1N•FX1NC
FX1S
GX Works2
(SW1DNC-GXW2-E)
Applied
Functions
1. ST (Structured text) language
1.2
Function List
1. Structured ladder language
Ver. 1.08J or later
FXU/FX2C
FX0N
FX0•FX0S
15
FXCPU Structured Programming Manual
(Application Functions)
1.3
1 Outline
1.3 Cautions on Creation of Fundamental Programs
Cautions on Creation of Fundamental Programs
This section explains cautions on programming.
Refer to the following manual for cautions on structured programs and programming languages:
→ Q/FX Structured Programming Manual (Fundamentals)
Refer to the following programming manual for detailed operations of and cautions on devices and
parameters:
→ FX Structured Programming Manual (Device & Common)
1.3.1
I/O processing and response delay
1. Operation timing of I/O relays and
response delay
FX PLCs execute the I/O processing by
repeating the processing (1) to processing (3).
Accordingly, the control executed by PLCs
contains not only the drive time of input filters
and output devices but also the response
delay caused by the operation cycle.
Acquiring the latest I/O information
For acquiring the latest input information or
immediately outputting the operation result in
the middle of the operation cycle shown
above, the I/O refresh instruction (REF) is
available.
(1)
The ON/OFF status of input
[Input processing] terminals is received at one time.
Input image
memory is read.
Input image is read, and
Scan
time
(operation
cycle)
(2) [Program processing]
operation is executed
according to program.
Image memory of
each device is updated.
(3)
[Output processing] Output
Result is transferred to devices
Batch I/O method output latch memory. are driven.
(Refresh method)
2. Short pulses cannot be received.
The ON duration and OFF duration of inputs in PLCs require longer time than "PLC cycle time + Input filter
response delay".
When the response delay "10 ms" of the input filter is considered and the cycle time is supposed as "10 ms",
the ON duration and OFF duration should be at least 20 ms respectively.
Accordingly, PLCs cannot handle input pulses at 25 Hz (= 1000 /(20 + 20)) or more. However, the situation
can be improved by PLC special functions and applied instructions.
Convenient functions for
improvement
By using the following functions, PLCs
can receive pulses shorter than the
operation cycle:
• High speed counter function
• Input interrupt function
• Pulse catch function
• Input filter value adjustment function
16
OFF
This "input ON" can be received.
"Input ON" cannot
This "input OFF" cannot
be received.
be received.
ON
ON OFF
Program
processing
Program
processing
Input processing
Output processing
(
Program
processing
Time)
Program
processing
Operation cycle
FXCPU Structured Programming Manual
(Application Functions)
1.3 Cautions on Creation of Fundamental Programs
1
Double output (double coil) operation and countermeasures
Outline
1.3.2
1 Outline
This subsection explains the double output (double coil) operation and countermeasures.
1. Operation of double outputs
Suppose that the same coil Y003 is used in two positions as
shown in the right figure.
For example, suppose that X001 is ON and X002 is OFF.
In the second coil Y003, however, the image memory is set to
OFF because the input X002 is OFF.
X001
First
Y003
X002
Second
3
Y004
4
How to Read
Explanation of
Functions
As a result, the actual output to the outside is "Y003: OFF, Y004:
ON".
Y003
Function
Construction
In the first coil Y003, the image memory is set to ON and the
output Y004 is also set to ON because the input X001 is ON.
Input processing
X001=ON X002=OFF
Y003
Output processing
Y003=OFF Y004=ON
5
Double outputs (double coils) do not cause an illegal input error (program error), but the operation is
complicated as described above.
Change the program as shown in the example below.
Y000
Ignored
C
E
A
B
C
E
6
Y000
Standard
Function Blocks
B
Applied
Functions
2. Countermeasures against double outputs
A
2
Function List
When a coil (output variable) is used twice (double coils) in another program block to be executed or in the
same program block, the PLC gives priority to the latter coil.
D
A
Y000
A
B
M100
C
E
M101
Correspondence
between Devices
and Addresses
D
Or
D
M100
Y000
M101
The SET and RST instructions or jump instruction can be used instead, or a same output coil can be
programmed at each state using step ladder instructions STL and RET.
When you use the step ladder instructions STL and RET, note that the PLC regards it as double coils if you
program, inside the state, an output coil located outside the RET instruction from another program block or
the STL instruction.
17
FXCPU Structured Programming Manual
(Application Functions)
1.3.3
1 Outline
1.3 Cautions on Creation of Fundamental Programs
Circuits not available in structured ladder programs and countermeasures
1. Bridge circuit
A circuit in which the current flows in both directions should be changed as shown in the right figure (so that a
circuit without D and a circuit without B are connected in parallel).
A
F
B
C
B
E
D
F
A
E
A
C
E
D
C
2. Coil connection position
• You can program a contact on the right side of a coil. In this case, make sure to program a coil (including a
function or function block) at the end of the circuit.
A
B
C
D
E
A
E
B
C
D
Or
A
1.3.4
E
B
D
C
Handling of general flags
The following flags are valid in general sequence instructions:
(Examples)
M8020:Zero flag
M8021:Borrow flag
M8022:Carry flag
M8029:Instruction execution complete flag
M8090:Block comparison signal*1
*1
M8328:Instruction non-execution flag
M8329:Instruction execution abnormal complete flag*2
M8304:Zero flag*1
M8306:Carry flag*1
*1.
Supported only in FX3U/FX3UC PLCs.
*2.
Supported only in FX3U/FX3UC/FX3G PLCs.
Each of these flags turns ON or OFF every time the PLC executes a corresponding instruction. These flags
do not turn ON or OFF when the PLC does not execute a corresponding instruction or when an error occurs.
Because these flags are related to many sequence instructions, their ON/OFF status changes every time the
PLC executes each corresponding instruction.
Refer to examples in the next page, and program a flag contact just under the target sequence instruction.
18
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.3 Cautions on Creation of Fundamental Programs
Good example
M8000
D0
10
EN
s1
s2
M8029
M8029 works as
a flag to indicate
that execution of
DSW is completed.
Execution is
completed.
DSW
ENO
d1
d2
Y010
D0
MUL
ENO
d
Number of output pulses
3
Function
Construction
X010
1
EN
s1
s2
4
How to Read
Explanation of
Functions
M0
S
X000
M0
DPLSY
EN
ENO
s1
d
s2
5
Applied
Functions
1000
Number of
output pulses
M8029 works as
a flag to indicate
that execution of
DPLSY is
completed.
Y000
M0
R
M8029
Execution is
completed.
M8029 works as
a flag to indicate
that execution of
DPLSY (on the
lower side) is
completed.
M0
R
M8029
Program for DPLSY (on the upper side)
Execution is
completed.
M8000
X010
1
EN
s1
s2
DSW
ENO
d1
d2
A
Correspondence
between Devices
and Addresses
M8029 works as
a flag to indicate
that execution of
DSW is completed.
6
Standard
Function Blocks
Bad example
2
Function List
If you program the instruction execution complete flag M8029 twice or more together for two or more
sequence instructions which actuate the flag M8029, you cannot judge easily by which sequence instruction
the flag M8029 is controlled. In addition, the flag M8029 does not turn ON or OFF correctly for each
corresponding sequence instruction.
Refer to the next page when you would like to use the flag M8029 in any position other than the position just
under the corresponding sequence instruction.
1
Outline
1. Program containing many flags (Example of instruction execution complete flag M8029)
Y010
D0
M0
S
X000
M0
1000
Number of
M8029 works as a
output pulses
flag to indicate that
execution of DPLSY
(on the upper side) M8029
is completed.
Execution is
D0
completed.
10
M1
1000
Number of
output pulses2
DPLSY
EN
ENO
s1
d
s2
EN
s1
s2
MUL
ENO
d
DPLSY
EN
ENO
s1
d
s2
DPLSY(on the upper side)
Y000
Program for DSW
Number of output pulses
DPLSY(on the lower side)
Y001
19
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.3 Cautions on Creation of Fundamental Programs
2. Introduction of a method to use flags in any positions other than positions just under
sequence instructions
If two or more sequence instructions are programmed, general flags turn ON or OFF when each
corresponding instruction is executed.
Accordingly, when using a general flag in any position other than a position just under a sequence instruction,
set to ON or OFF another device (variable) just under the sequence instruction, and then use the contact of
such device (variable) as the command contact.
M8000
X010
1
DSW execution
complete flag
M8029 is changed
to M100.
EN
s1
s2
DSW
ENO
d1
d2
Y010
D0
M100
M8029
Execution is
completed.
M0
1000
Number of
output pulses
DPLSY execution
complete flag
M8029 is changed
to M200.
DPLSY
EN
ENO
s1
d
s2
Y000
M0
R
M8029
Execution is
completed.
M200
It works as the DSW
execution complete flag.
M100
It works as the DPLSY
execution complete flag.
M200
20
D0
10
EN
s1
s2
MUL
ENO
d
Y030
Number of output pulses
FXCPU Structured Programming Manual
(Application Functions)
1.3 Cautions on Creation of Fundamental Programs
1
Handling of operation error flag
When there is an error in the instruction construction, target device or target device number range and an
error occurs while operation is executed, the following flag turns ON and the error information is stored.
1. Operation error
2
Error flag
Device which stores
error code
M8067
D8067
Function List
*1.
Device which stores error occurrence step
FX0/FX0S/FX0N/FXU/FX2C/FX1S
/FX1N/FX2N/FX1NC/FX2NC/FX3G
FX3U/FX3UC
D8069*1
D8315, D8314
• When another error occurs in another step, the stored data is updated in turn to the error code and step
number of the new error. (These devices are set to OFF when errors are cleared.)
2. Operation error latch
Device which stores
error code
M8068
-
5
Device which stores error occurrence step
FX0/FX0S/FX0N/FXU/FX2C/FX1S
/FX1N/FX2N/FX1NC/FX2NC/FX3G
FX3U/FX3UC
D8068*2
D8313, D8312
Applied
Functions
Error flag
4
How to Read
Explanation of
Functions
• When the PLC mode changes from STOP to RUN, these devices are cleared instantaneously, and then
turn ON again if errors have not been cleared.
3
Function
Construction
When an error occurs in a step up to the step No. 32767 in the FX3U/FX3UC PLC, you can check the
error occurrence step also in D8069 (16 bits).
• When an operation error has occurred, M8067 turns ON, D8067 stores the operation error code, and the
specified device (shown in the table above) stores the error occurrence step.
*2.
Outline
1.3.5
1 Outline
When an error occurs in a step up to the step No. 32767 in the FX3U/FX3UC PLC, you can check the
error occurrence step also in D8068 (16 bits).
• Even if another error occurs in another step, the stored data is not updated and remains held until these
devices are forcibly set to OFF or until the power is turned OFF.
Standard
Function Blocks
• When an operation error has occurred, M8068 turns ON, and the device shown in the table above stores
the error occurrence step.
6
A
Correspondence
between Devices
and Addresses
21
FXCPU Structured Programming Manual
(Application Functions)
2.
2 Function List
2.1 Type Conversion Functions
Function List
This chapter introduces a list of functions available in programming.
2.1
Type Conversion Functions
Applicable PLC
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
BOOL_TO_INT(_E)
Converts bit data into word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.1
BOOL_TO_DINT(_E)
Converts bit data into double word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.2
BOOL_TO_STR(_E)
Converts bit data into string data.
3
BOOL_TO_WORD(_E)
Converts bit data into word [unsigned]/bit string
[16-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.4
BOOL_TO_DWORD
(_E)
Converts bit data into double word [unsigned]/bit
string [32-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.5
BOOL_TO_TIME(_E)
Converts bit data into time data.
3
3
3
3
3
3
3
3
Subsection
5.1.6
INT_TO_DINT(_E)
Converts word [signed] data into double word
[signed] data
3
3
3
3
3
3
3
3
Subsection
5.1.7
DINT_TO_INT(_E)
Converts double word [signed] data into word
[signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.8
INT_TO_BOOL(_E)
Converts word [signed] data into bit data.
3
3
3
3
3
3
3
3
Subsection
5.1.9
DINT_TO_BOOL(_E)
Converts double word [signed] data into bit data.
3
3
3
3
3
3
3
3
Subsection
5.1.10
INT_TO_REAL(_E)
Converts word [signed] data into float (single
precision) data.
3
*1
3
Subsection
5.1.11
DINT_TO_REAL(_E)
Converts double word [signed] data into float
(single precision) data.
3
*1
3
Subsection
5.1.12
INT_TO_STR(_E)
Converts word [signed] data into string data.
3
Subsection
5.1.13
DINT_TO_STR(_E)
Converts double word [signed] data into string
data.
3
Subsection
5.1.14
INT_TO_WORD(_E)
Converts word [signed] data into word
[unsigned]/bit string [16-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.15
DINT_TO_WORD(_E)
Converts double word [signed] data into word
[unsigned]/bit string [16-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.16
INT_TO_DWORD(_E)
Converts word [signed] data into double word
[unsigned]/bit string [32-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.17
DINT_TO_DWORD
(_E)
Converts double word [signed] data into double
word [unsigned]/bit string[32-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.18
INT_TO_BCD(_E)
Converts word [signed] data into BCD data.
3
3
3
3
3
3
3
3
Subsection
5.1.19
DINT_TO_BCD(_E)
Converts double word [signed] data into BCD
data.
3
3
3
3
3
3
3
3
Subsection
5.1.20
INT_TO_TIME(_E)
Converts word [signed] data into time data.
3
3
3
3
3
3
3
3
Subsection
5.1.21
DINT_TO_TIME(_E)
Converts double word [signed] data into time
data.
3
3
3
3
3
3
3
3
Subsection
5.1.22
Function name
*1.
22
Function
Reference
Subsection
5.1.3
The function is provided in the FX3G Series Ver.1.10 or later.
FXCPU Structured Programming Manual
(Application Functions)
2 Function List
2.1 Type Conversion Functions
1
3
Subsection
5.1.23
REAL_TO_DINT(_E)
Converts float (single precision) data into double
word [signed] data.
3
*1
3
Subsection
5.1.24
REAL_TO_STR(_E)
Converts float (single precision) data into string
data.
3
WORD_TO_BOOL(_E)
Converts word [unsigned]/bit string [16-bit] data
into bit data.
3
3
3
3
3
3
3
3
Subsection
5.1.26
DWORD_TO_BOOL
(_E)
Converts double word [unsigned]/bit string [32bit] data into bit data.
3
3
3
3
3
3
3
3
Subsection
5.1.27
WORD_TO_INT(_E)
Converts word [unsigned]/bit string [16-bit] data
into word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.28
WORD_TO_DINT(_E)
Converts word [unsigned]/bit string [16-bit] data
into double word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.29
DWORD_TO_INT(_E)
Converts double word [unsigned]/bit string [32bit] data into word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.30
DWORD_TO_DINT
(_E)
Converts double word [unsigned]/bit string [32bit] data into double word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.31
WORD_TO_DWORD
(_E)
Converts word [unsigned]/bit string [16-bit] data
into double word [unsigned]/bit string [32-bit].
3
3
3
3
3
3
3
3
Subsection
5.1.32
DWORD_TO_WORD
(_E)
Converts double word [unsigned]/bit string [32bit] data into word [unsigned]/bit string [16bit]data.
3
3
3
3
3
3
3
3
Subsection
5.1.33
WORD_TO_TIME(_E)
Converts word [unsigned]/bit string [16-bit] data
into time data.
3
3
3
3
3
3
3
3
Subsection
5.1.34
DWORD_TO_TIME
(_E)
Converts double word [unsigned]/bit string [32bit] data into time data.
3
3
3
3
3
3
3
3
Subsection
5.1.35
STR_TO_BOOL(_E)
Converts string data into bit data.
3
Subsection
5.1.36
STR_TO_INT(_E)
Converts string data into word [signed] data.
3
Subsection
5.1.37
STR_TO_DINT(_E)
Converts string data into double word [signed]
data.
3
Subsection
5.1.38
STR_TO_REAL(_E)
Converts string data into float (single precision)
data.
3
Subsection
5.1.39
A
Subsection
5.1.40
Correspondence
between Devices
and Addresses
FX0(S)
*1
FX0N
3
Standard
Function Blocks
FXU/FX2C
FX2N(C)
Converts float (single precision) data into word
[signed] data.
Function
FX1S
FX3G
REAL_TO_INT(_E)
Function name
FX1N(C)
FX3U(C)
Outline
Applicable PLC
Reference
BCD_TO_INT(_E)
Converts BCD data into word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.41
BCD_TO_DINT(_E)
Converts BCD data into double word [signed]
data.
3
3
3
3
3
3
3
3
Subsection
5.1.42
TIME_TO_BOOL(_E)
Converts time data into bit data.
3
3
3
3
3
3
3
3
Subsection
5.1.43
TIME_TO_INT(_E)
Converts time data into word [signed] data.
3
3
3
3
3
3
3
3
Subsection
5.1.44
TIME_TO_DINT(_E)
Converts time data into double word [signed]
data.
3
3
3
3
3
3
3
3
Subsection
5.1.45
TIME_TO_STR(_E)
Converts time data into string data.
3
TIME_TO_WORD(_E)
Converts time data into word [unsigned]/bit
string [16-bit]data.
3
3
3
3
3
3
3
3
Subsection
5.1.47
TIME_TO_DWORD
(_E)
Converts time data into double word [unsigned]/
bit string [32-bit] data.
3
3
3
3
3
3
3
3
Subsection
5.1.48
*1.
Subsection
5.1.46
The function is provided in the FX3G Series Ver.1.10 or later.
23
5
Applied
Functions
3
4
How to Read
Explanation of
Functions
Converts string data into time data.
3
Function
Construction
STR_TO_TIME(_E)
Function List
Subsection
5.1.25
2
6
FXCPU Structured Programming Manual
(Application Functions)
2.2
2 Function List
2.2 Standard Functions Of One Numeric Variable
Standard Functions Of One Numeric Variable
Applicable PLC
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2.3
Obtains the absolute value.
FX3G
ABS(_E)
Function
FX3U(C)
Function name
3
3
3
3
3
3
3
3
Reference
Subsection
5.2.1
Standard Arithmetic Functions
Applicable PLC
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
ADD_E
Adds data.
3
3
3
3
3
3
3
3
Subsection
5.3.1
SUB_E
Subtracts data.
3
3
3
3
3
3
3
3
Subsection
5.3.2
MUL_E
Multiplies data.
3
3
3
3
3
3
3
3
Subsection
5.3.3
DIV_E
Divides data (, and outputs the quotient).
3
3
3
3
3
3
3
3
Subsection
5.3.4
MOD(_E)
Divides data (, and outputs the remainder).
3
3
3
3
3
3
3
3
Subsection
5.3.5
EXPT(_E)
Obtains the raised result.
3
MOVE(_E)
Transfers data.
3
Function name
24
Function
Reference
Subsection
5.3.6
3
3
3
3
3
3
3
Subsection
5.3.7
FXCPU Structured Programming Manual
(Application Functions)
2.4 Standard Bit Shift Functions
1
Standard Bit Shift Functions
Outline
2.4
2 Function List
Applicable PLC
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Shifts bits leftward.
3
3
3
3
3
3
3
3
Subsection
5.4.1
SHR(_E)
Shifts bits rightward.
3
3
3
3
3
3
3
3
Subsection
5.4.2
Function
Reference
2
Function List
FX3U(C)
SHL(_E)
Function name
3
Standard Bitwise Boolean Functions
Function
Construction
2.5
Applicable PLC
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Obtains the logical product.
3
3
3
3
3
3
3
3
Subsection
5.5.1
OR_E
Obtains the logical sum.
3
3
3
3
3
3
3
3
Subsection
5.5.2
XOR_E
Obtains the exclusive logical sum.
3
3
3
3
3
3
3
3
Subsection
5.5.3
NOT(_E)
Obtains the logical not.
3
3
3
3
3
3
3
3
Subsection
5.5.4
Reference
4
Standard Selection Functions
6
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Selects data in accordance with the input
condition.
3
3
3
3
3
3
3
3
Subsection
5.6.1
MAXIMUM(_E)
Searches the maximum value.
3
3
3
3
3
3
3
3
Subsection
5.6.2
MINIMUM(_E)
Searches the minimum value.
3
3
3
3
3
3
3
3
Subsection
5.6.3
LIMITATION(_E)
Judges whether data is located within the range
between the upper limit value and the lower limit
value.
3
3
3
3
3
3
3
3
Subsection
5.6.4
MUX(_E)
Selects data, and outputs it.
3
3
3
3
3
3
3
3
Subsection
5.6.5
Reference
25
A
Correspondence
between Devices
and Addresses
FX3U(C)
SEL(_E)
Function
Standard
Function Blocks
Applicable PLC
Function name
5
Applied
Functions
2.6
Function
How to Read
Explanation of
Functions
FX3U(C)
AND_E
Function name
FXCPU Structured Programming Manual
(Application Functions)
2.7
2 Function List
2.7 Standard Comparison Functions
Standard Comparison Functions
Applicable PLC
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
GT_E
Compares data with regard to "> (larger)".
3
3
3
3
3
3
3
3
Subsection
5.7.1
GE_E
Compares data with regard to "≥ (larger or
equal)".
3
3
3
3
3
3
3
3
Subsection
5.7.2
EQ_E
Compares data with regard to "= (equal)".
3
3
3
3
3
3
3
3
Subsection
5.7.3
LE_E
Compares data with regard to "≤ (smaller or
equal)".
3
3
3
3
3
3
3
3
Subsection
5.7.4
LT_E
Compares data with regard to "< (smaller)".
3
3
3
3
3
3
3
3
Subsection
5.7.5
NE_E
Compares data with regard to "≠ (unequal)".
3
3
3
3
3
3
3
3
Subsection
5.7.6
Function name
2.8
Function
Reference
Standard Character String Functions
Applicable PLC
FX0(S)
FX0N
FXU/FX2C
FX1S
FX1N(C)
FX2N(C)
FX3G
Function
FX3U(C)
Function name
Reference
MID(_E)
Obtains a character string from a specified
position.
3
Subsection
5.8.1
CONCAT(_E)
Connects character strings.
3
Subsection
5.8.2
INSERT(_E)
Inserts a character string.
3
Subsection
5.8.3
DELETE(_E)
Deletes a character string.
3
Subsection
5.8.4
REPLACE(_E)
Replaces a character string.
3
Subsection
5.8.5
FIND(_E)
Searches a character string.
3
Subsection
5.8.6
2.9
Functions Of Time Data Types
Applicable PLC
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
ADD_TIME(_E)
Adds time data.
3
3
3
3
3
3
3
3
Subsection
5.9.1
SUB_TIME(_E)
Subtracts time data.
3
3
3
3
3
3
3
3
Subsection
5.9.2
MUL_TIME(_E)
Multiplies time data.
3
3
3
3
3
3
3
3
Subsection
5.9.3
DIV_TIME(_E)
Divides time data.
3
3
3
3
3
3
3
3
Subsection
5.9.4
Function name
26
Function
Reference
FXCPU Structured Programming Manual
(Application Functions)
2.10 Standard Function Blocks
1
Standard Function Blocks
Outline
2.10
2 Function List
Applicable PLC
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Reference
R_TRIG(_E)
Detects the rising edge of a signal, and outputs
pulse signal.
3
3
3
3
3
3
3
3
Section 6.1
F_TRIG(_E)
Detects the falling edge of a signal, and outputs
pulse signal.
3
3
3
3
3
3
3
3
Section 6.2
CTU(_E)
Counts up the number of times of rising of a
signal.
3
3
3
3
3
3
Section 6.3
CTD(_E)
Counts down the number of times of rising of a
signal.
3
3
3
3
3
3
Section 6.4
CTUD(_E)
Counts up/down the number of times of rising of
a signal.
3
3
3
3
3
3
Section 6.5
TP(_E)
Keeps ON a signal during specified time
duration.
3
3
3
3
3
3
Section 6.6
4
TON(_E)
Keeps OFF a signal during specified time
duration.
3
3
3
3
3
3
Section 6.7
TOF(_E)
Turns OFF the output signal at specified time
after the input signal turned OFF.
3
3
3
3
3
3
Section 6.8
How to Read
Explanation of
Functions
COUNTER_FB_M
Counter drive
3
3
3
3
3
3
3
3
Section 6.9
TIMER_10_FB_M
10ms timer drive
3
3
3
3
3
3
3
3
Section
6.10
5
TIMER_CONT_FB_M
Retentive timer drive
3
3
3
3
Section
6.11
Applied
Functions
TIMER_100_M
100ms timer drive
3
3
3
3
Function name
Function
3
3
3
Section
6.12
3
Function
Construction
3
Function List
3
2
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
27
FXCPU Structured Programming Manual
(Application Functions)
3.
3 Function Construction
3.1 Applied Function Expression and Execution Type
Function Construction
This chapter explains the construction of applied functions.
3.1
Applied Function Expression and Execution Type
Applied function and argument
• The name expressing the contents is given to each function.
For example, the function name "SHL (bit shift left)" is given.
• Each function consists of arguments which indicate I/O data used in the function.
D0
K1
SHL_E
EN
ENO
_IN
*1
_N
D10
_IN ( s ) : An argument whose contents do not change even if the function is executed is called
"source", and expressed in this symbol.
*1 ( d ) : An argument whose contents change when the function is executed is called "destination",
and expressed in this symbol.
K1 ( n ) : Arguments not regarded as source or destination are expressed in "m", "n", etc.
Argument target devices
• The input variable (label or device) specifies the target.
• Bit device themselves such as X, Y, M and S may be handled.
• Bit devices may be combined in a way "KnX", "KnY", "KnM" and "KnS" to express numeric data.
→ FX Structured Programming Manual (Device & Common)
• Current value registers of data registers (D), timers (T) and counters (C) may be handled.
• When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects.
Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they have 32-bit length. Use global labels
when specifying devices.
When 32-bit data is handled, two consecutive 16-bit data registers D are combined.
For example, when data register D0 is defined as an argument of a 32-bit instruction by a label, 32-bit data
stored in D1 and D0 is handled. (D1 offers high-order 16 bits, and D0 offers low-order 16-bits.)
When the current value register of a timer or counter is used as a general data register, it is handled in the
same way.
28
FXCPU Structured Programming Manual
(Application Functions)
3.2 Labels
1
Labels
Outline
3.2
3 Function Construction
Label types
Labels are classified into two types, global and local.
2
Function List
• Global labels can be used in program components and function blocks.
• Local labels can be used only in declared program blocks.
Label class
The label class indicates how each label can be used from which program component.
The table below shows label classes.
3
VAR_GLOBAL
Description
Common label available in all program components
VAR_GLOBAL_CONSTANT Common constant available in all program components
Program
block
Function
Function
block
3
3
3
3
3
3
VAR_CONSTANT
Constant available within declared program components, and
not available in any other program component
3
3
3
VAR_INPUT
Label which receives a value, and cannot be changed in
program components
3
3
VAR_OUTPUT
Label output from a function block
3
VAR_IN_OUT
Local label which receives a value, outputs it from a program
component, and can be changed in program components
3
5
Applied
Functions
3
4
How to Read
Explanation of
Functions
VAR
Label available within declared program components, and not
available in any other program component
Function
Construction
Applicable program component
Class
Label definition
6
Standard
Function Blocks
It is necessary to define a label to use the label.
An error will occur when a program in which labels are not defined is converted (compiled).
• When defining a global label, set the label name, class and data type, and assigns a device.
• When defining a local label, set the label name, class and data type.
You do not have to specify devices for local labels. Assignment of devices is automatically executed
during compiling.
A
X000
M0
BOOL_TO_STR_E
EN
ENO
_BOOL
Correspondence
between Devices
and Addresses
In the example below, the label "VAR_D10" is set for the function "BOOL_TO_STR_E".
VAR_D10
• When using "VAR_D10" as a global label
Set the class, label name, data type and device (or address).
• When using "VAR_D10" as a local label
Set the class, label name and data type.
29
FXCPU Structured Programming Manual
(Application Functions)
3 Function Construction
3.2 Labels
Constant description method
The table below the description method required to set a constant to a label.
Constant type
Description method
Example
Bit
Input "TRUE" or "FALSE". Or input "0" or "1".
TRUE, FALSE
Binary number
Add "2#" before a binary number.
2#0010, 2#01101010
Octal number
Add "8#" before an octal number.
8#0, 8#337
Decimal number
Input a decimal number directly. Or add "K" before a decimal
123, K123
number.
Hexadecimal number
Add "16#" or "H" before a hexadecimal number.
16#FF, HFF
Real number
Input a real number directly. Or add "E" before a real number.
2.34, E2.34
Character string
Surround a character string with single quotations (') or double
'ABC', "ABC"
quotations (").
Data type
The label data type is basic or universal.
• The table below shows a list of basic data types.
Data type
Description
Value range
Bit length
Bit
Boolean data
0(FALSE), 1(TRUE)
1 bit
Word [signed]
Integer
-32768 to 32767
16 bits
Double Word [signed]
Double precision integer
-2147483648 to
2147483647
32 bits
Word [unsigned]/Bit String
16-bit data
[16-bit]
0 to 65535
16 bits
Double Word [unsigned]/Bit
32-bit data
String [32-bit]
0 to 4294967295
32 bits
E ±1.175495-38 to
30
FLOAT (Single Precision)
Real number
E ±3.402823+38
(Number of significant figures: 6)
32 bits
String
Character string
(50 characters maximum)
Variable
Time
Time value
T#-24d-0h31m23s648.00ms to
T#24d20h31m23s647.00ms
32 bits
FXCPU Structured Programming Manual
(Application Functions)
3 Function Construction
3.2 Labels
1
Outline
• The universal data type indicates data type of a label which combines several basic data types.
The data type name begins with "ANY".
ANY
2
ANY_NUM
Time
ANY_BIT
Structure
*1
String
3
ANY_INT
Word
[signed]
FLOAT
(Double
Precision)
Double word
[signed]
The "ANY" type on a higher layer contains types
on the lower layer.
The "ANY" type on the top layer contains all types.
4
Double Word
[unsigned]/
Bit String
[32-bit]
How to Read
Explanation of
Functions
FLOAT
(Single
Precision)
Word
[unsigned]/
Bit String
[16-bit]
Function
Construction
Bit
ANY_REAL
Function List
Array
ANY_SIMPLE
*1
5
ANY16
Word
[signed]
Double word
[signed]
6
Standard
Function Blocks
Double Word
[unsigned]/
Bit String
[32-bit]
Applied
Functions
Word
[unsigned]/
Bit String
[16-bit]
ANY32
A
Correspondence
between Devices
and Addresses
*1 Refer to the following manual for details.
Q/FX Structured Programming Manual (Fundamentals)
31
FXCPU Structured Programming Manual
(Application Functions)
3.3
3 Function Construction
3.3 Device and Address
Device and Address
Devices can be described in two methods, device method and address method.
Device method
In this method, a device is described using the device name and device number.
X0
D 100
Device name
Device number
Address method
This method is defined in IEC61131-3, and used as shown in the table below.
Head
1st character:
Position
I
%
%I
X
2nd character: Size
Input
(Omitted)
Bit
Q
Output
X
Bit
M
Internal
W
Word (16 bits)
D
Double word (32 bits)
L
Long Word (64 bits)
0
Memory area
position
3rd and later characters:
Classification
Number
This number is provided for
This decimal number
detailed classification.
corresponds to the device
Period (.) is used to delimit
number.
the subsequent "Number".
The characters for
classification may be omitted.
%M X 1 . 863
Size
Classification
Number
• Memory area position
The memory area position in which data is assigned is classified into "input", "output" or "internal".
X(X Device method) : I(Input)
Y(Y Device method) : Q(Output)
Any other device
: M(Internal)
• Size
The principle of the description method corresponding to the device method (MELSEC description method)
is as follows:
Bit device : X(Bit)
Word device : W(Word (16 bits)), D(Double word (32 bits))
• Classification
The 3rd and later characters indicate the device type which cannot be specified only by the position and
size explained above.
The classification is not required for devices "X" and "Y".
Refer to the following for the device description method:
→ 7.3 Appendix A
32
FXCPU Structured Programming Manual
(Application Functions)
3.4 EN and ENO
1
EN and ENO
Outline
3.4
3 Function Construction
Execution of an instruction can be controlled when the instruction contains "EN" in its name.
• "EN" inputs the instruction execution condition.
2
• "ENO" outputs the instruction execution status.
EN
TRUE(Executes operation.)
X000
Operation result
TRUE(Operation error did not occur.) Operation output value
FALSE(Operation error occurred.)
Indefinite value
FALSE
Indefinite value
BOOL_TO_STR_E
EN
ENO
_BOOL
3
Function
Construction
FALSE(Stops operation.)
ENO
Function List
• The table below shows the "ENO" status corresponding to the "EN" status and the operation result.
M1
VAR_D10
4
How to Read
Explanation of
Functions
In the above example, the function "BOOL_TO_STR_E"
is executed only when X000 is "TRUE".
When the function is executed normally, "TRUE" is output to M1.
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
33
FXCPU Structured Programming Manual
(Application Functions)
4.
4 How to Read Explanation of Functions
How to Read Explanation of Functions
Function explanation pages have the following configuration.
1)
2)
3)
4)
5)
6)
7)
* The above page is prepared for explanation, and is different from the actual page.
34
FXCPU Structured Programming Manual
(Application Functions)
4 How to Read Explanation of Functions
1
Item
Outline
1) Indicates the chapter/section/subsection number and instruction name.
2) Indicates PLCs which support the function.
Description
The PLC Series supports the function from its first product.
The supporting status varies on the version.
Applicable versions are explained in "Cautions".
2
Function List
The PLC Series does not support the function.
3) Indicates the expression of each function.
Item
Structured ladder
ST
Description
Indicates the instruction expression in the structured ladder language.
3
Indicates the instruction expression in the ST language.
5) Explanation of function and operation
The function executed by this function is explained.
In explanation, the structured ladder language is used as the representative.
Function
Construction
4) Indicates the input variable name and output variable name of the function as well as the contents and
data type of each variable.
Refer to the following for detailed data types:
→ Q/FX Structured Programming Manual (Fundamentals)
4
How to Read
Explanation of
Functions
6) Cautions
Cautions on using the function are described.
7) Program example
Program examples are explained in each language.
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
35
FXCPU Structured Programming Manual
(Application Functions)
5.
5 Applied Functions
5.1 Type Conversion Functions
Applied Functions
This chapter explains the operation outline of each applied function, symbols, I/O data type, equivalent circuit
in sequence instructions, target models, cautions and program examples.
Refer to the following manual for variables, operators, data types and program languages:
→ Q/FX Structured Programming Manual (Fundamentals)
5.1
Type Conversion Functions
5.1.1
BOOL_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function coverts bit data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_INT
M0
X000
BOOL_TO_INT_E
M0
*1.
BOOL_TO_INT
_BOOL
*1
BOOL_TO_INT_E
EN
ENO
_BOOL
*1
ST
D0
D0
BOOL_TO_INT(_BOOL);
Example:
D0:=
BOOL_TO_INT(M0);
BOOL_TO_INT_E(EN,_BOOL,
Output label
Example:
BOOL_TO_INT_E(X000,M0,
D0);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
Output
variable
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data stored in a device specified in s into word [signed] data, and outputs the
data obtained by conversion to a device specified in d .
When the input value is "FALSE", this function outputs "0" as the word [signed] data value.
When the input value is "TRUE", this function outputs "1" as the word [signed] data value.
FALSE
0
TRUE
1
Bit data
Word [signed] data
Cautions
Use the function having "_E" in its name to connect a bus.
36
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a device specified in s is converted into word [signed] data, and the data
obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(BOOL_TO_INT)
BOOL_TO_INT
_BOOL
Function List
g_bool1
2
[ST]
[Structured ladder]
g_int1 := BOOL_TO_INT(g_bool1);
g_int1
2) Function with EN/ENO(BOOL_TO_INT_E)
g_bool1
g_bool2
3
[ST]
BOOL_TO_INT_E
EN
ENO
_BOOL
g_bool3 := BOOL_TO_INT_E(g_bool1, g_bool2, g_int1);
g_bool3
g_int1
Function
Construction
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
37
FXCPU Structured Programming Manual
(Application Functions)
5.1.2
5 Applied Functions
5.1 Type Conversion Functions
BOOL_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts bit data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_DINT
BOOL_TO_DINT_
E
M0
X000
M0
*1.
ST
BOOL_TO_DINT
_BOOL
*1
BOOL_TO_DINT_E
EN
ENO
_BOOL
*1
Label
Label
BOOL_TO_DINT(_BOOL);
Example:
Label:=
BOOL_TO_DINT(M0);
BOOL_TO_DINT_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_DINT_E(X000,M0,
Label);
Output variable
2. Set data
Variable
Input
variable
EN
Output
variable
Description
Data type
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data stored in a device specified in s
the data obtained by conversion to a device specified in d .
FALSE
0
TRUE
1
Bit data
Double word [signed] data
into double word [signed] data, and outputs
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
38
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a device specified in s is converted into double word [signed] data, and
the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(BOOL_TO_DINT)
BOOL_TO_DINT
_BOOL
Function List
g_bool1
2
[ST]
[Structured ladder]
g_dint1 := BOOL_TO_DINT(g_bool1);
g_dint1
2) Function with EN/ENO(BOOL_TO_DINT_E)
g_bool2
BOOL_TO_DINT_E
EN
ENO
_BOOL
g_bool3 := BOOL_TO_DINT_E(g_bool1, g_bool2, g_dint1);
g_bool3
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
g_dint1
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
39
FXCPU Structured Programming Manual
(Application Functions)
5.1.3
5 Applied Functions
5.1 Type Conversion Functions
BOOL_TO_STR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts bit data into string data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_STR
BOOL_TO_STR_
E
*1.
M0
X000
M0
BOOL_TO_STR
_BOOL
*1
BOOL_TO_STR_E
EN
ENO
_BOOL
*1
ST
Label
Label
BOOL_TO_STR(_BOOL);
Example:
Label:=
BOOL_TO_STR(M0);
BOOL_TO_STR_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_STR_E(X000,M0,
Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
Output
variable
ENO
Execution status
Bit
String data after conversion
String
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data input to a deice specified in
by conversion to a device specified in d .
FALSE
"0"
TRUE
"1"
Bit data
String data
s
into string data, and outputs the data obtained
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling string data. Use global labels when specifying labels.
40
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a deice specified in
by conversion is output to a device specified in d .
s
is converted into string data, and the data obtained
1) Function without EN/ENO(BOOL_TO_STR)
BOOL_TO_STR
_BOOL
Function List
g_bool1
2
[ST]
[Structured ladder]
g_string1 := BOOL_TO_STR(g_bool1);
g_string1
2) Function with EN/ENO(BOOL_TO_STR_E)
g_bool2
BOOL_TO_STR_E
EN
ENO
_BOOL
g_bool3 := BOOL_TO_STR_E(g_bool1, g_bool2, g_string1);
g_bool3
g_string1
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
41
FXCPU Structured Programming Manual
(Application Functions)
5.1.4
5 Applied Functions
5.1 Type Conversion Functions
BOOL_TO_WORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts bit data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_WOR
D
BOOL_TO_WOR
D_E
M0
X000
M0
*1.
ST
BOOL_TO_WORD
_BOOL
*1
D0
BOOL_TO_WORD_E
EN
ENO
_BOOL
*1
D0
BOOL_TO_WORD(_BOOL);
Example:
D0:=
BOOL_TO_WORD(M0);
BOOL_TO_WORD_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_WORD_E(X000,
M0,D0);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
ENO
Execution status
Bit
Word [unsigned]/bit string [16-bit] data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data stored in a device specified in s into word [unsigned]/bit string [16-bit] data,
and outputs the data obtained by conversion to a device specified in d .
When the input value is "FALSE", this function outputs "0H" as the word [unsigned]/bit string [16-bit] data
value.
When the input value is "TRUE", this function outputs "1H" as the word [unsigned]/bit string [16-bit] data
value.
FALSE
0H
TRUE
1H
Bit data
Word [unsigned]/
bit string [16-bit] data
Cautions
Use the function having "_E" in its name to connect a bus.
42
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a device specified in s is converted into word [unsigned]/bit string [16-bit]
data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(BOOL_TO_WORD)
BOOL_TO_WORD
_BOOL
Function List
g_bool1
2
[ST]
[Structured ladder]
g_word1 := BOOL_TO_WORD(g_bool1);
g_word1
2) Function with EN/ENO(BOOL_TO_WORD_E)
g_bool2
BOOL_TO_WORD_E
EN
ENO
_BOOL
g_bool3 := BOOL_TO_WORD_E(g_bool1, g_bool2, g_word1);
g_bool3
g_word1
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
43
FXCPU Structured Programming Manual
(Application Functions)
5.1.5
5 Applied Functions
5.1 Type Conversion Functions
BOOL_TO_DWORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts bit data into double word [unsigned]/bit string [32-bit] data, and outputs the data
obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_DWO
RD
BOOL_TO_DWO
RD_E
M0
X000
M0
*1.
BOOL_TO_DWORD
_BOOL
*1
BOOL_TO_DWORD_E
EN
ENO
_BOOL
*1
ST
Label
BOOL_TO_DWORD(_BOOL);
Example:
Label:=
BOOL_TO_DWORD(M0);
BOOL_TO_DWORD_E(EN,
_BOOL, Output label);
Example:
Label BOOL_TO_DWORD_E(X000,
M0, Label);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
EN
Data type
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
ENO
Execution status
Bit
Double word [unsigned]/bit string [32-bit] data after conversion
Double Word [unsigned]/
Bit string [32-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data stored in a device specified in s into double word [unsigned]/bit string [32bit] data, and outputs the data obtained by conversion to a device specified in d .
When the input value is "FALSE", this function outputs "0H" as the double word [unsigned]/bit string [32bit]data value.
When the input value is "TRUE", this function outputs "1H" as the double word [unsigned]/bit string [32-bit]
data value.
FALSE
0H
TRUE
1H
Bit data
Double Word [unsigned]/
Bit string [32-bit] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
44
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a device specified in s is converted into double word [unsigned]/bit string
[32-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(BOOL_TO_DWORD)
2
BOOL_TO_DWORD
_BOOL
Function List
[Structured ladder]
g_bool1
Outline
Program example
g_dword1
[ST]
3
g_dword1 := BOOL_TO_DWORD(g_bool1);
Function
Construction
2) Function with EN/ENO(BOOL_TO_DWORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dword1
How to Read
Explanation of
Functions
g_bool2
BOOL_TO_DWORD_E
EN
ENO
_BOOL
[ST]
g_bool3 := BOOL_TO_DWORD_E(g_bool1, g_bool2, g_dword1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
45
FXCPU Structured Programming Manual
(Application Functions)
5.1.6
5 Applied Functions
5.1 Type Conversion Functions
BOOL_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts bit data into time data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BOOL_TO_TIME
BOOL_TO_TIME_
E
M0
X000
M0
*1.
BOOL_TO_TIME
_BOOL
*1
BOOL_TO_TIME_E
EN
ENO
_BOOL
*1
ST
Label
Label
BOOL_TO_TIME(_BOOL);
Example:
Label:=
BOOL_TO_TIME(M0);
BOOL_TO_TIME_E(EN,_BOOL,
Output label);
Example:
BOOL_TO_TIME_E(X000,M0,
Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_BOOL ( s )
Conversion source bit data
Bit
Output
variable
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts bit data stored in a device specified in
obtained by conversion to a device specified in d .
FALSE
0
TRUE
1ms
Bit data
Time data
s
into time data, and outputs the data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
46
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, bit data stored in a device specified in
by conversion is output to a device specified in d .
s
is converted into time data, and the data obtained
1) Function without EN/ENO(BOOL_TO_TIME)
BOOL_TO_TIME
_BOOL
Function List
g_bool1
2
[ST]
[Structured ladder]
g_time1 := BOOL_TO_TIME(g_bool1);
g_time1
2) Function with EN/ENO(BOOL_TO_TIME_E)
g_bool2
BOOL_TO_TIME_E
EN
ENO
_BOOL
g_bool3 := BOOL_TO_TIME_E(g_bool1, g_bool2, g_time1);
g_bool3
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
g_time1
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
47
FXCPU Structured Programming Manual
(Application Functions)
5.1.7
5 Applied Functions
5.1 Type Conversion Functions
INT_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into double word [signed] data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_DINT
D0
X000
INT_TO_DINT_E
D0
*1.
INT_TO_DINT
_INT
*1
INT_TO_DINT_E
EN
ENO
_INT
*1
ST
Label
Label
INT_TO_DINT(_INT);
Example:
Label:=
INT_TO_DINT(D0);
INT_TO_DINT_E(EN,_INT,
Output label);
Example:
INT_TO_DINT_E(X000,D0,
Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_INT ( s )
Conversion source word [signed] data
Word [signed]
Output
variable
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s
and outputs the data obtained by conversion to a device specified in d .
1234
1234
Word [signed] data
Double word [signed] data
into double word [signed] data,
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
48
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in s is converted into double word [signed]
data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(INT_TO_DINT)
INT_TO_DINT
_INT
Function List
g_int1=5923
2
[ST]
[Structured ladder]
g_dint1 := INT_TO_DINT(g_int1);
g_dint1=5923
2) Function with EN/ENO(INT_TO_DINT_E)
g_int1
INT_TO_DINT_E
EN
ENO
_INT
g_bool3 := INT_TO_DINT_E(g_bool1, g_int1, g_dint1);
g_bool3
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
g_dint1
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
49
FXCPU Structured Programming Manual
(Application Functions)
5.1.8
5 Applied Functions
5.1 Type Conversion Functions
DINT_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into word [signed] data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
DINT_TO_INT
Label
X000
DINT_TO_INT_E
Label
*1.
ST
DINT_TO_INT
_DINT
*1
D10
DINT_TO_INT_E
EN
ENO
_DINT
*1
D10
DINT_TO_INT(_DINT);
Example:
D10:=
DINT_TO_INT(Label);
DINT_TO_INT_E(EN,_DINT,
Output label);
Example:
DINT_TO_INT_E(X000, Label,
D10);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in
and outputs the data obtained by conversion to a device specified in d .
1234
1234
Double word [signed] data
Word [signed] data
s
into word [signed] data,
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
50
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in s is converted into word [signed]
data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DINT_TO_INT)
DINT_TO_INT
_DINT
Function List
g_dint1=5923
2
[ST]
[Structured ladder]
g_int1 := DINT_TO_INT(g_dint1);
g_int1=5923
2) Function with EN/ENO(DINT_TO_INT_E)
g_dint1
DINT_TO_INT_E
EN
ENO
_DINT
g_bool3 := DINT_TO_INT_E(g_bool1, g_dint1, g_int1);
g_bool3
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
g_int1
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
51
FXCPU Structured Programming Manual
(Application Functions)
5.1.9
5 Applied Functions
5.1 Type Conversion Functions
INT_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_BOOL
D0
X000
INT_TO_BOOL_E
D0
*1.
INT_TO_BOOL
_INT
*1
INT_TO_BOOL_E
EN
ENO
_INT
*1
ST
M0
M0
INT_TO_BOOL(_INT);
Example:
M0:=
INT_TO_BOOL(D0);
INT_TO_BOOL_E(EN,_INT,
Output label);
Example:
INT_TO_BOOL_E(X000,D0,M0);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_INT ( s )
Conversion source word [signed] data
Output
variable
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
Execution condition
Bit
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s into bit data, and outputs the
data obtained by conversion to a device specified in d .
When the input value is "0", this function outputs "FALSE".
When the input value is any value other than "0", this function outputs "TRUE".
0
FALSE
1567
TRUE
Word [signed] data
Bit data
Cautions
Use the function having "_E" in its name to connect a bus.
52
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in
obtained by conversion is output to a device specified in d .
s
is converted into bit data, and the data
1) Function without EN/ENO(INT_TO_BOOL)
INT_TO_BOOL
_INT
Function List
g_int1=5923
2
[ST]
[Structured ladder]
g_bool1 := INT_TO_BOOL(g_int1);
g_bool1
2) Function with EN/ENO(INT_TO_BOOL_E)
g_int1
INT_TO_BOOL_E
EN
ENO
_INT
g_bool3 := INT_TO_BOOL_E(g_bool1, g_int1, g_bool2);
g_bool3
Function
Construction
g_bool1
3
[ST]
[Structured ladder]
Outline
Program example
g_bool2
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
53
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.10 DINT_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
DINT_TO_BOOL
DINT_TO_BOOL_
E
Label
X000
Label
*1.
DINT_TO_BOOL
_DINT
*1
DINT_TO_BOOL_E
EN
ENO
_DINT
*1
ST
M0
M0
DINT_TO_BOOL(_DINT);
Example:
M0:=
DINT_TO_BOOL(Label);
DINT_TO_BOOL_E(EN,_DINT,
Output label);
Example:
DINT_TO_BOOL_E(X000, Label,
M0);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in s
the data obtained by conversion to a device specified in d .
When the input value is "0", this function outputs "FALSE".
When the input value is any value other than "0", this function outputs "TRUE".
0
FALSE
12345678
TRUE
Double word [signed] data
Bit data
into bit data, and outputs
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
54
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in
the data obtained by conversion is output to a device specified in d .
s
is converted into bit data, and
1) Function without EN/ENO(DINT_TO_BOOL)
2
DINT_TO_BOOL
_DINT
Function List
[Structured ladder]
g_dint1=0
Outline
Program example
g_bool1
[ST]
3
g_bool1 := DINT_TO_BOOL(g_dint1);
Function
Construction
2) Function with EN/ENO(DINT_TO_BOOL_E)
[Structured ladder]
g_bool1
4
g_bool3
g_bool2
How to Read
Explanation of
Functions
g_dint1
DINT_TO_BOOL_E
EN
ENO
_DINT
[ST]
g_bool3 := DINT_TO_BOOL_E(g_bool1, g_dint1, g_bool2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
55
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.11 INT_TO_REAL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into float (single precision) data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_REAL
D0
X000
INT_TO_REAL_E
D0
*1.
INT_TO_REAL
a_Int
*1
INT_TO_REAL_E
EN
ENO
a_Int
*1
ST
Label
Label
INT_TO_REAL(a_Int);
Example:
Label:=
INT_TO_REAL(D0);
INT_TO_REAL_E(EN,a_Int,
Output label);
Example:
INT_TO_REAL_E(X000,D0,Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
a_Int ( s )
Conversion source word [signed] data
Word [signed]
Output
variable
ENO
Execution status
Bit
Float (single precision) data after conversion
FLOAT (Single Precision)
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s
and outputs the data obtained by conversion to a device specified in d .
1234
1234.0
Word [signed] data
Float (single precision) data
into float (single precision) data,
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) The function is provided in the FX3G Series Ver.1.10 or later.
56
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in s is converted into float (single
precision) data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(INT_TO_REAL)
[Structured ladder]
2
[ST]
INT_TO_REAL
a_Int
Function List
g_int1=5923
g_real1 := INT_TO_REAL(g_int1);
g_real1=5923.0
2) Function with EN/ENO(INT_TO_REAL_E)
g_bool1
g_int1
3
[ST]
INT_TO_REAL_E
EN
ENO
a_Int
g_bool3 := INT_TO_REAL_E(g_bool1, g_int1, g_real1);
g_bool3
g_real1
Function
Construction
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
57
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.12 DINT_TO_REAL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into float (single precision) data, and outputs the data
obtained by conversion.
1. Format
Expression in each language
Function name
DINT_TO_REAL
DINT_TO_REAL_
E
Structured ladder
Label 1
X000
Label 1
*1.
DINT_TO_REAL
a_Dint
*1
DINT_TO_REAL_E
EN
ENO
a_Dint
*1
ST
DINT_TO_REAL(a_Dint);
Example:
Label 2 Label 2:=
DINT_TO_REAL(Label 1);
Label 2
DINT_TO_REAL_E(EN,a_Dint,
Output label);
Example:
DINT_TO_REAL_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
a_Dint ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
Float (single precision) data after conversion
FLOAT (Single Precision)
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in s into float (single
precision) data, and outputs the data obtained by conversion to a device specified in d .
16543521
16543521.0
Double word [signed] data
Float (single precision) data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) The function is provided in the FX3G Series Ver.1.10 or later.
58
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in s is converted into float (single
precision) data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DINT_TO_REAL)
2
DINT_TO_REAL
a_Dint
Function List
[Structured ladder]
g_dint1=65000
Outline
Program example
g_real1=65000.0
[ST]
3
g_real1 := DINT_TO_REAL(g_dint1);
Function
Construction
2) Function with EN/ENO(DINT_TO_REAL_E)
[Structured ladder]
g_bool1
4
g_bool3
g_real1
How to Read
Explanation of
Functions
g_dint1
DINT_TO_REAL_E
EN
ENO
a_Dint
[ST]
g_bool3 := DINT_TO_REAL_E(g_bool1, g_dint1, g_real1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
59
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.13 INT_TO_STR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into string data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_STR
D0
X000
INT_TO_STR_E
D0
*1.
INT_TO_STR
_INT
*1
INT_TO_STR_E
EN
ENO
_INT
*1
ST
Label
Label
INT_TO_STR(_INT);
Example:
Label:=
INT_TO_STR(D0);
INT_TO_STR_E(EN,_INT,
Output label);
Example:
INT_TO_STR_E(X000, D0, Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_INT ( s )
Conversion source word [signed] data
Output
variable
ENO
Execution status
Bit
String data after conversion
String
*1
( d )
Execution condition
Bit
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function converts word [signed] data stored in a device specified in
the data obtained by conversion to a device specified in d .
Word [signed] data
s
into string data, and outputs
High-order byte
Low-order byte
ASCII code for ten-thousands place
Sign data
String
ASCII code for hundreds place ASCII code for thousands place
ASCII code for ones place ASCII code for tens place
0000H
1st word
2nd word
3rd word
4th word
Automatically stored at the end of the character string
2) In "Sign data", "20H (space)" is stored when the input value is positive, and "2DH (-)" is stored when the
input value is negative.
3) "20H (space)" is stored in high-order digits when the number of significant figures is small.
Example: When "-123" is input
-123
Word [signed] data
High-order byte
20H (space)
31H (1)
33H (3)
Low-order byte
2DH (-)
20H (space)
32H (2)
0000H
String
1st word
2nd word
3rd word
4th word
4) "00H" is automatically stored at the end (4th word) of the character string.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling string data.
Use global labels when specifying labels.
60
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
An operation error occurs in the following case. The error flag M8067 turns ON, and D8067 stores the error
code.
d
)
2
Program example
In this program, word [signed] data stored in a device specified in s
data obtained by conversion is output to a device specified in d .
is converted into string data, and the
3
1) Function without EN/ENO(INT_TO_STR)
g_int1=-12345
Function
Construction
[ST]
[Structured ladder]
INT_TO_STR
_INT
g_string1 := INT_TO_STR(g_int1);
g_string='-12345'
4
[ST]
[Structured ladder]
g_int1
INT_TO_STR_E
EN
ENO
_INT
g_bool3 := INT_TO_STR_E(g_bool1, g_int1, g_string1);
How to Read
Explanation of
Functions
2) Function with EN/ENO(INT_TO_STR_E)
g_bool1
Function List
1) When the number of points occupied by the string data storage destination (device specified in
exceeds the range of the corresponding device
(Error code: K6706)
Outline
Error
g_bool3
5
g_string1
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
61
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.14 DINT_TO_STR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into string data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
DINT_TO_STR
Label 1
X000
DINT_TO_STR_E
Label 1
*1.
ST
DINT_TO_STR
_DINT
*1
DINT_TO_STR(_DINT);
Example:
Label 2 Label 2:=
DINT_TO_STR(Label 1);
DINT_TO_STR_E
EN
ENO
_DINT
*1
DINT_TO_STR_E(EN,_DINT,
Output label);
Example:
Label 2 DINT_TO_STR_E(X000,
Label 1, Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
String data after conversion
String
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function converts double word [signed] data stored in a device specified in
outputs the data obtained by conversion to a device specified in d .
Double word [signed] data
s
into string data, and
High-order byte
Low-order byte
ASCII code for billions place
Sign data
String
ASCII code for ten-millions place ASCII code for hundred-millions place
ASCII code for hundred-thousands place ASCII code for millions place
ASCII code for thousands place ASCII code for ten-thousands place
ASCII code for tens place ASCII code for hundreds place
00H
ASCII code for ones place
1st word
2nd word
3rd word
4th word
5th word
6th word
Automatically stored at the end of the character string
2) In "Sign data", "20H (space)" is stored when the input value is positive, and "2DH (-)" is stored when the
input value is negative.
3) "20H (space)" is stored in high-order digits when the number of significant figures is small.
Example: When "-123456" is input
-123456
Double word [signed] data
High-order byte
20H (space)
20H (space)
31H (1)
33H (3)
35H (5)
00H
Low-order byte
2DH (-)
20H (space)
20H (space)
32H (2)
34H (4)
36H (6)
String
1st word
2nd word
3rd word
4th word
5th word
6th word
4) "00H" is automatically stored at the end (high-order byte of the 6th word) of the character string.
62
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data and 32-bit data in structured programs, you cannot specify 16-bit devices
directly, different from simple projects. Use labels when handling string data and 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Outline
Cautions
2
Function List
1) When the number of points occupied by the string data storage destination (device specified in
exceeds the range of the corresponding device
(Error code: K6706)
3
d
)
Program example
In this program, double word [signed] data stored in a device specified in s
and the data obtained by conversion is output to a device specified in d .
is converted into string data,
4
1) Function without EN/ENO(DINT_TO_STR)
DINT_TO_STR
_DINT
How to Read
Explanation of
Functions
[Structured ladder]
g_dint1=-12345678
Function
Construction
An operation error occurs in the following case. The error flag M8067 turns ON, and D8067 stores the error
code.
Error
g_string1='-12345678'
[ST]
5
g_string1 := DINT_TO_STR(g_dint1);
Applied
Functions
2) Function with EN/ENO(DINT_TO_STR_E)
[Structured ladder]
g_bool1
g_dint1
DINT_TO_STR_E
EN
ENO
_DINT
g_bool3
6
g_string1
Standard
Function Blocks
[ST]
g_bool3 := DINT_TO_STR_E(g_bool1, g_dint1, g_string1);
A
Correspondence
between Devices
and Addresses
63
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.15 INT_TO_WORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into word [unsigned]/bit string [16-bit] data, and outputs the data
obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_WORD
D0
X000
INT_TO_WORD_
E
D0
*1.
INT_TO_WORD
*1
_INT
INT_TO_WORD_E
EN
ENO
_INT
*1
ST
D10
D10
INT_TO_WORD(_INT);
Example:
D10:=
INT_TO_WORD(D0);
INT_TO_WORD_E(EN,_INT,
Output label);
Example:
INT_TO_WORD_E(X000,D0,D10);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_INT ( s )
Conversion source word [signed] data
Word [signed]
ENO
Execution status
Bit
Word [unsigned]/Bit String [16-bit] data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s into word [unsigned]/bit string
[16-bit] data, and outputs the data obtained by conversion to a device specified in d .
22136
5678H
Word [signed] data
Word [unsigned]/
bit string [16-bit] data
Cautions
Use the function having "_E" in its name to connect a bus.
64
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in s is converted into word [unsigned]/bit
string [16-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(INT_TO_WORD)
2
INT_TO_WORD
_INT
Function List
[Structured ladder]
g_int1=5923
Outline
Program example
g_word1=16#1723
[ST]
3
g_word1 := INT_TO_WORD(g_int1);
Function
Construction
2) Function with EN/ENO(INT_TO_WORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_word1
How to Read
Explanation of
Functions
g_int1
INT_TO_WORD_E
EN
ENO
_INT
[ST]
g_bool3 := INT_TO_WORD_E(g_bool1, g_int1, g_word1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
65
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.16 DINT_TO_WORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into word [unsigned]/bit string [16-bit] data, and outputs the
data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
DINT_TO_WORD
Label
X000
DINT_TO_WORD
_E
Label
*1.
DINT_TO_WORD
_DINT
*1
DINT_TO_WORD_E
EN
ENO
_DINT
*1
ST
D10
D10
DINT_TO_WORD(_DINT);
Example:
D10:=
DINT_TO_WORD(Label);
DINT_TO_WORD_E(EN,_DINT,
Output label);
Example:
DINT_TO_WORD_E(X000, Label,
D10);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
EN
Data type
Execution condition
Bit
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
ENO
Execution status
Bit
Word [unsigned]/bit string [16-bit] data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in s into word [unsigned]/bit
string [16-bit] data, and outputs the data obtained by conversion to a device specified in d .
12345678
614EH
Double word [signed] data
Word [unsigned]/
bit string [16-bit] data
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
614E
0 11 0 0 0 01 01 0 0 1 11 0
The information stored in high-order 16 bits is discarded.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
66
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in s is converted into word
[unsigned]/bit string [16-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DINT_TO_WORD)
2
DINT_TO_WORD
_DINT
Function List
[Structured ladder]
g_dint1=12345678
Outline
Program example
g_word1=16#614E
[ST]
3
g_word1 := DINT_TO_WORD(g_dint1);
Function
Construction
2) Function with EN/ENO(DINT_TO_WORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_word1
How to Read
Explanation of
Functions
g_dint1
DINT_TO_WORD_E
EN
ENO
_DINT
[ST]
g_bool3 := DINT_TO_WORD_E(g_bool1, g_dint1, g_word1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
67
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.17 INT_TO_DWORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into double word [unsigned]/bit string [32-bit] data, and outputs the
data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_DWORD
D0
X000
INT_TO_DWORD
_E
D0
*1.
ST
INT_TO_DWORD
_INT
*1
INT_TO_DWORD_E
EN
ENO
_INT
*1
Label
Label
INT_TO_DWORD(_INT);
Example:
Label:=
INT_TO_DWORD(D0);
INT_TO_DWORD_E(EN,_INT,
Output label);
Example:
INT_TO_DWORD_E(X000,D0,
Label);
Output variable
2. Set data
Variable
Description
EN
Input
variable
Output
variable
Data type
Execution condition
Bit
_INT ( s )
Conversion source word [signed] data
Word [signed]
ENO
Execution status
Bit
Double word [unsigned]/bit string [32-bit] data after conversion
Double Word [unsigned]/
Bit string [32-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s into double word [unsigned]/bit
string [32-bit] data, and outputs the data obtained by conversion to a device specified in d .
-325
0000FEBBH
Word [signed] data
Double word [unsigned]/
bit string [32-bit] data
-325
111 1 1 1 1 0 1 0 1 1 10 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
Each of high-order 16 bits becomes
"0" after data conversion.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
68
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in s is converted into double word
[unsigned]/bit string [32-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(INT_TO_DWORD)
2
INT_TO_DWORD
_INT
Function List
[Structured ladder]
g_int1=10
Outline
Program example
g_dword1=16#0000000A
[ST]
3
g_dword1 := INT_TO_DWORD(g_int1);
Function
Construction
2) Function with EN/ENO(INT_TO_DWORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dword1
How to Read
Explanation of
Functions
g_int1
INT_TO_DWORD_E
EN
ENO
_INT
[ST]
g_bool3 := INT_TO_DWORD_E(g_bool1, g_int1, g_dword1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
69
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.18 DINT_TO_DWORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into double word [unsigned]/bit string [32-bit] data, and
outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
DINT_TO_DWOR
D
DINT_TO_DWOR
D_E
Structured ladder
Label 1
X000
Label 1
*1.
DINT_TO_DWORD
_DINT
*1
DINT_TO_DWORD_E
EN
ENO
_DINT
*1
ST
DINT_TO_DWORD(_DINT);
Example:
Label 2 Label 2:=
DINT_TO_DWORD(Label 1);
DINT_TO_DWORD_E(EN,_DINT,
Output label);
Example:
Label 2 DINT_TO_DWORD_E(X000,
Label 1, Label 2);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
EN
Data type
Execution condition
Bit
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
ENO
Execution status
Bit
Double word [unsigned]/bit string [32-bit] data after conversion
Double Word [unsigned]/
Bit string [32-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in s into double word
[unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion to a device specified in d .
12345678
BC614EH
Double word [signed] data
Double word [unsigned]/
bit string [32-bit] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
70
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in s is converted into double word
[unsigned]/bit string [32-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DINT_TO_DWORD)
2
DINT_TO_DWORD
_DINT
Function List
[Structured ladder]
g_dint1=74565
Outline
Program example
g_dword1=16#00012345
[ST]
3
g_dword1 := DINT_TO_DWORD(g_dint1);
Function
Construction
2) Function with EN/ENO(DINT_TO_DWORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dword1
How to Read
Explanation of
Functions
g_dint1
DINT_TO_DWORD_E
EN
ENO
_DINT
[ST]
g_bool3 := DINT_TO_DWORD_E(g_bool1, g_dint1, g_dword1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
71
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.19 INT_TO_BCD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_BCD
INT_TO_BCD
_INT
*1
D0
D0
INT_TO_BCD(_INT);
Example:
D10:=
INT_TO_BCD(D0);
D10
INT_TO_BCD_E
EN
ENO
_INT
*1
X000
INT_TO_BCD_E
*1.
ST
INT_TO_BCD_E(EN,_INT,
Output label);
Example:
INT_TO_BCD_E(X000,D0,D10);
D10
Output variable
2. Set data
Variable
Description
EN
Input
variable
Output
variable
Data type
Execution condition
Bit
_INT ( s )
Conversion source word [signed] data
Word [signed]
ENO
Execution status
Bit
BCD data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in
data obtained by conversion to a device specified in d .
9999
9999H
Word [signed] data
Word [unsigned]/
bit string [16-bit] data
32768 16384 8192 4096 2048 1024 512
9999
0
0
1
0
0
1
1
256
128
64
32
16
8
4
2
1
1
0
0
0
0
1
1
1
1
Make sure to set them to "0".
8000 4000 2000 1000 800
9999H
1
0
0
1
Thousands place
1
into BCD data, and outputs the
s
is outside the range from "0" to
Conversion into BCD data
400
200
100
80
40
20
10
8
4
2
1
0
0
1
1
0
0
1
1
0
0
1
Hundreds place
s
Tens place
Ones place
Cautions
Use the function having "_E" in its name to connect a bus.
Error
An operation error occurs when the value stored in a device specified in
"9,999".
72
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in s
data obtained by conversion is output to a device specified in d .
is converted into BCD data, and the
1) Function without EN/ENO(INT_TO_BCD)
2
INT_TO_BCD
_INT
Function List
[Structured ladder]
g_int1=5923
Outline
Program example
g_word=16#5923
[ST]
3
g_word1 := INT_TO_BCD(g_int1);
Function
Construction
2) Function with EN/ENO(INT_TO_BCD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_word1
How to Read
Explanation of
Functions
g_int1
INT_TO_BCD_E
EN
ENO
_INT
[ST]
g_bool3 := INT_TO_BCD_E(g_bool1, g_int1, g_word1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
73
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.20 DINT_TO_BCD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
DINT_TO_BCD
DINT_TO_BCD(_DINT);
Example:
Label 2 Label 2:=
DINT_TO_BCD(Label 1);
DINT_TO_BCD
_DINT
*1
Label 1
DINT_TO_BCD_E
EN
ENO
_DINT
*1
X000
DINT_TO_BCD_E
Label 1
*1.
ST
Label 2
DINT_TO_BCD_E(EN,_DINT,
Output label);
Example:
DINT_TO_BCD_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
BCD data after conversion
ANY_BIT
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in
outputs the data obtained by conversion to a device specified in d .
99999999H
Double word [signed] data
ANY_BIT data
into BCD data, and
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
99999999
s
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
101
102
103
105
106
Conversion into BCD data
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
Make sure to set them to "0".
104
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 Millions HundredTen- Thousands Hundreds
place
place thousands thousands place
place
place
place
Tens
place
Ones
place
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
74
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
An operation error occurs when the value stored in a device specified in
"99,999,999".
s
is outside the range from "0" to
Program example
is converted into BCD data,
1) Function without EN/ENO(DINT_TO_BCD)
[Structured ladder]
DINT_TO_BCD
_DINT
3
g_dword1=16#00020000
Function
Construction
g_dint1=20000
2
Function List
In this program, double word [signed] data stored in a device specified in s
and the data obtained by conversion is output to a device specified in d .
Outline
Error
[ST]
g_dword1 := DINT_TO_BCD(g_dint1);
4
How to Read
Explanation of
Functions
2) Function with EN/ENO(DINT_TO_BCD_E)
[Structured ladder]
g_bool1
g_dint1
DINT_TO_BCD_E
EN
ENO
_DINT
g_bool3
g_dword1
5
Applied
Functions
[ST]
g_bool3 := DINT_TO_BCD_E(g_bool1, g_dint1, g_dword1);
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
75
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.21 INT_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
INT_TO_TIME
D0
X000
INT_TO_TIME_E
D0
*1.
INT_TO_TIME
_INT
*1
INT_TO_TIME_E
EN
ENO
_INT
*1
ST
Label
Label
INT_TO_TIME(_INT);
Example:
Label:=
INT_TO_TIME(D0);
INT_TO_TIME_E(EN,_INT,
Output label);
Example:
INT_TO_TIME_E(X000,D0,Label);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_INT ( s )
Conversion source word [signed] data
Word [signed]
Output
variable
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [signed] data stored in a device specified in
data obtained by conversion to a device specified in d .
FFFFh
1m5s535ms
Word [signed] data
Time data
s
into time data, and outputs the
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
76
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, word [signed] data stored in a device specified in
data obtained by conversion is output to a device specified in d .
s
is converted into time data, and the
1) Function without EN/ENO(INT_TO_TIME)
[Structured ladder]
2
[ST]
INT_TO_TIME
_INT
Function List
g_int1
g_time1 := INT_TO_TIME(g_int1);
g_time1
2) Function with EN/ENO(INT_TO_TIME_E)
g_bool1
g_int1
3
[ST]
INT_TO_TIME_E
EN
ENO
_INT
g_bool3 := INT_TO_TIME_E(g_bool1, g_int1, g_time1);
g_bool3
g_time1
Function
Construction
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
77
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.22 DINT_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts double word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
DINT_TO_TIME
DINT_TO_TIME_
E
Structured ladder
Label 1
X000
Label 1
*1.
DINT_TO_TIME
_DINT
*1
DINT_TO_TIME_E
EN
ENO
_DINT
*1
ST
DINT_TO_TIME(_DINT);
Example:
Label 2 Label 2:=
DINT_TO_TIME(Label 1);
Label 2
DINT_TO_TIME_E(EN,_DINT,
Output label);
Example:
DINT_TO_TIME_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_DINT ( s )
Conversion source double word [signed] data
Double Word [signed]
Output
variable
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in
outputs the data obtained by conversion to a device specified in d .
7FFFFFFFh
24d20h31m23s647ms
Double word [signed] data
Time data
s
into time data, and
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
78
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, double word [signed] data stored in a device specified in
the data obtained by conversion is output to a device specified in d .
s
is converted into time data, and
1) Function without EN/ENO(DINT_TO_TIME)
[Structured ladder]
2
[ST]
DINT_TO_TIME
_DINT
Function List
g_dint1
g_time1 := DINT_TO_TIME(g_dint1);
g_time1
2) Function with EN/ENO(DINT_TO_TIME_E)
g_bool1
g_dint1
3
[ST]
DINT_TO_TIME_E
EN
ENO
_DINT
g_bool3 := DINT_TO_TIME_E(g_bool1, g_dint1, g_time1);
g_bool3
g_time1
Function
Construction
[Structured ladder]
Outline
Program example
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
79
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.23 REAL_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts float (single precision) data into word [signed] data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
REAL_TO_INT
Label
X000
REAL_TO_INT_E
Label
*1.
REAL_TO_INT
a_real
*1
REAL_TO_INT_E
EN
ENO
a_real
*1
ST
D10
D10
REAL_TO_INT(a_real);
Example:
D10:=
REAL_TO_INT(Label);
REAL_TO_INT_E(EN,a_real,
Output label);
Example:
REAL_TO_INT_E(X000, Label,
D10);
Output variable
2. Set data
Variable
Input
variable
EN
Output
variable
ENO
a_real
*1
Description
( s )
( d )
Data type
Execution condition
Bit
Conversion source float (single precision) data
FLOAT (Single Precision)
Execution status
Bit
Word [signed] data after conversion
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts float (single precision) data stored in a device specified in
and outputs the data obtained by conversion to a device specified in d .
1234.0
1234
Float (single precision) data
Word [signed] data
The portion after the decimal
point is rounded off.
s
into word [signed] data,
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) The function is provided in the FX3G Series Ver.1.10 or later.
4) In the data obtained by conversion, the portion after the decimal point of the float (single precision) data
(source data) is rounded off.
80
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, float (single precision) data stored in a device specified in s is converted into word
[signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(REAL_TO_INT)
2
REAL_TO_INT
a_real
Function List
[Structured ladder]
g_real1=5923.5
Outline
Program example
g_int1=5923
[ST]
3
g_int1 := REAL_TO_INT(g_real1);
Function
Construction
2) Function with EN/ENO(REAL_TO_INT_E)
[Structured ladder]
g_bool1
4
g_bool3
g_int1
How to Read
Explanation of
Functions
g_real1
REAL_TO_INT_E
EN
ENO
a_real
[ST]
g_bool3 := REAL_TO_INT_E(g_bool1, g_real1, g_int1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
81
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.24 REAL_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts float (single precision) data into double word [signed] data, and outputs the data
obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
REAL_TO_DINT
Label 1
X000
REAL_TO_DINT_
E
Label 1
*1.
REAL_TO_DINT
a_real
*1
REAL_TO_DINT_E
EN
ENO
*1
a_real
ST
Label 2
Label 2
REAL_TO_DINT(a_real);
Example:
Label 2:=
REAL_TO_DINT(Label 1);
REAL_TO_DINT_E(EN,a_real,
Output label);
Example:
REAL_TO_DINT_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Input
variable
EN
Output
variable
ENO
a_real
*1
Description
( s )
( d )
Data type
Execution condition
Bit
Conversion source float (single precision) data
FLOAT (Single Precision)
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts float (single precision) data stored in a device specified in s
[signed] data, and outputs the data obtained by conversion to a device specified in d .
16543521.0
16543521
FLOAT (single precision) data
Double word [signed] data
The portion after the decimal
point is rounded off.
into double word
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) The function is provided in the FX3G Series Ver.1.10 or later.
4) In the data obtained by conversion, the portion after the decimal point of the float (single precision) data
(source data) is rounded off.
82
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, float (single precision) data stored in a device specified in s is converted into double word
[signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(REAL_TO_DINT)
2
REAL_TO_DINT
a_real
Function List
[Structured ladder]
g_real1=65000.5
Outline
Program example
g_dint1=65000
[ST]
3
g_dint1 := REAL_TO_DINT(g_real1);
Function
Construction
2) Function with EN/ENO(DINT_TO_TIME_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dint1
How to Read
Explanation of
Functions
g_real1
REAL_TO_DINT_E
EN
ENO
a_real
[ST]
g_bool3 := REAL_TO_DINT_E(g_bool1, g_real1, g_dint1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
83
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.25 REAL_TO_STR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts float (single precision) data into string data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
REAL_TO_STR
Structured ladder
Label 1
X000
REAL_TO_STR_E
Label 1
*1.
REAL_TO_STR
_REAL
*1
REAL_TO_STR_E
EN
ENO
_REAL
*1
ST
Label 2
Label 2
REAL_TO_STR(_REAL);
Example:
Label 2:=
REAL_TO_STR(Label 1);
REAL_TO_STR_E(EN,_REAL,
Output label);
Example:
REAL_TO_STR_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_REAL ( s )
Conversion source float (single precision) data
FLOAT (Single Precision)
Output
variable
ENO
Execution status
Bit
String data after conversion
String
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function converts float (single precision) data stored in a device specified in s
(exponent) data, and outputs the data obtained by conversion to a device specified in d .
High-order byte
Float
(single
precision)
data
.
Sign
(integer part)
20H (space)
E
Sign (exponent part)
Added
automatically
ASCII code (2EH)
for decimal point (.)
ASCII code
for 2nd decimal place
ASCII code
for 4th decimal place
45H(E)
ASCII code for tens
place of exponent part
00H
Low-order byte
Sign data (integer part) String
1st word
ASCII code
for integer part
ASCII code
for 1st decimal place
ASCII code
for 3rd decimal place
ASCII code
for 5th decimal place
Sign data
(exponent part)
ASCII code for ones
place of exponent part
2nd word
Automatically stored at the end of the character string
84
into string
3rd word
4th word
5th word
6th word
7th word
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Total number of digits (12 digits)
-12.3456
Float (single precision)
data
-
Decimal part
(5 digits)
Exponent part
(2 digits)
1 . 2 3 4 5 6 E + 0 1
3
Total number of digits (12 digits)
4
How to Read
Explanation of
Functions
7
Float (single precision)
data
- 1 . 2 3 4 5 6 7 8 E + 0 1
Number of digits
of decimal part (5)
These digits are rounded.
5
d) "30H (0)" is stored in the decimal part when the number of significant figures is small.
Float (single precision)
data
Applied
Functions
Total number of digits (12 digits)
-12.34
- 1 . 2 3 4 0 0 E + 0 1
"30H (0)" is stored.
Number of digits of decimal part (5)
Total number of digits (12 digits)
A
Number of digits of exponent part (2)
Correspondence
between Devices
and Addresses
- 1 . 2 3 4 5 6 E + 0 1
Float (single precision)
data
6
Standard
Function Blocks
e) In "Sign data (exponent part)", "2BH (+)" is stored when the input value is positive, and "2DH (-)" is
stored when the input value is negative.
f) "30H (0)" is stored in the tens place of the exponent part when the exponent part consists of 1 digit.
-12.3456
Function
Construction
"45H (E)" is stored.
"2EH (.)" is stored.
b) In "Sign data (integer part)", "20H (space)" is stored when the input value is positive, and "2DH (-)" is
stored when the input value is negative.
c) The 6th and later digits of the decimal part are rounded.
-12.345678
2
Function List
Integer part
(1 digit)
Outline
2) The string data obtained by conversion is output to a device specified in d as follows:
a) The number of digits is fixed respectively for the integer part, decimal part and exponent part as
follows:
Integer part: 1, decimal part: 5, exponent part: 2
"2EH (.)" is automatically stored in the 3rd byte, and "45H (E)" is automatically stored in the 9th byte.
"30H (0)" is stored.
3) "00H" is automatically stored at the end (7th word) of the character string.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data and 32-bit data in structured programs, you cannot specify 16-bit
devices directly, different from simple projects. Use labels when handling string data and 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
85
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When the value stored in a device specified in s is outside the following range:
0, ±2-126≤ (Value of device specified in s ) ≤ ±2128
(Error code: K6706)
2) When the range of a device which will store the character string obtained by conversion (device specified
in d ) exceeds the range of the corresponding device
(Error code: K6706)
3) When the conversion result exceeds the specified total number of digits
(Error code: K6706)
Program example
In this program, float (single precision) data stored in a device specified in s
and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(REAL_TO_STR)
[Structured ladder]
g_real1=-12.34567
REAL_TO_STR
_REAL
g_string1="-1.23457E+01"
[ST]
g_string1 := REAL_TO_STR(g_real1);
2) Function with EN/ENO(REAL_TO_STR_E)
[Structured ladder]
g_bool1
g_real1
REAL_TO_STR_E
EN
ENO
_REAL
g_bool3
g_string1
[ST]
g_bool3 := REAL_TO_STR_E(g_bool1, g_real1, g_string1);
86
is converted into string data,
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.26 WORD_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts word [unsigned]/bit string [16-bit] data into bit data, and outputs the data obtained by
conversion.
1. Format
D0
X000
D0
WORD_TO_BOOL_E
EN
ENO
*1
_WORD
M0
M0
WORD_TO_BOOL(_WORD);
Example:
M0:=
WORD_TO_BOOL(D0);
WORD_TO_BOOL_E(EN,
_WORD, Output label);
Example:
WORD_TO_BOOL_E(X000,D0,
M0);
4
How to Read
Explanation of
Functions
WORD_TO_BOO
L_E
WORD_TO_BOOL
_WORD
*1
ST
Function
Construction
Structured ladder
WORD_TO_BOO
L
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_WORD ( s )
Conversion source word [unsigned]/bit String [16-bit] data
Word [unsigned]/
Bit String [16-bit]
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data stored in a device specified in
and outputs the data obtained by conversion to a device specified in d .
1567H
TRUE
Word [unsigned]/
bit string [16-bit] data
Bit data
into bit data,
A
Correspondence
between Devices
and Addresses
FALSE
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
0H
Function List
Outline
Cautions
Use the function having "_E" in its name to connect a bus.
87
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in
data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(WORD_TO_BOOL)
[Structured ladder]
g_word1=16#0001
WORD_TO_BOOL
_WORD
g_bool1
[ST]
g_bool1 := WORD_TO_BOOL(g_word1);
2) Function with EN/ENO(WORD_TO_BOOL_E)
[Structured ladder]
g_bool1
g_word1
WORD_TO_BOOL_E
EN
ENO
_WORD
g_bool3
g_bool2
[ST]
g_bool3 := WORD_TO_BOOL_E(g_bool1, g_word1, g_bool2);
88
s
is converted into bit
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.27 DWORD_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts double word [unsigned]/bit string [32-bit] data into bit data, and outputs the data
obtained by conversion.
1. Format
Label
X000
*1.
DWORD_TO_BOOL_E
EN
ENO
_DWORD
*1
M0
M0
DWORD_TO_BOOL(_DWORD);
Example:
M0:=
DWORD_TO_BOOL(Label);
DWORD_TO_BOOL_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_BOOL_E(X000,
Label, M0);
4
How to Read
Explanation of
Functions
Label
DWORD_TO_BOOL
_DWORD
*1
ST
Function
Construction
Structured ladder
DWORD_TO_BO
OL
DWORD_TO_BO
OL_E
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
5
Data type
EN
Execution condition
Bit
_DWORD ( s )
Conversion source double word [unsigned]/bit string [32-bit] data
Double Word [unsigned]/
Bit string [32-bit]
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in
bit data, and outputs the data obtained by conversion to a device specified in d .
12345678H
TRUE
Double word [unsigned]/
bit string [32-bit] data
Bit data
into
A
Correspondence
between Devices
and Addresses
FALSE
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
0H
Function List
Outline
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
89
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in
into bit data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DWORD_TO_BOOL)
[Structured ladder]
g_dword1=16#00000001
DWORD_TO_BOOL
_DWORD
g_bool1
[ST]
g_bool1 := DWORD_TO_BOOL(g_dword1);
2) Function with EN/ENO(DWORD_TO_BOOL_E)
[Structured ladder]
g_bool1
g_dword1
DWORD_TO_BOOL_E
EN
ENO
_DWORD
g_bool3
g_bool2
[ST]
g_bool3 := DWORD_TO_BOOL_E(g_bool1, g_dword1, g_bool2);
90
s
is converted
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.28 WORD_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts word [unsigned]/bit string [16-bit] data into word [signed] data, and outputs the data
obtained by conversion.
1. Format
D0
X000
D0
WORD_TO_INT_E
EN
ENO
_WORD
*1
D10
D10
WORD_TO_INT(_WORD);
Example:
D10:=
WORD_TO_INT(D0);
WORD_TO_INT_E(EN,_WORD,
Output label);
Example:
WORD_TO_INT_E(X000,D0,
D10);
4
How to Read
Explanation of
Functions
WORD_TO_INT_
E
WORD_TO_INT
_WORD
*1
ST
Function
Construction
Structured ladder
WORD_TO_INT
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_WORD ( s )
Conversion source word [unsigned]/bit string [16-bit] data
Word [unsigned]/
Bit String [16-bit]
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data stored in a device specified in
[signed] data, and outputs the data obtained by conversion to a device specified in d .
Word [unsigned]/
bit string [16-bit] data
Word [signed] data
into word
A
Correspondence
between Devices
and Addresses
22136
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
5678H
Function List
Outline
Cautions
Use the function having "_E" in its name to connect a bus.
91
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is converted into
word [signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(WORD_TO_INT)
[Structured ladder]
g_word1=16#000A
WORD_TO_INT
_WORD
g_int1=10
[ST]
g_int1 := WORD_TO_INT(g_word1);
2) Function with EN/ENO(WORD_TO_INT_E)
[Structured ladder]
g_bool1
g_word1
WORD_TO_INT_E
EN
ENO
_WORD
g_bool3
g_int1
[ST]
g_bool3 := WORD_TO_INT_E(g_bool1, g_word1, g_int1);
92
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.29 WORD_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts word [unsigned]/bit string [16-bit] data into double word [signed] data, and outputs the
data obtained by conversion.
1. Format
D0
X000
D0
WORD_TO_DINT
_WORD
*1
WORD_TO_DINT_E
EN
ENO
_WORD
*1
Label
Label
WORD_TO_DINT(_WORD);
Example:
Label:=
WORD_TO_DINT(D0);
WORD_TO_DINT_E(EN,_WORD,
Output label);
Example:
WORD_TO_DINT_E(X000,D0,
Label);
4
How to Read
Explanation of
Functions
WORD_TO_DINT
_E
ST
Function
Construction
Structured ladder
WORD_TO_DINT
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_WORD ( s )
Conversion source word [unsigned]/bit string [16-bit] data
Word [unsigned]/
Bit String [16-bit]
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data storeds in a device specified in s
word [signed] data, and outputs the data obtained by conversion to a device specified in d .
Word [unsigned]/
bit string [16-bit] data
Double word [signed] data
5678H
0 1 0 1 01 1 0 0 1 1 1 1 0 00
22136
0 0 0 0 0 0 0 0 00 00 0 0 00 01 01 0 1 1 0 01 1 1 1 0 0 0
A
Correspondence
between Devices
and Addresses
22136
into double
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
5678H
Function List
Outline
Data conversion
Each of high-order 16 bits becomes
"0" after data conversion.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
93
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is converted into
double word [signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(WORD_TO_DINT)
[Structured ladder]
g_word1=16#1234
WORD_TO_DINT
_WORD
g_dint1=4660
[ST]
g_dint1 := WORD_TO_DINT(g_word1);
2) Function with EN/ENO(WORD_TO_DINT_E)
[Structured ladder]
g_bool1
g_word1
WORD_TO_DINT_E
EN
ENO
_WORD
g_bool3
g_dint1
[ST]
g_bool3 := WORD_TO_DINT_E(g_bool1, g_word1, g_dint1);
94
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.30 DWORD_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts double word [unsigned]/bit string [32-bit] data into word [signed] data, and outputs the
data obtained by conversion.
1. Format
Label
X000
*1.
DWORD_TO_INT
_DWORD
*1
DWORD_TO_INT_E
EN
ENO
_DWORD
*1
D10
D10
DWORD_TO_INT(_DWORD);
Example:
D10:=
DWORD_TO_INT(Label);
DWORD_TO_INT_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_INT_E(X000,Label,
D10);
4
How to Read
Explanation of
Functions
Label
ST
Function
Construction
Structured ladder
DWORD_TO_INT
DWORD_TO_INT
_E
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
5
Data type
EN
Execution condition
Bit
_DWORD ( s )
Conversion source double word [unsigned]/bit string [32-bit] data
Double Word [unsigned]/
Bit string [32-bit]
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in
word [signed] data, and outputs the data obtained by conversion to a device specified in d .
Double word [unsigned]/
bit string [32-bit] data
Word [signed] data
BC614EH
0 0 00 0 0 0 01 0 11 11 0 0 0 11 0 0 0 0 1 0 1 0 0 11 1 0
24910
01 1 00 0 0 10 1 0 0 1 1 1 0
into
A
Correspondence
between Devices
and Addresses
24910
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
BC614EH
Function List
Outline
The information stored in
high-order 16 bits is discarded.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
95
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in s is converted
into word [signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DWORD_TO_INT)
[Structured ladder]
g_dword1=16#00012345
DWORD_TO_INT
_DWORD
g_int1=9029
[ST]
g_int1 := DWORD_TO_INT(g_dword1);
2) Function with EN/ENO(DWORD_TO_INT_E)
[Structured ladder]
g_bool1
g_dword1
DWORD_TO_INT_E
EN
ENO
_DWORD
g_bool3
g_int1
[ST]
g_bool3 := DWORD_TO_INT_E(g_bool1, g_dword1, g_int1);
96
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.31 DWORD_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts double word [unsigned]/bit string [32-bit] data into double word [signed] data, and
outputs the data obtained by conversion.
1. Format
Label 1
X000
Label 1
*1.
ST
DWORD_TO_DINT
_DWORD
*1
DWORD_TO_DINT(_DWORD);
Example:
Label 2 Label 2:=
DWORD_TO_DINT(Label 1);
DWORD_TO_DINT_E
EN
ENO
_DWORD
*1
DWORD_TO_DINT_E(EN,
_DWORD, Output label);
Example:
Label 2 DWORD_TO_DINT_E(X000,
Label 1, Label 2);
4
How to Read
Explanation of
Functions
DWORD_TO_DIN
T_E
Structured ladder
Function
Construction
DWORD_TO_DIN
T
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_DWORD ( s )
Conversion source double word [unsigned]/bit string [32-bit] data
Double Word [unsigned]/
Bit string [32-bit]
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in s
double word [signed] data, and outputs the data obtained by conversion to a device specified in d .
Double word [unsigned]/
bit string [32-bit] data
Double word [signed] data
A
Correspondence
between Devices
and Addresses
12345678
into
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
BC614EH
Function List
Outline
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
97
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in s is converted
into double word [signed] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DWORD_TO_DINT)
[Structured ladder]
g_dword1=16#00012345
DWORD_TO_DINT
_DWORD
g_dint1=74565
[ST]
g_dint1 := DWORD_TO_DINT(g_dword1);
2) Function with EN/ENO(DWORD_TO_DINT_E)
[Structured ladder]
g_bool1
g_dword1
DWORD_TO_DINT_E
EN
ENO
_DWORD
g_bool3
g_dint1
[ST]
g_bool3 := DWORD_TO_DINT_E(g_bool1, g_dword1, g_dint1);
98
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.32 WORD_TO_DWORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts word [unsigned]/bit string [16-bit] data into double word [unsigned]/bit string [32-bit]
data, and outputs the data obtained by conversion.
1. Format
D0
X000
*1.
WORD_TO_DWORD_E
EN
ENO
_WORD
*1
Label
WORD_TO_DWORD(_WORD);
Example:
Label:=
WORD_TO_DWORD(D0);
WORD_TO_DWORD_E(EN,
_WORD, Output label);
Example:
Label WORD_TO_DWORD_E(X000,D0,
Label);
4
How to Read
Explanation of
Functions
D0
WORD_TO_DWORD
_WORD
*1
ST
Function
Construction
Structured ladder
WORD_TO_DWO
RD
WORD_TO_DWO
RD_E
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_WORD ( s )
Conversion source word [unsigned]/bit string [16-bit] data
Word [unsigned]/
Bit String [16-bit]
ENO
Execution status
Bit
Double word[unsigned]/bit string[32-bit] data after conversion
Double Word [unsigned]/
Bit string [32-bit]
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
00005678H
Word [unsigned]/
bit string [16-bit] data
Double word [unsigned]/
bit string [32-bit] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
99
A
Correspondence
between Devices
and Addresses
This function converts word [unsigned]/bit string [16-bit] data stored in a device specified in s into double
word [unsigned]/bit [32-bit] data, and outputs the data obtained by conversion to a device specified in d .
Each of high-order 16 bits becomes "0" after data conversion.
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
5678H
Function List
Outline
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is converted into
double word [unsigned]/bit string [32-bit] data, and the data obtained by conversion is output to a device
specified in d .
1) Function without EN/ENO(WORD_TO_DWORD)
[Structured ladder]
g_word1=16#1234
WORD_TO_DWORD
_WORD
g_dword1=16#00001234
[ST]
g_dword1 := WORD_TO_DWORD(g_word1);
2) Function with EN/ENO(WORD_TO_DWORD_E)
[Structured ladder]
g_bool1
g_word1
WORD_TO_DWORD_E
EN
ENO
_WORD
g_bool3
g_dword1
[ST]
g_bool3 := WORD_TO_DWORD_E(g_bool1, g_word1, g_dword1);
100
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.33 DWORD_TO_WORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts double word [unsigned]/bit string[32-bit] data into word [unsigned]/bit string [16-bit]
data, and outputs the data obtained by conversion.
1. Format
Label
X000
Label
DWORD_TO_WORD
_DWORD
*1
DWORD_TO_WORD_E
EN
ENO
_DWORD
*1
DWORD_TO_WORD(_DWORD);
Example:
D10:=
DWORD_TO_WORD(Label);
D10
DWORD_TO_WORD_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_WORD_E(X000,
Label, D10);
D10
4
How to Read
Explanation of
Functions
DWORD_TO_WO
RD_E
ST
Function
Construction
Structured ladder
DWORD_TO_WO
RD
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
5
Data type
EN
Execution condition
Bit
_DWORD ( s )
Conversion source double word [unsigned]/bit string [32-bit] data
Double Word [unsigned]
/Bit string [32-bit]
ENO
Execution status
Bit
Word [unsigned]/bit string [16-bit] data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
6
Explanation of function and operation
5678H
Double word [unsigned]/
bit string [32-bit] data
Word [unsigned]/
bit string [16-bit] data
1
2
3
4
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 01 0 1 1 0 0 1 1 1 1 0 00
The information stored in high-order 16 bits is discarded.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
101
A
Correspondence
between Devices
and Addresses
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in s into
word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion to a device specified in
d .
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
12345678H
Applied
Functions
Input
variable
Function List
Outline
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in s is converted
into word [unsigned]/bit string [16-bit] data, and the data obtained by conversion is output to a device
specified in d .
1) Function without EN/ENO(WORD_TO_DWORD)
[Structured ladder]
g_dword1=16#12345678
DWORD_TO_WORD
_DWORD
g_word1=16#5678
[ST]
g_word1 := DWORD_TO_WORD(g_dword1);
2) Function with EN/ENO(WORD_TO_DWORD_E)
[Structured ladder]
g_bool1
g_dword1
DWORD_TO_WORD_E
EN
ENO
_DWORD
g_bool3
g_word1
[ST]
g_bool3 := DWORD_TO_WORD_E(g_bool1, g_dword1, g_word1);
102
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.34 WORD_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts word [unsigned]/bit string [16-bit] data into time data, and outputs the data obtained by
conversion.
1. Format
D0
X000
D0
WORD_TO_TIME_E
EN
ENO
_WORD
*1
Label
Label
WORD_TO_TIME(_WORD);
Example:
Label:=
WORD_TO_TIME(D0);
WORD_TO_TIME_E(EN,_WORD,
Output label);
Example:
WORD_TO_TIME_E(X000,D0,
Label);
4
How to Read
Explanation of
Functions
WORD_TO_TIME
_E
WORD_TO_TIME
_WORD
*1
ST
Function
Construction
Structured ladder
WORD_TO_TIME
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
EN
Execution condition
Bit
_WORD ( s )
Conversion source word [unsigned]/bit string [16-bit] data
Word [unsigned]/
Bit String[ 16-bit]
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data stored in a device specified in
data, and outputs the data obtained by conversion to a device specified in d .
1234
1s234ms
Word [unsigned]/
bit string [16-bit] data
Time data
into time
A
Correspondence
between Devices
and Addresses
0ms
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
0
Function List
Outline
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
103
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in
time data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(WORD_TO_TIME)
[Structured ladder]
g_word1
WORD_TO_TIME
_WORD
g_time1
[ST]
g_time1 := WORD_TO_TIME(g_word1);
2) Function with EN/ENO(WORD_TO_TIME_E)
[Structured ladder]
g_bool1
g_word1
WORD_TO_TIME_E
EN
ENO
_WORD
g_bool3
g_time1
[ST]
g_bool3 := WORD_TO_TIME_E(g_bool1, g_word1, g_time1);
104
s
is converted into
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.35 DWORD_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts double word [unsigned]/bit string [32-bit] data into time data, and outputs the data
obtained by conversion.
1. Format
Label 1
X000
Label 1
*1.
ST
DWORD_TO_TIME
_DWORD
*1
DWORD_TO_TIME(_DWORD);
Example:
Label 2 Label 2:=
DWORD_TO_TIME(Label 1);
DWORD_TO_TIME_E
EN
ENO
_DWORD
*1
DWORD_TO_TIME_E(EN,_
DWORD, Output label);
Example:
Label 2 DWORD_TO_TIME_E(X000,
Label 1, Label 2);
4
How to Read
Explanation of
Functions
DWORD_TO_TIM
E_E
Structured ladder
Function
Construction
DWORD_TO_TIM
E
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Output
variable
Description
5
Data type
EN
Execution condition
Bit
_DWORD ( s )
Conversion source double word [unsigned]/bit string [32-bit] data
Double Word [unsigned]/
Bit string [32-bit]
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
Applied
Functions
Input
variable
6
Explanation of function and operation
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in
time data, and outputs the data obtained by conversion to a device specified in d .
1234567
20m34s567ms
Double word [unsigned]/
bit string [32-bit] data
Time data
into
A
Correspondence
between Devices
and Addresses
0ms
s
Standard
Function Blocks
In explanation of functions, I/O variables inside ( ) are described.
0
Function List
Outline
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
105
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in
into time data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(DWORD_TO_TIME)
[Structured ladder]
g_dword1
DWORD_TO_TIME
_DWORD
g_time1
[ST]
g_time1 := DWORD_TO_TIME(g_dword1);
2) Function with EN/ENO(DWORD_TO_TIME_E)
[Structured ladder]
g_bool1
g_dword1
DWORD_TO_TIME_E
EN
ENO
_DWORD
g_bool3
g_time1
[ST]
g_bool3 := DWORD_TO_TIME_E(g_bool1, g_dword1, g_time1);
106
s
is converted
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.36 STR_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function converts string data into bit data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
STR_TO_BOOL_
E
Label
X000
*1.
STR_TO_BOOL_E
EN
ENO
*1
_STRING
M0
M0
STR_TO_BOOL_E(EN,_STRING,
Output label);
Example:
STR_TO_BOOL_E(X000, Label,
M0);
4
How to Read
Explanation of
Functions
Label
STR_TO_BOOL
_STRING
*1
STR_TO_BOOL(_STRING);
Example:
M0:=
STR_TO_BOOL(Label);
Function
Construction
STR_TO_BOOL
3
ST
Output variable
2. Set data
Variable
EN
Output
variable
Execution condition
Bit
_STRING ( s )
Conversion source string data
String
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
5
Data type
Applied
Functions
Input
variable
Description
In explanation of functions, I/O variables inside ( ) are described.
6
This function converts string data stored in a device specified in
obtained by conversion to a device specified in d .
FALSE
'12'
TRUE
String data
Bit data
into bit data, and outputs the data
A
Correspondence
between Devices
and Addresses
'0'
s
Standard
Function Blocks
Explanation of function and operation
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling string data.
Use global labels when specifying labels.
107
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, string data stored in a device specified in
obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(STR_TO_BOOL)
[Structured ladder]
g_string1
STR_TO_BOOL
_STRING
g_bool1
[ST]
g_bool1 := STR_TO_BOOL(g_string1);
2) Function with EN/ENO(STR_TO_BOOL_E)
[Structured ladder]
g_bool1
g_string1
STR_TO_BOOL_E
EN
ENO
_STRING
g_bool3
g_bool2
[ST]
g_bool3 := STR_TO_BOOL_E(g_bool1, g_string1, g_bool2);
108
s
is converted into bit data, and the data
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.37 STR_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts string data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
Label
X000
STR_TO_INT_E
STR_TO_INT_E
EN
ENO
_STRING
*1
D10
D10
STR_TO_INT(_STRING);
Example:
D10:=
STR_TO_INT(Label);
STR_TO_INT_E(EN,_STRING,
Output label);
Example:
STR_TO_INT_E(X000, Label,
D10);
4
How to Read
Explanation of
Functions
Label
STR_TO_INT
_STRING
*1
3
ST
Function
Construction
STR_TO_INT
*1.
Output variable
2. Set data
Variable
EN
Output
variable
Description
Execution condition
Bit
_STRING ( s )
Conversion source string data
String
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
5
Data type
Applied
Functions
Input
variable
In explanation of functions, I/O variables inside ( ) are described.
6
This function converts string data (3 words) stored in a device specified in
outputs the data obtained by conversion to a device specified in d .
into word [signed] data, and
A
High-order byte
Low-order byte
Sign data
ASCII code for ten-thousands place
ASCII code for hundreds place ASCII code for thousands place
ASCII code for ones place ASCII code for tens place
Correspondence
between Devices
and Addresses
1st word
2nd word
3rd word
s
Standard
Function Blocks
Explanation of function and operation
String
Function List
Outline
Word [signed] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling string data.
Use global labels when specifying labels.
109
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Error
1) When the sign data (low-order byte) of the 1st word stored in a device specified in
"20H (space)" or "2DH (-)"
(Error code: K6706)
2) When the ASCII code for each place (digit) stored in
"20H (space)" or "00H (NULL)"
(Error code: K6706)
3) When the value stored in
-32768 to +32767
(Error code: K6706)
4) When any of devices
(Error code: K6706)
s
s
to
to
s
s
s
to
s
s
is any other than
+2 is any other than "30H" to "39H",
+2 is outside the following range:
+2 exceeds the device range
Program example
In this program, string data stored in a device specified in s is converted into word [signed] data, and the
data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(STR_TO_INT)
[Structured ladder]
g_string1="-12345"
STR_TO_INT
_STRING
g_int1=-12345
[ST]
g_int1 := STR_TO_INT(g_string1);
2) Function with EN/ENO(STR_TO_INT_E)
[Structured ladder]
g_bool1
g_string1
STR_TO_INT_E
EN
ENO
_STRING
g_bool3
g_int1
[ST]
g_bool3 := STR_TO_INT_E(g_bool1, g_string1, g_int1);
110
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.38 STR_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts string data into double word [signed] data, and outputs the data obtained by
conversion.
1. Format
Structured ladder
Label 1
X000
STR_TO_DINT_E
*1.
STR_TO_DINT
_STRING
*1
STR_TO_DINT(_STRING);
Example:
Label 2 Label 2:=
STR_TO_DINT(Label 1);
STR_TO_DINT_E
EN
ENO
_STRING
*1
STR_TO_DINT_E(EN,_STRING,
Output label);
Example:
Label 2 STR_TO_DINT_E(X000, Label 1,
Label 2);
4
How to Read
Explanation of
Functions
Label 1
ST
Function
Construction
STR_TO_DINT
3
Expression in each language
Function name
Output variable
2. Set data
Variable
Description
EN
Output
variable
Execution condition
Bit
_STRING ( s )
Conversion source string data
String
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
5
Data type
Applied
Functions
Input
variable
6
In explanation of functions, I/O variables inside ( ) are described.
This function converts string data (6 words) stored in a device specified in s
data, and outputs the data obtained by conversion to a device specified in d .
High-order byte
Low-order byte
ASCII code for billions place
Sign data
ASCII code for ten-millions place ASCII code for hundred-millions place
ASCII code for hundred-thousands place ASCII code for millions place
ASCII code for thousands place ASCII code for ten-thousands place
ASCII code for tens place ASCII code for hundreds place
ASCII code for ones place
A
Double word [signed] data
(Ignore)
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data and 32-bit data in structured programs, you cannot specify 16-bit devices
directly, different from simple projects. Use labels when handling string data and 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
111
Correspondence
between Devices
and Addresses
1st word
2nd word
3rd word
4th word
5th word
6th word
into double word [signed]
Standard
Function Blocks
Explanation of function and operation
String
Function List
Outline
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Error
1) When the sign data (low-order byte) of the 1st word stored in a device specified in
"20H (space)" or "2DH (-)"
(Error code: K6706)
2) When the ASCII code for each place (digit) stored in
"20H (space)" or "00H (NULL)"
(Error code: K6706)
s
to
s
s
is any other than
+5 is any other than "30H" to "39H",
3) When the value stored in s to s +5 is outside the following range:
-2,147,483,648 to +2,147,483,647
(Error code: K6706)
4) When any of devices
(Error code: K6706)
s
to
s
+5 exceeds the device range
Program example
In this program, string data stored in a device specified in s is converted into double word [signed] data,
and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(STR_TO_DINT)
[Structured ladder]
g_string1="_ _65000"
STR_TO_DINT
_STRING
g_dint1=65000
[ST]
g_dint1 := STR_TO_DINT(g_string1);
2) Function with EN/ENO(STR_TO_DINT_E)
[Structured ladder]
g_bool1
g_string1
STR_TO_DINT_E
EN
ENO
_STRING
g_bool3
g_dint1
[ST]
g_bool3 := STR_TO_DINT_E(g_bool1, g_string1, g_dint1);
112
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
Outline
5.1.39 STR_TO_REAL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This function converts string data into float (single precision) data, and outputs the data obtained by
conversion.
1. Format
Label 1
X000
STR_TO_REAL_E
STR_TO_REAL
_STRING
*1
STR_TO_REAL(_STRING);
Example:
Label 2 Label 2:=
STR_TO_REAL(Label 1);
STR_TO_REAL_E
EN
ENO
*1
_STRING
STR_TO_REAL_E(EN,_STRING,
Output label);
Example:
Label 2 STR_TO_REAL_E(X000, Label 1,
Label 2);
4
How to Read
Explanation of
Functions
Label 1
ST
Function
Construction
Structured ladder
STR_TO_REAL
*1.
3
Expression in each language
Function name
Output variable
2. Set data
Variable
EN
Output
variable
Description
5
Data type
Applied
Functions
Input
variable
Execution condition
Bit
_STRING ( s )
Conversion source string data
String
ENO
Execution status
Bit
Float (single precision) data after conversion
FLOAT (Single Precision)
*1
( d )
6
In explanation of functions, I/O variables inside ( ) are described.
1) This function converts string data (in the decimal format or exponent format) stored in a device specified
in s into float (single precision) data, and outputs the data obtained by conversion to a device specified
in d .
1st word
2nd word
3rd word
4th word
5th word
6th word
7th word
Float (single precision) data
2) The conversion source string data can be in the decimal format or exponent format.
a) In the case of decimal format
String
1st word
2nd word
3rd word
4th word
5th word
High-order byte
31H (1)
33H (3)
30H (0)
34H (4)
Low-order byte
2DH (-)
2EH (.)
35H (5)
33H (3)
-1.35034
0000H
- 1 . 3 5 0 3 4
A
Correspondence
between Devices
and Addresses
String
Standard
Function Blocks
Explanation of function and operation
Low-order byte
High-order byte
ASCII code for 1st character
Sign data
ASCII code for 3rd character ASCII code for 2nd character
ASCII code for 5th character ASCII code for 4th character
ASCII code for 7th character ASCII code for 6th character
ASCII code for 9th character ASCII code for 8th character
ASCII code for 11th character ASCII code for 10th character
0000H (Indicates the end of the character string.)
Function List
Outline
Float (single precision)
data
113
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
b) In the case of exponent format
Low-order byte
2DH (-)
2EH (3)
35H (5)
33H (3)
45H (E)
31H (1)
High-order byte
31H (1)
33H (3)
30H (0)
34H (4)
2DH (-)
30H (0)
1st word
2nd word
3rd word
4th word
5th word
6th word
7th word
String
0000H
-1.35034E-10
Float (single precision)
data
- 1 . 3 5 0 3 4 E - 1 0
3) With regard to string data, six digits excluding the sign, decimal point and exponent part are valid, and the
7th and later digits are discarded during conversion.
a) In the case of decimal format
- 1 . 3 5 0 3 4 1 2 0 2 3
-1.35034
Float (single precision) data
Discarded
b) In the case of exponent format
- 1 . 3 5 0 3 4 1 2 E - 1 0
-1.35034E-10
Float (single precision) data
Discarded
4) String data in the decimal format is handled as positive value during conversion when the sign is set to
"2BH (+)" or when the sign is omitted. It is handled as negative value during conversion when the sign is
set to "2DH (-)".
5) String data in the exponent format is handled as positive value during conversion when the sign of the
exponent part is set to "2BH (+)" or when the sign is omitted. It is handled as negative value during
conversion when the sign is set to "2DH (-)".
6) When "20H (space)" or "30H (0)" exists between the sign and the first number except "0" in string data,
"20H (space)" or "30H (0)" is ignored during conversion.
a) In the case of decimal format
-
0 1 . 3 5 0 3 4
-1.35034
Float (single precision) data
Ignored
b) In the case of exponent format
-
0 1 . 3 5 0 3 4 E - 1 0
Float (single precision) data
Ignored
7)
-1.35034E-10
When "30H (0)" exists between "E" and a number in character string data (in the exponent format), "30H
(0)" is ignored during conversion.
- 1 . 3 5 0 3 4 E - 0 2
Ignored
-1.35034E-2
Float (single precision) data
8) When "20H (space)" is contained in character string, "20H (space)" is ignored during conversion.
9) Up to 24 characters can be input as string data.
Each of "20H (space)" and "30H (0)" contained in string is counted as 1 character respectively.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data and 32-bit data in structured programs, you cannot specify 16-bit devices
directly, different from simple projects. Use labels when handling string data and 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
114
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When any character other than "30H (0)" to "39H (9)" exists in the integer or decimal part
(Error code: K6706)
2
s
3) When any character other than "45H (E)", "2BH (+)" or "2DH (-)" exists in the exponent part, or when two
or more exponent parts exist
(Error code: K6706)
s
is "0" or any value larger than "24"
Program example
In this program, string data stored in a device specified in s is converted into float (single precision) data,
and the data obtained by conversion is output to a device specified in d .
[Structured ladder]
STR_TO_REAL
_STRING
4
How to Read
Explanation of
Functions
1) Function without EN/ENO(STR_TO_REAL)
g_string1
3
Function
Construction
4) When the number of characters after
(Error code: K6706)
Function List
2) When "2EH (.)" exists in two or more positions inside the character string specified in
(Error code: K6706)
Outline
Error
g_real1
5
Applied
Functions
[ST]
g_real1 := STR_TO_REAL(g_string1);
2) Function with EN/ENO(STR_TO_REAL_E)
6
[Structured ladder]
g_string1
STR_TO_REAL_E
EN
ENO
_STRING
Standard
Function Blocks
g_bool1
g_bool3
g_real1
[ST]
g_bool3 := STR_TO_REAL_E(g_bool1, g_string1, g_real1);
A
Correspondence
between Devices
and Addresses
115
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.40 STR_TO_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts string data into time data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
STR_TO_TIME
Structured ladder
Label 1
X000
STR_TO_TIME_E
Label 1
*1.
STR_TO_TIME
_STRING
*1
STR_TO_TIME_E
EN
ENO
_STRING
*1
ST
Label 2
Label 2
STR_TO_TIME(_STRING);
Example:
Label 2:=
STR_TO_TIME(Label 1);
STR_TO_TIME_E(EN,_STRING,
Output label);
Example:
STR_TO_TIME_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_STRING ( s )
Conversion source string data
String
Output
variable
ENO
Execution status
Bit
Time data after conversion
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts string data stored in a device specified in
obtained by conversion to a device specified in d .
'0'
0ms
'1234567'
20m34s567ms
String data
Time data
s
into time data, and outputs the data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling string data and 32-bit data in structured programs, you cannot specify 16-bit devices
directly, different from simple projects. Use labels when handling string data and 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
116
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When the sign data of numeric data specified in
(Error code: K6706)
s
is any other than "20H (space)" or "2DH (-)"
s
s
is any other than "30H (0)" to
is outside the following range:
3
In this program, string data stored in a device specified in s
obtained by conversion is output to a device specified in d .
is converted into time data, and the data
4
1) Function without EN/ENO(STR_TO_TIME)
How to Read
Explanation of
Functions
[Structured ladder]
STR_TO_TIME
_STRING
Function
Construction
Program example
g_string1
2
Function List
2) When the ASCII code for each digit of character string data specified in
"39H (9)", "20H (space)" or "00H (NULL)"
(Error code: K6706)
3) When the numeric value specified in
-2,147,483,648 to +2,147,483,647
(Error code: K6706)
Outline
Error
g_time1
5
[ST]
Applied
Functions
g_time1 := STR_TO_TIME(g_string1);
2) Function with EN/ENO(STR_TO_TIME_E)
[Structured ladder]
g_bool1
6
g_bool3
Standard
Function Blocks
g_string1
STR_TO_TIME_E
EN
ENO
_STRING
g_time1
[ST]
g_bool3 := STR_TO_TIME_E(g_bool1, g_string1, g_time1);
A
Correspondence
between Devices
and Addresses
117
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.41 BCD_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts BCD data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BCD_TO_INT
BCD_TO_INT
_BCD
*1
D0
D0
BCD_TO_INT(_BCD);
Example:
D10:=
BCD_TO_INT(D0);
D10
BCD_TO_INT_E
EN
ENO
_BCD
*1
X000
BCD_TO_INT_E
*1.
ST
BCD_TO_INT_E(EN,_BCD,
Output label);
Example:
BCD_TO_INT_E(X000,D0,D10);
D10
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_BCD ( s )
Conversion source BCD data
Word [unsigned]/
Bit String [16-bit]
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts BCD data stored in a device specified in
data obtained by conversion to a device specified in d .
9999H
9999
Word [unsigned]/
bit string [16-bit] data
Word [signed] data
8000 4000 2000 1000 800 400 200 100
9999H
1
0
0
1
1
0
0
1
Thousands place Hundreds place
0
0
1
0
0
1
1
1
into word [signed] data, and outputs the
80
40
20
10
8
4
2
1
1
0
0
1
1
0
0
1
Tens place
Ones place
Conversion into word [signed] data
3276516354 8192 4095 2048 1024 512 256 128
9999
s
0
64
32
16
8
4
2
1
0
0
0
1
1
1
1
Always becomes "0".
Cautions
Use the function having "_E" in its name to connect a bus.
Error
When the source data is not BCD (decimal number), M8067 (operation error) turns ON.
118
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this example, BCD data stored in a device specified in s
data obtained by conversion is output to a device specified in
is converted into word [signed] data, and the
.
d
1) Function without EN/ENO(BCD_TO_INT)
2
BCD_TO_INT
_BCD
Function List
[Structured ladder]
g_word1=16#1234
Outline
Program example
g_int1=1234
[ST]
3
g_int1 := BCD_TO_INT(g_word1);
Function
Construction
2) Function with EN/ENO(BCD_TO_INT_E)
[Structured ladder]
g_bool1
4
g_bool3
g_int1
How to Read
Explanation of
Functions
g_word1
BCD_TO_INT_E
EN
ENO
_BCD
[ST]
g_bool3 := BCD_TO_INT_E(g_bool1, g_word1, g_int1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
119
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.42 BCD_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts BCD data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
BCD_TO_DINT
Label 1
X000
BCD_TO_DINT_E
Label 1
*1.
BCD_TO_DINT
_BCD
*1
BCD_TO_DINT_E
EN
ENO
_BCD
*1
ST
Label 2
Label 2
BCD_TO_DINT(_BCD);
Example:
Label 2:=
BCD_TO_DINT(Label 1);
BCD_TO_DINT_E(EN,_BCD,
Output label);
Example:
BCD_TO_DINT_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_BCD ( s )
Conversion source BCD data
ANY_BIT
Output
variable
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
100
102
103
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] data
105
ANY_BIT data
106
99999999
107
99999999H
into double word [signed] data, and
101
This function converts BCD data stored in a device specified in s
outputs the data obtained by conversion to a device specified in d .
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 HundredTen- Thousands Hundreds Tens
place thousands thousands place
place
place
place
place
Conversion into DINT data
Ones
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
Tenmillions
place
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
Always becomes "0".
Cautions
Use the function having "_E" in its name to connect a bus.
Error
When the source data is not BCD (decimal number), M8067 (operation error) turns ON.
120
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this example, BCD data stored in a device specified in s is converted into double word [signed] data,
and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(BCD_TO_DINT)
2
BCD_TO_DINT
_BCD
Function List
[Structured ladder]
g_word1=16#0000
Outline
Program example
g_dint1=0
[ST]
3
g_dint1 := BCD_TO_DINT(g_word1);
Function
Construction
2) Function with EN/ENO(BCD_TO_DINT_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dint1
How to Read
Explanation of
Functions
g_word1
BCD_TO_DINT_E
EN
ENO
_BCD
[ST]
g_bool3 := BCD_TO_DINT_E(g_bool1, g_word1, g_dint1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
121
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.43 TIME_TO_BOOL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into bit data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
TIME_TO_BOOL
TIME_TO_BOOL_
E
Label
X000
Label
*1.
ST
TIME_TO_BOOL
_TIME
*1
M0
TIME_TO_BOOL_E
EN
ENO
_TIME
*1
M0
TIME_TO_BOOL(_TIME);
Example:
M0:=
TIME_TO_BOOL(Label);
TIME_TO_BOOL_E(EN,_TIME,
Output label);
Example:
TIME_TO_BOOL_E(X000, Label,
M0);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
Output
variable
ENO
Execution status
Bit
Bit data after conversion
Bit
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in
obtained by conversion to a device specified in d .
0ms
FALSE
20m34s567ms
TRUE
Time data
Bit data
s
into bit data, and outputs the data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
122
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in
by conversion is output to a device specified in d .
s
is converted into bit data, and the data obtained
1) Function without EN/ENO(TIME_TO_BOOL)
2
TIME_TO_BOOL
_TIME
Function List
[Structured ladder]
g_time1
Outline
Program example
g_bool1
[ST]
3
g_bool1 := TIME_TO_BOOL(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_BOOL_E)
[Structured ladder]
g_bool1
4
g_bool3
g_bool2
How to Read
Explanation of
Functions
g_time1
TIME_TO_BOOL_E
EN
ENO
_TIME
[ST]
g_bool3 := TIME_TO_BOOL_E(g_bool1, g_time1, g_bool2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
123
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.44 TIME_TO_INT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
Structured ladder
TIME_TO_INT
Label
X000
TIME_TO_INT_E
Label
*1.
ST
TIME_TO_INT
_TIME
*1
D10
TIME_TO_INT_E
EN
ENO
_TIME
*1
D10
TIME_TO_INT(_TIME);
Example:
D10:=
TIME_TO_INT(Label);
TIME_TO_INT_E(EN,_TIME,
Output label);
Example:
TIME_TO_INT_E(X000, Label,
D10);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
Output
variable
ENO
Execution status
Bit
Word [signed] data after conversion
Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in
data obtained by conversion to a device specified in d .
1s234ms
1234
Time data
Word [signed] data
s
into word [signed] data, and outputs the
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
124
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in s
data obtained by conversion is output to a device specified in
is converted into word [signed] data, and the
d .
1) Function without EN/ENO(TIME_TO_INT)
2
TIME_TO_INT
_TIME
Function List
[Structured ladder]
g_time1
Outline
Program example
g_int1
[ST]
3
g_int1 := TIME_TO_INT(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_INT_E)
[Structured ladder]
g_bool1
4
g_bool3
g_int1
How to Read
Explanation of
Functions
g_time1
TIME_TO_INT_E
EN
ENO
_TIME
[ST]
g_bool3 := TIME_TO_INT_E(g_bool1, g_time1, g_int1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
125
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.45 TIME_TO_DINT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
TIME_TO_DINT
TIME_TO_DINT_
E
Structured ladder
Label 1
X000
Label 1
*1.
TIME_TO_DINT
_TIME
*1
TIME_TO_DINT_E
EN
ENO
_TIME
*1
ST
Label 2
Label 2
TIME_TO_DINT(_TIME);
Example:
Label 2:=
TIME_TO_DINT(Label 1);
TIME_TO_DINT_E(EN,_TIME,
Output label);
Example:
TIME_TO_DINT_E(X000,Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
Output
variable
ENO
Execution status
Bit
Double word [signed] data after conversion
Double Word [signed]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in s
outputs the data obtained by conversion to a device specified in d .
20m34s567ms
1234567
Time data
Double word [signed] data
into double word [signed] data, and
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
126
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in s is converted into double word [signed] data, and
the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(TIME_TO_DINT)
2
TIME_TO_DINT
_TIME
Function List
[Structured ladder]
g_time1
Outline
Program example
g_dint1
[ST]
3
g_dint1 := TIME_TO_DINT(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_DINT_E)
[Structured ladder]
g_bool1
4
g_bool3
g_dint1
How to Read
Explanation of
Functions
g_time1
TIME_TO_DINT_E
EN
ENO
_TIME
[ST]
g_bool3 := TIME_TO_DINT_E(g_bool1, g_time1, g_dint1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
127
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.46 TIME_TO_STR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into string data, and outputs the data obtained by conversion.
1. Format
Expression in each language
Function name
TIME_TO_STR
Structured ladder
Label 1
X000
TIME_TO_STR_E
Label 1
*1.
TIME_TO_STR
_TIME
*1
TIME_TO_STR_E
EN
ENO
_TIME
*1
ST
TIME_TO_STR(_TIME);
Example:
Label 2 Label 2:=
TIME_TO_STR(Label 1);
Label 2
TIME_TO_STR_E(EN,_TIME,
Output label);
Example:
TIME_TO_STR_E(X000, Label 1,
Label 2);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
Output
variable
ENO
Execution status
Bit
String data after conversion
String
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in
obtained by conversion to a device specified in d .
20m34s567ms
"1234567"
Time data
String data
s
into string data, and outputs the data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Error
An operation error occurs in the following case. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When the number of points occupied by the device specified in
corresponding device.
128
d
exceeds the range of the
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in s
obtained by conversion is output to a device specified in d .
is converted into string data, and the data
1) Function without EN/ENO(TIME_TO_STR)
2
TIME_TO_STR
_TIME
Function List
[Structured ladder]
g_time1
Outline
Program example
g_string1
[ST]
3
g_string1 := TIME_TO_STR(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_STR_E)
[Structured ladder]
g_bool1
4
g_bool3
g_string1
How to Read
Explanation of
Functions
g_time1
TIME_TO_STR_E
EN
ENO
_TIME
[ST]
g_bool3 := TIME_TO_STR_E(g_bool1, g_time1, g_string1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
129
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.47 TIME_TO_WORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by
conversion.
1. Format
Expression in each language
Function name
Structured ladder
TIME_TO_WORD
TIME_TO_WORD
_E
Label
X000
Label
*1.
ST
TIME_TO_WORD
_TIME
*1
D10
TIME_TO_WORD_E
EN
ENO
_TIME
*1
D10
TIME_TO_WORD(_TIME);
Example:
D10:=
TIME_TO_WORD(Label);
TIME_TO_WORD_E(EN,_TIME,
Output label);
Example:
TIME_TO_WORD_E(X000, Label,
D10);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
EN
Data type
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
ENO
Execution status
Bit
Word [unsigned]/bit string [16-bit] data after conversion
Word [unsigned]/
Bit String [16-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in s into word [unsigned]/bit string [16-bit]
data, and outputs the data obtained by conversion to a device specified in d .
1s234ms
1234
Time data
Word [unsigned]/
bit string [16-bit] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
130
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in s is converted into word [unsigned]/bit string [16bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(TIME_TO_WORD)
2
TIME_TO_WORD
_TIME
Function List
[Structured ladder]
g_time1
Outline
Program example
g_word1
[ST]
3
g_word1 := TIME_TO_WORD(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_WORD_E)
[Structured ladder]
g_bool1
4
g_bool3
g_word1
How to Read
Explanation of
Functions
g_time1
TIME_TO_WORD_E
EN
ENO
_TIME
[ST]
g_bool3 := TIME_TO_WORD_E(g_bool1, g_time1, g_word1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
131
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5.1.48 TIME_TO_DWORD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function converts time data into double word [unsigned]/bit string [32-bit] data, and outputs the data
obtained by conversion.
1. Format
Expression in each language
Function name
TIME_TO_DWOR
D
TIME_TO_DWOR
D_E
Structured ladder
Label 1
X000
Label 1
*1.
ST
TIME_TO_DWORD
_TIME
*1
TIME_TO_DWORD(_TIME);
Example:
Label 2 Label 2:=
TIME_TO_DWORD(Label 1);
TIME_TO_DWORD_E
EN
ENO
_TIME
*1
TIME_TO_DWORD_E(EN,_TIME,
Output label);
Example:
Label 2 TIME_TO_DWORD_E(X000,
Label 1, Label 2);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
EN
Data type
Execution condition
Bit
_TIME ( s )
Conversion source time data
Time
ENO
Execution status
Bit
Double word [unsigned]/bit string [32-bit] data after conversion
Double Word [unsigned]/
Bit string [32-bit]
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts time data stored in a device specified in s into double word [unsigned]/bit string [32bit] data, and outputs the data obtained by conversion to a device specified in d .
12m34s567ms
1234567
Time data
Double word [unsigned]/
bit string [32-bit] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
132
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
In this program, time data stored in a device specified in s is converted into double word [unsigned]/bit
string [32-bit] data, and the data obtained by conversion is output to a device specified in d .
1) Function without EN/ENO(TIME_TO_DWORD)
2
TIME_TO_DWORD
_TIME
Function List
[Structured ladder]
g_time1
g_dword1
[ST]
3
g_dword1 := TIME_TO_DWORD(g_time1);
Function
Construction
2) Function with EN/ENO(TIME_TO_DWORD_E)
[Structured ladder]
g_bool1
4
g_bool3
How to Read
Explanation of
Functions
g_time1
TIME_TO_DWORD_E
EN
ENO
_TIME
Outline
Program example
g_dword1
[ST]
g_dword1 := TIME_TO_DWORD(g_time1);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
133
FXCPU Structured Programming Manual
(Application Functions)
5.2 Standard Functions Of One Numeric Variable
5.2
Standard Functions Of One Numeric Variable
5.2.1
ABS(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains the absolute value, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
ABS
ABS
D0
X000
ABS_E
D0
*1.
ST
_IN
*1
ABS_E
EN
ENO
_IN
*1
D10
ABS(_IN);
Example:
D10:=
ABS(D0);
ABS_E(EN,_IN,Output label);
Example:
ABS_E(X000,D0,D10);
D10
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
_IN ( s )
Data whose absolute value is to be obtained, or word device which
ANY_NUM
stores such data
ENO
Execution status
Bit
*1
Word device which will store the operation result
ANY_NUM
( d )
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function obtains the absolute value of word [signed]/double word [signed]/float (single precision) data
stored in a device specified in s , and outputs the operation result to a device specified in d using
the data type of data stored in devices specified in a device specified in s .
This function is expressed as follows when the input value is "A" and the output operation result is "B".
B= A
2) When the data type stored in a device specified in s is word [signed] and the stored data is "-32768",
this function outputs "-32768" to a device specified in d . (The maximum absolute value handled by this
function is "32,767".)
When the data type stored in a device specified in s is double word [signed] and the stored data is "2147483648", this function outputs "-2147483648" to a device specified in d . (The maximum absolute
value handled by this function is "2147483647".)
Cautions
Use the function having "_E" in its name to connect a bus.
134
FXCPU Structured Programming Manual
(Application Functions)
5.2 Standard Functions Of One Numeric Variable
1
In this program, the absolute value is obtained for word [signed] data stored in a device specified in s , and
the operation result is output to a device specified in d using the data type same as the data stored in a
device specified in s .
2
1) Function without EN/ENO(ABS)
Function List
[Structured ladder]
ABS
g_int1=-5923
g_int2=5923
_IN
Outline
Program example
3
[ST]
Function
Construction
g_int2 := ABS(g_int1);
2) Function with EN/ENO(ABS_E)
[Structured ladder]
EN
_IN
ENO
g_bool3
How to Read
Explanation of
Functions
g_int1
4
ABS_E
g_bool1
g_int2
[ST]
g_bool3 := ABS_E(g_bool1, g_int1, g_int2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
135
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
5.3
Standard Arithmetic Functions
5.3.1
ADD_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs addition using two values (A + B = C), and outputs the operation result.
1. Format
Expression in each language
Function name
Structured ladder
X000
ADD_E
*1.
D0
D10
ADD_E
EN
ENO
_IN
*1
_IN
ST
D20
ADD_E(EN,_IN,_IN,Output
label);
Example:
ADD_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Input
variable
EN
Output
variable
ENO
Description
…)
_IN ( s
*1
( d )
Data type
Execution condition
Bit
Data for addition or word device which stores such data
ANY_NUM
Execution status
Bit
Word device which will store the operation result
ANY_NUM
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function performs addition ( s1 + s2 ) using word [signed]/double word [signed]/float (single
precision) data stored in devices specified in s1 and s2 , and outputs the operation result to a device
specified in d using the data type of data stored in devices specified in s1 and s2 .
Example: When the data type is word [signed]
1234
s1 (Word
[signed] data)
136
+
5678
6912
s2 (Word
[signed] data)
d (Word
[signed] data)
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
1) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
Name
3
Description
M8021
Borrow
ON : When the operation result is less than "-32,768" (16-bit operation) or less than "2,147,483,648" (32-bit operation)
OFF: When the operation result is "-32,768" (16-bit operation) or more or "-2,147,483,648" (32bit operation) or more
Carry
ON : When the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit
operation)
OFF: When the operation result is "32,767" (16-bit operation) or less or "2,147,483,647" (32-bit
operation) or less
Zero flag
Zero flag
-2 , -1 , 0 ,
-1 , 0 , 1
-32,768
The most
significant bit
of data is "1".
The most
significant bit
of data is "0".
Zero flag
-2 , -1 , 0 ,
32,767 ,
5
0, 1, 2
Applied
Functions
Borrow flag
Zero flag
Carry flag
Zero flag
-1 , 0 , 1
-2,147,483,648
Zero flag
2,147,483,647 ,
6
0, 1, 2
Standard
Function Blocks
Borrow flag
Carry flag
Program example
In this program, addition is performed using double word [signed] data stored in devices specified in s1 and
s2 , and the operation result is output to a device specified in d .
ADD_E
g_bool1
EN
_IN
ENO
A
Correspondence
between Devices
and Addresses
[Structured ladder]
g_dint1
g_dint2
4
How to Read
Explanation of
Functions
Zero
Function
Construction
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
M8020
M8022
2
Function List
2) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
"TRUE" is output from ENO.
However, note that the obtained operation result is not accurate in this case.
Outline
Cautions
g_bool3
g_dint3
_IN
[ST]
g_bool3:=ADD_E(g_bool1,g_dint1,g_dint2,g_dint3);
137
FXCPU Structured Programming Manual
(Application Functions)
5.3.2
5.3 Standard Arithmetic Functions
SUB_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs subtraction using two values (A - B = C), and outputs the operation result.
1. Format
Expression in each language
Function name
Structured ladder
X000
SUB_E
*1.
D0
D10
SUB_E
EN
ENO
_IN1
*1
_IN2
ST
D20
SUB_E(EN,_IN1,_IN2,Output
label);
Example:
SUB_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Data to be subtracted or word device which stores such data
ANY_NUM
_IN2 ( s2 )
Data for subtraction or word device which stores such data
ANY_NUM
ENO
Execution status
Bit
Word device which will store the operation result
ANY_NUM
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function performs subtraction ( s1 - s2 ) using word [signed]/double word [signed]/float (single
precision) data stored in devices specified in s1 and s2 , and outputs the operation result to a device
specified in d using the data type of data stored in devices specified in s1 and s2 .
Example: When the data type is word [signed]
12345
s1 (Word
[signed] data)
138
-
6789
5556
s2 (Word
[signed] data)
d (Word
[signed] data)
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
1) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
Name
3
Description
M8021
Borrow
ON : When the operation result is less than "-32,768" (16-bit operation) or less than "2,147,483,648" (32-bit operation)
OFF: When the operation result is "-32,768" (16-bit operation) or more or "-2,147,483,648" (32bit operation) or more
Carry
ON : When the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit
operation)
OFF: When the operation result is "32,767" (16-bit operation) or less or "2,147,483,647" (32-bit
operation) or less
Zero flag
Zero flag
-2 , -1 , 0 ,
-1 , 0 , 1
-32,768
The most
significant bit
of data is "1".
The most
significant bit
of data is "0".
Zero flag
-2 , -1 , 0 ,
32,767 ,
5
0, 1, 2
Applied
Functions
Borrow flag
Zero flag
Carry flag
Zero flag
-1 , 0 , 1
-2,147,483,648
Zero flag
2,147,483,647 ,
6
0, 1, 2
Carry flag
Program example
In this program, subtraction is performed using word [signed] data stored in devices specified in s1 and
s2 , and the operation result is output to a device specified in d .
SUB_E
EN
_IN1
ENO
A
Correspondence
between Devices
and Addresses
[Structured ladder]
g_bool1
Standard
Function Blocks
Borrow flag
g_int1
g_int2
4
How to Read
Explanation of
Functions
Zero
Function
Construction
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
M8020
M8022
2
Function List
2) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
"TRUE" is output from ENO.
However, note that the obtained operation result is not accurate in this case.
Outline
Cautions
g_bool3
g_int3
_IN2
[ST]
g_bool3:=SUB_E(g_bool1,g_int1,g_int2,g_int3);
139
FXCPU Structured Programming Manual
(Application Functions)
5.3.3
5.3 Standard Arithmetic Functions
MUL_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs multiplication using two values (A × B = C), and outputs the operation result.
1. Format
Expression in each language
Function name
Structured ladder
X000
MUL_E
*1.
D0
D10
MUL_E
EN
ENO
*1
_IN
_IN
ST
D20
MUL_E(EN,_IN,_IN,Output
label);
Example:
MUL_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_IN ( s1 …)
Data for multiplication or word device which stores such data
ANY_NUM
Output
variable
ENO
Execution status
Bit
Word device which will store the operation result
ANY_NUM
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function performs multiplication ( s1 × s2 ) using word [signed]/double word [signed]/float (single
precision) data stored in devices specified in s1 and s2 , and outputs the operation result to a device
specified in d using the data type of data stored in devices specified in s1 and s2 .
Example: When the data type is word [signed]
100
15
1500
s1 (Word
[signed] data)
s2 (Word
[signed] data)
d (Word
[signed] data)
Cautions
1) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
"TRUE" is output from ENO.
However, note that the obtained operation result is not accurate in this case.
140
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
In this program, multiplication is performed using double word [signed] data stored in devices specified in
s1 and s2 , and the operation result is output to a device specified in d .
[Structured ladder]
EN
_IN
ENO
Function List
g_dint1
g_dint2
2
MUL_E
g_bool1
Outline
Program example
g_bool3
g_dint3
_IN
[ST]
3
g_bool3:=MUL_E(g_bool1,g_dint1,g_dint2,g_dint3);
Function
Construction
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
141
FXCPU Structured Programming Manual
(Application Functions)
5.3.4
5.3 Standard Arithmetic Functions
DIV_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs division using two values (A / B = C … remainder), and outputs the quotient.
1. Format
Expression in each language
Function name
Structured ladder
X000
DIV_E
*1.
D0
D10
DIV_E
EN
ENO
_IN1
*1
_IN2
ST
D20
DIV_E(EN,_IN1,_IN2,Output
label);
Example:
DIV_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
_IN1 ( s1 )
Data to be divided, or word device which stores such data
ANY_NUM
_IN2 ( s2 )
Data for division (divisor), or word device which stores such data
ANY_NUM
ENO
Execution status
Bit
Word device which will store the operation result
ANY_NUM
*1
( d )
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function performs division ( s1 / s2 ) using word [signed]/double word [signed]/float (single precision)
data stored in devices specified in s1 and s2 , and outputs the operation result to a device specified in
d using the data type of data stored in devices specified in s1 and s2 .
Example: When the data type is word [signed]
5
s1 (Word
[signed] data)
/
2
s2 (Word
[signed] data)
(Quotient)
2
d (Word
[signed] data)
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Error
1) An operation error occurs when the divisor stored in a device specified in s2 is "0", and the function is
not executed.
2) An operation error occurs when the operation result exceeds "32,767" (16-bit operation) or
"2,147,483,647" (32-bit operation).
142
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
In this program, division is performed using double word [signed] data stored in devices specified in s1 and
s2 , and the operation result is output to a device specified in d using the data type of data stored in
devices specified in s1 and s2 .
2
[Structured ladder]
Function List
DIV_E
g_bool1
g_dint1
g_dint2
Outline
Program example
EN
_IN1
ENO
g_bool3
g_dint3
_IN2
3
[ST]
Function
Construction
g_bool3:=DIV_E(g_bool1,g_dint1,g_dint2,g_dint3);
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
143
FXCPU Structured Programming Manual
(Application Functions)
5.3.5
5.3 Standard Arithmetic Functions
MOD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs division using two values (A / B = C … remainder), and outputs the remainder.
1. Format
Expression in each language
Function name
Structured ladder
MOD
Label 1
Label 2
X000
MOD_E
Label 1
Label 2
*1.
Output variable
*2.
Refer to the Cautions
MOD
_IN1
*1
_IN2
MOD_E
EN
ENO
_IN1
*1
_IN2
ST
_IN1 MOD _IN2; *2
Example:
Label 3:=
Label 1 MOD Label 2;
Label 3
MOD_E(EN,_IN1,_IN2,Output
label; *2
Example:
MOD_E(X000,Label 1,
Label 2,Label 3);
Label 3
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Data to be divided, or word device which stores such data
ANY_INT
_IN2 ( s2 )
Data for division (divisor), or word device which stores such data
ANY_INT
ENO
Execution status
Bit
*1
Word device which will store the operation result
ANY_INT
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function performs division ( s1 / s2 ) using word [signed]/double word [signed] data stored in devices
specified in s1 and s2 , and outputs the remainder to a device specified in d using the data type of
data stored in devices specified in s1 and s2 .
Example: When the data type is word [signed]
5
s1 (Word
[signed] data)
/
2
s2 (Word
[signed] data)
(Quotient)
2
Not output
(Remainder)
1
d (Word
[signed] data)
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) Note that the "MOD" description method is different from other function description methods in the ST
language.
144
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
1) An operation error occurs when the divisor stored in a device specified in s2 is "0", and the function is
not executed.
2) An operation error occurs when the operation result exceeds "32,767" (16-bit operation) or
"2,147,483,647" (32-bit operation).
2
In this program, division is performed using double word [signed] data stored in devices specified in s1 and
s2 , and the remainder is output to a device specified in d using the data type of data stored in devices
specified in s1 and s2 .
1) Function without EN/ENO(MOD)
3
Function
Construction
[Structured ladder]
MOD
g_dint3=742
_IN1
_IN2
4
How to Read
Explanation of
Functions
[ST]
g_dint3:=g_dint1 MOD g_dint2;
2) Function with EN/ENO(MOD_E)
5
[Structured ladder]]
Applied
Functions
MOD_E
g_bool1
g_dint1
g_dint2
Function List
Program example
g_dint1=5678
g_dint2=1234
Outline
Error
EN
_IN1
ENO
g_bool3
g_dint3
_IN2
6
[ST]
Standard
Function Blocks
g_bool3 := MOD_E(g_bool1, g_dint1, g_dint2, g_dint3);
A
Correspondence
between Devices
and Addresses
145
FXCPU Structured Programming Manual
(Application Functions)
5.3.6
5.3 Standard Arithmetic Functions
EXPT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains raised result, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
ST
EXPT
EXPT
EXPT_E
*1.
Label 1
D10
In1
In2
X000
EXPT_E
EN
ENO
In1
*1
In2
Label 1
D10
Label 2
*1
Label 2
EXPT(In1,In2);
Example:
Label 2:=
EXPT(Label 1,D10);
EXPT_E(EN,In1,In2,Output
label);
Example:
EXPT_E(X000,Label 1,D10,
Label 2);
Output variable
2. Set data
Variable
EN
Input
variable
In1
In2
Output
variable
Data type
Bit
( s1 )
Data to be raised, or word device which stores such data
FLOAT (Single Precision)
( s2 )
Power data, or word device which stores such data
ANY_NUM
ENO
*1
Description
Execution condition
( d )
Execution status
Bit
Word device which will store the operation result
FLOAT (Single Precision)
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function raises float (single precision) data stored in a device specified in s1 (to the power of the value
stored in a device specified in s2 ), and outputs the operation result to a device specified in d .
2
4.0
s1 Float (single
precision) data
Word
[signed] data
s2
16.0
d
Float (single
precision) data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
146
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When the value stored in a device specified in s1 is negative
(Error code: K6706)
2
Function List
2) When the value stored in a device specified in s1 is "0"
(Error code: K6706)
3) When the operation result is outside the following range:
(Error code: K6706)
2-126≤⏐Operation result⏐<2128
3
In this program, the value stored in a device specified in s1 is raised to the power of the value stored in a
device specified in s2 , and the operation result is output to a device specified in d using the data type of
data stored in a device specified in s1 .
4
1) Function without EN/ENO(EXPT)
How to Read
Explanation of
Functions
[Structured ladder]
EXPT
In1
Function
Construction
Program example
g_real1
g_int1
Outline
Error
g_real2
In2
5
[ST]
Applied
Functions
g_real2:=EXPT(g_real1,g_int1);
2) Function with EN/ENO(EXPT_E)
[Structured ladder]
g_real1
g_int1
EXPT_E
EN
ENO
In1
6
Standard
Function Blocks
g_bool1
g_bool3
g_real2
In2
[ST]
A
g_bool3:=EXPT_E(g_bool1,g_real1,g_int1,g_real2);
Correspondence
between Devices
and Addresses
147
FXCPU Structured Programming Manual
(Application Functions)
5.3.7
5.3 Standard Arithmetic Functions
MOVE(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function transfers data stored in a device to another device.
1. Format
Expression in each language
Function name
Structured ladder
MOVE
D0
X000
MOVE_E
D0
*1.
MOVE
_IN
*1
MOVE_E
EN
ENO
_IN
*1
ST
MOVE(_IN);
Example:
D10:=
MOVE(D0);
D10
MOVE_E(EN,_IN,Output label);
Example:
MOVE_E(X000,D0,D10);
D10
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_IN ( s )
Transfer source data, or word device which stores such data
ANY
Output
variable
ENO
Execution status
Bit
Transfer destination word device
ANY
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function transfers data stored in a device specified in
12
s
Word [signed] data
s
to a device specified in
d
.
12
d
Word [signed] data
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
148
FXCPU Structured Programming Manual
(Application Functions)
5.3 Standard Arithmetic Functions
1
In this program, word [signed] data stored in a device specified in
d .
s
is transferred to a device specified in
1) Function without EN/ENO(MOVE)
2
[Structured ladder]
Function List
MOVE
g_int1
g_int2
_IN
[ST]
3
g_int2:=MOVE(g_int1);
Function
Construction
2) Function with EN/ENO(MOVE_E)
[Structured ladder]
g_bool1
g_int1
EN
_IN
MOVE_E
ENO
Outline
Program example
g_bool3
4
g_int2
How to Read
Explanation of
Functions
[ST]
g_bool3:=MOVE_E(g_bool1,g_int1,g_int2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
149
FXCPU Structured Programming Manual
(Application Functions)
5.4 Standard Bit Shift Functions
5.4
Standard Bit Shift Functions
5.4.1
SHL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function shifts data of specified bit length leftward by the specified number of bits.
1. Format
Expression in each language
Function name
Structured ladder
ST
SHL(_IN,_N);
Example:
D10:=
SHL(D0,K1);
SHL
SHL
D0
K1
_IN
_N
SHL_E
EN
ENO
_IN
*1
_N
X000
SHL_E
*1.
*1
D0
K1
D10
SHL_E(EN,_IN,_N,Output label);
Example:
SHL_E(X000,D0,K1,D10);
D10
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
_IN ( s )
Word device which stores data to be shifted leftward
ANY_BIT
_N ( n )
Number of shifted bits
ANY_BIT
ENO
Execution status
Bit
Word device which will store data obtained by shift
ANY_BIT
*1
( d )
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function shifts word [unsigned]/bit string [16-bit]/double word [unsigned]/bit string [32-bit] data stored
in a device specified in s leftward by "n" bits, and outputs the obtained data to a device specified in
d using the data type of data stored in a device specified in s .
Data is shifted leftward by "n" bits specified in n .
Example: When word [unsigned]/bit string [16-bit] data is stored in a device specified in s , and "8" is
specified in n
270FH
F00H
s
(Word [unsigned]/
bit string [16-bit] data)
d (Word [unsigned]/
bit string [16-bit] data)
270FH
0
0
1
0
0
1
1
1
0
0
0
0
1
1
1
1
F00H
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
These bits become "0".
2) "n" bits from the least significant bit become "0".
150
FXCPU Structured Programming Manual
(Application Functions)
5.4 Standard Bit Shift Functions
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is shifted leftward
by "n" bits, and the obtained data is output to a device specified in d using the data type of data stored in a
device specified in s .
Function List
Program example
3
Function
Construction
1) Function without EN/ENO(SHL)
[Structured ladder]
SHL
g_word1=16#F30F
g_const_word1=16#0008
g_word2=16#0F00
_IN
4
_N
How to Read
Explanation of
Functions
[ST]
g_word2:=SHL(g_word1,g_const_word1);
2) Function with EN/ENO(SHL_E)
5
SHL_E
g_bool1
g_word1
g_const_word1
Applied
Functions
[Structured ladder]
EN
_IN
ENO
g_bool3
g_word2
_N
6
[ST]
Standard
Function Blocks
g_bool3:=SHL_E(g_bool1,g_word1,g_const_word1,g_word2);
A
Correspondence
between Devices
and Addresses
151
FXCPU Structured Programming Manual
(Application Functions)
5.4.2
5.4 Standard Bit Shift Functions
SHR(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function shifts data of specified bit length rightward by the specified number of bits.
1. Format
Expression in each language
Function name
Structured ladder
ST
SHR(_IN,_K);
Example:
D10:=
SHR(D0,K1);
SHR
SHR
D0
K1
_IN
_K
SHR_E
EN
ENO
_IN
*1
_N
X000
SHR_E
*1.
*1
D0
K1
D10
SHR_E(EN,_IN,_N,Output label);
Example:
SHR_E(X000,D0,K1,D10);
D10
Output variable
2. Set data
Variable
Description
EN
Input
variable
Output
variable
Data type
Execution condition
Bit
Word device which stores data to be shifted rightward
ANY_BIT
_K,_N ( n )
Number of shifted bits
ANY_BIT
ENO
Execution status
Bit
Word device which will store data obtained by shift
ANY_BIT
_IN
( s )
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function shifts word [unsigned]/bit string [16-bit]/double word [unsigned]/bit string [32-bit] data stored
in a device specified in s rightward by "n" bits, and outputs the obtained data to a device specified in
d using the data type of data stored in a device specified in s .
Data is shifted rightward by "n" bits specified in n .
Example: When word [unsigned]/bit string [16-bit] data is stored in a device specified in s , and "8" is
specified in n
270FH
27H
s (Word [unsigned]/
bit string [16-bit] data)
d (Word [unsigned]/
bit string [16-bit] data)
270FH
0
0
1
0
0
1
1
1
0
0
0
0
1
1
1
1
27H
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
These bits become "0".
2) "n" bits from the most significant bit become "0".
152
FXCPU Structured Programming Manual
(Application Functions)
5.4 Standard Bit Shift Functions
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is shifted rightward
by "n" bits, and the obtained data is output to a device specified in d using the data type of data stored in a
device specified in s .
Function List
Program example
3
Function
Construction
1) Function without EN/ENO(SHR)
[Structured ladder]
SHR
g_word1=16#EEEE
g_const_word1=16#0006
g_word2=16#03BB
_IN
4
_K
How to Read
Explanation of
Functions
[ST]
g_word2:=SHR(g_word1,g_const_word1);
2) Function with EN/ENO(SHR_E)
5
SHR_E
g_bool1
g_word1
g_const_word1
Applied
Functions
[Structured ladder]
EN
_IN
ENO
g_bool3
g_word2
_N
6
Standard
Function Blocks
[ST]
g_bool3:=SHR_E(g_bool1,g_word1,g_const_word1,g_word2);
A
Correspondence
between Devices
and Addresses
153
FXCPU Structured Programming Manual
(Application Functions)
5.5 Standard Bitwise Boolean Functions
5.5
Standard Bitwise Boolean Functions
5.5.1
AND_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains the logical product of two or more bits, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
X000
AND_E
*1.
M0
M10
ST
AND_E
EN
ENO
*1
_IN
_IN
AND_E(EN,_IN,_IN,Output
label);
Example:
AND_E(X000,M0,M10,M20);
M20
Output variable
2. Variable
Variable
Description
Data type
Input
variable
EN
_IN ( s1 …)
Device used to obtain the logical product
ANY_BIT
Output
variable
ENO
Execution status
Bit
Device which will store the operation result
ANY_BIT
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function obtains the logical product using each bit of bit/word [unsigned]/bit string [16-bit]/double
word [unsigned]/bit string [32-bit] data stored in devices specified in s1 and s2 , and outputs the
operation result to a device specified in d using the data type of data stored in devices specified in
s1 and s2 .
Example: When the data type is word [unsigned]/bit string [16-bit]
s1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
Logical product
s2
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
0
d
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
s
can be changed.
2) The number of pins in
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data. You can specify 32-bit counters directly, however,
because they are 32-bit devices.
Use global labels when specifying labels.
154
FXCPU Structured Programming Manual
(Application Functions)
5.5 Standard Bitwise Boolean Functions
1
In this program, the logical product is obtained using each bit of word [unsigned]/bit string [16-bit] data stored
in devices specified in s1 and s2 , and the operation result is output to a device specified in d using the
data type of data stored in devices specified in s1 and s2 .
2
[Structured ladder]
Function List
AND_E
g_bool1
g_word1=16#FF0F
g_word2=16#1234
Outline
Program example
EN
_IN
ENO
g_bool3
g_word3=16#1204
_IN
3
[ST]
Function
Construction
g_bool3:=AND_E(g_bool1,g_word1,g_word2,g_word3);
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
155
FXCPU Structured Programming Manual
(Application Functions)
5.5.2
5.5 Standard Bitwise Boolean Functions
OR_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains the logical sum of two or more bits, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
X000
OR_E
*1.
M0
M10
ST
OR_E(EN,_IN,_IN,Output label);
Example:
OR_E(X000,M0,M10,M20);
OR_E
EN
ENO
*1
_IN
_IN
M20
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s1 …)
Device used to obtain the logical sum
ANY_BIT
Output
variable
ENO
Execution status
Bit
Device which will store the operation result
ANY_BIT
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function obtains the logical sum using each bit of bit/word [unsigned]/bit string [16-bit]/double word
[unsigned]/bit string [32-bit] data stored in devices specified in s1 and s2 , and outputs the operation
result to a device specified in d using the data type of data stored in devices specified in s1 and
s2 .
Example: When the data type is word [unsigned]/bit string [16-bit]]
s1
1
1
0
0
1
1
1
1
0
0
0
0
1
1
1
1
Logical sum
s2
0
0
0
0
0
0
1
0
0
0
1
1
0
1
0
0
d
1
1
0
0
1
1
1
1
0
0
1
1
1
1
1
1
s
can be changed.
2) The number of pins in
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
156
FXCPU Structured Programming Manual
(Application Functions)
5.5 Standard Bitwise Boolean Functions
1
In this program, the logical sum is obtained using each bit of word [unsigned]/bit string [16-bit] data stored in
devices specified in s1 and s2 , and the operation result is output to a device specified in d using the
data type of data stored in devices specified in s1 and s2 .
2
[Structured ladder]
Function List
OR_E
g_bool1
g_word1=16#5F03
g_word2=16#9CCC
Outline
Program example
EN
_IN
ENO
g_bool3
g_word3=16#DFCF
_IN
3
[ST]
Function
Construction
g_bool3:=OR_E(g_bool1,g_word1,g_word2,g_word3);
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
157
FXCPU Structured Programming Manual
(Application Functions)
5.5.3
5.5 Standard Bitwise Boolean Functions
XOR_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains the exclusive logical sum of two or more bits, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
XOR_E
EN
ENO
*1
_IN
_IN
X000
XOR_E
*1.
ST
M0
M10
XOR_E(EN,_IN,_IN,Output
label);
Example:
XOR_E(X000,M0,M10,M20);
M20
Output variable
2. .Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s1 …)
Device used to obtain the exclusive logical sum
ANY_BIT
Output
variable
ENO
Execution status
Bit
Device which will store the operation result
ANY_BIT
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function obtains the exclusive logical sum using each bit of bit/word [unsigned]/bit string [16-bit]/
double word [unsigned]/bit string [32-bit] data stored in devices specified in s1 and s2 , and outputs
the operation result to a device specified in d using the data type of data stored in devices specified in
s1 and s2 .
Example: When the data type is word [unsigned]/bit string [16-bit]
s1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
Exclusive logical sum
s2
0
0
0
1
1
0
1
1
1
1
1
1
0
0
0
0
d
1
0
1
1
0
0
0
1
0
1
0
1
1
0
1
0
s
can be changed.
2) The number of pins in
158
FXCPU Structured Programming Manual
(Application Functions)
5.5 Standard Bitwise Boolean Functions
1
s1
s2
When the number
of "_IN" is 4
When the number
of "_IN" is 5
FALSE
TRUE
FALSE
TRUE
XOR
XOR
XOR
XOR
TRUE
TRUE
Result FALSE
s4
TRUE
Result TRUE
s5
3
TRUE
After that, the exclusive
logical sum is obtained
the required number of
Result FALSE times.
Function
Construction
Result TRUE
s3
2
Function List
When the number
of "_IN" is 3
Outline
3) If there are 3 or more s , the exclusive logical sum is obtained using the "exclusive logical sum of s1
and s2 " and s3 .
If there is s4 , the exclusive logical sum is obtained using the "exclusive logical sum of "exclusive logical
sum of s1 and s2 " and " s3 "" and s4 . In this way, the exclusive logical sum is obtained the
s6 …
required number of times for all input labels s5
Example: When the data type is bit
4
Cautions
5
Program example
[Structured ladder]
6
XOR_E
g_bool1
ENO
Standard
Function Blocks
EN
_IN
Applied
Functions
In this program, the exclusive logical sum is obtained using each bit of word [unsigned]/bit string [16-bit] data
stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d
using the data type of data stored in devices specified in s1 and s2 .
g_word1=16#AAAA
g_word2=16#1BF0
How to Read
Explanation of
Functions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
g_bool3
g_word3=16#B15A
_IN
[ST]
A
g_bool3:=XOR_E(g_bool1,g_word1,g_word2,g_word3);
Correspondence
between Devices
and Addresses
159
FXCPU Structured Programming Manual
(Application Functions)
5.5.4
5.5 Standard Bitwise Boolean Functions
NOT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function obtains the logical negation of bits, and outputs it.
1. Format
Expression in each language
Function name
Structured ladder
NOT
NOT
M0
X000
NOT_E
M0
*1.
ST
NOT(_IN);
Example:
M10:=
NOT(M0);
_IN
*1
M10
NOT_E(EN,_IN,Output label);
Example:
NOT_E(X000,M0,M10);
NOT_E
EN
ENO
*1
_IN
M10
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s )
Device used to obtain the logical negation
ANY_BIT
Output
variable
ENO
Execution status
Bit
Device which will store the operation result
ANY_BIT
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function obtains the logical negation using each bit of bit/word [unsigned]/bit string [16-bit]/double word
[unsigned]/bit string [32-bit] data stored in a device specified in s , and outputs the operation result to a
device specified in d using the data type of data stored in a device specified in s .
Example: When the data type is word [unsigned]/bit string [16-bit]
s
0
1
1
0
1
0
1
1
0
0
0
0
1
1
1
1
1
1
0
0
0
0
Logical negation
d
1
0
0
1
0
1
0
0
1
1
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
160
FXCPU Structured Programming Manual
(Application Functions)
5.5 Standard Bitwise Boolean Functions
1
In this program, the logical negation is obtained using each bit of word [unsigned]/bit string [16-bit] data stored
in a device specified in s , and the operation result is output to a device specified in d using the data
type of data stored in a device specified in s .
2
1) Function without EN/ENO(NOT)
Function List
[Structured ladder]
NOT
g_word1=16#AAAA
Outline
Program example
g_word2=16#5555
_IN
[ST]
3
Function
Construction
g_word2:= NOT(g_word1);
2) Function with EN/ENO(NOT_E)
[Structured ladder]
EN
_IN
ENO
g_bool3
How to Read
Explanation of
Functions
g_word1
4
NOT_E
g_bool1
g_word2
[ST]
g_bool3:=NOT_E(g_bool1,g_word1,g_word2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
161
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
5.6
Standard Selection Functions
5.6.1
SEL(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function selects either one between two data in accordance with the input condition, and outputs the
selection result.
1. Format
Expression in each language
Function name
Structured ladder
M0
D0
D10
SEL
X000
SEL_E
*1.
M0
D0
D10
SEL
_G
*1
_IN0
_IN1
SEL_E
EN
ENO
_G
*1
_IN0
_IN1
ST
D20
D20
SEL(_G,_IN0,_IN1);
Example:
D20:=
SEL(M0,D0,D10);
SEL_E(EN,_G,_IN0,_IN1,Output
label);
Example:
SEL_E(X000,M0,D0,D10,D20);
Output variable
2. Set data
Variable
Description
EN
Input
variable
Output
variable
Data type
Execution condition
Bit
Bit data used as the selection condition
Bit
_IN0 ( s2 )
Selectable data, or word device which stores such data
ANY
_IN1 ( s3 )
Selectable data, or word device which stores such data
ANY
ENO
Execution status
Bit
Word device which will store the selection result
ANY
_G
*1
( s1 )
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function outputs either one between the values stored in devices specified in s2 and s3 in
accordance with the value stored in a device specified in s1 to a device specified in d using the data
type of data stored in a device specified in s2 and s3 .
When the value stored in a device specified in s1 is "FALSE", this function outputs the value stored in a
device specified in s2 to a device specified in d .
When the value stored in a device specified in s1 is "TRUE", this function outputs the value stored in a
device specified in s3 to a device specified in d .
Example: When the data type of input variables s2 and s3 is word [signed]
FALSE
Bit data
1234
Word [signed] data
5678
Word [signed] data
162
SEL
G
_IN0
_IN1
1234
Word [signed] data
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
In this program, either one between the values stored in devices specified in s2 and s3 is output in
accordance with the value stored in a device specified in s1 to a device specified in d using the data
type of data stored in devices specified in s2 and s3 .
3
Function
Construction
1) Function without EN/ENO(SEL)
Function List
Program example
[Structured ladder]
SEL
g_bool1
g_word1
_G
g_word2
_IN1
g_word3
4
_IN0
How to Read
Explanation of
Functions
[ST]
g_word3:=SEL(g_bool1,g_word1,g_word2);
5
2) Function with EN/ENO(SEL_E)
Applied
Functions
[Structured ladder]
SEL_E
g_bool1
g_bool2
g_word1
ENO
g_bool3
g_word3
6
_IN0
_IN1
Standard
Function Blocks
g_word2
EN
_G
[ST]
g_bool3:=SEL_E(g_bool1,g_bool2,g_word1,g_word2,g_word3);
A
Correspondence
between Devices
and Addresses
163
FXCPU Structured Programming Manual
(Application Functions)
5.6.2
5.6 Standard Selection Functions
MAXIMUM(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function searches the maximum value among data, and outputs the maximum value.
1. Format
Expression in each language
Function name
Structured ladder
MAXIMUM
D0
D10
X000
MAXIMUM_E
*1.
D0
D10
MAXIMUM
_IN
*1
_IN
MAXIMUM_E
EN
ENO
_IN
*1
_IN
ST
D20
D20
MAXIMUM(_IN,_IN);
Example:
D20:=
MAXIMUM(D0,D10);
MAXIMUM_E(EN,_IN,_IN,Output
label);
Example:
MAXIMUM_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
Execution status
Bit
Word device which will store the maximum value
ANY_SIMPLE
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function outputs the maximum value among ANY_SIMPLE type data stored in devices specified in
s1 and s2 to a device specified in d using the data type of data stored in devices specified in s1
and s2 .
Example: When the data type is word [signed]
1234
Word [signed] data
5678
Word [signed] data
2) The number of pins in
MAXIMUM
_IN
_IN
s
5678
Word [signed] data
can be changed.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
164
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
1
In this program, the maximum value among word [signed] data stored in devices specified in s1 and s2 is
output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
1) Function without EN/ENO(MAXIMUM)
2
[Structured ladder]
Function List
MAXIMUM
g_int1=5678
g_int2=1234
_IN
Outline
Program example
g_int3=5678
_IN
[ST]
3
g_int3:=MAXIMUM(g_int1,g_int2);
Function
Construction
2) Function with EN/ENO(MAXIMUM_E)
[Structured ladder]
g_bool1
4
g_bool3
How to Read
Explanation of
Functions
g_int1
g_int2
MAXIMUM_E
EN
ENO
_IN
g_int3
_IN
[ST]
5
g_bool3:=MAXIMUM_E(g_bool1,g_int1,g_int2,g_int3);
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
165
FXCPU Structured Programming Manual
(Application Functions)
5.6.3
5.6 Standard Selection Functions
MINIMUM(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function searches the minimum value among data, and outputs the minimum value.
1. Format
Expression in each language
Function name
Structured ladder
MINIMUM
D0
D10
X000
MINIMUM_E
*1.
D0
D10
MINIMUM
_IN
*1
_IN
MINIMUM_E
EN
ENO
_IN
*1
_IN
ST
D20
D20
MINIMUM(_IN,_IN);
Example:
D20:=
MINIMUM(D0,D10);
MINIMUM_E(EN,_IN,_IN,Output
label);
Example:
MINIMUM_E(X000,D0,D10,D20);
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
Execution status
Bit
Word device which will store the minimum value
ANY_SIMPLE
*1
( d )
Execution condition
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function outputs the minimum value among ANY_SIMPLE type data stored in devices specified in
s1 and s2 to a device specified in d using the data type of data stored in devices specified in s1
and s2 .
Example: When the data type is word [signed]
1234
Word [signed] data
5678
Word [signed] data
2) The number of pins in
MINIMUM
1234
Word [signed] data
_IN
_IN
s
can be changed.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
166
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
1
In this program, the minimum value among word [signed] data stored in devices specified in s1 and s2 is
output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
1) Function without EN/ENO(MINIMUM)
2
[Structured ladder]
Function List
MINIMUM
g_int1=5678
g_int2=1234
_IN
Outline
Program example
g_int3=1234
_IN
[ST]
3
g_int3:=MINIMUM(g_int1,g_int2);
Function
Construction
2) Function with EN/ENO(MINIMUM_E)
[Structured ladder]
g_bool1
4
g_bool3
How to Read
Explanation of
Functions
g_int1
g_int2
MINIMUM_E
EN
ENO
_IN
g_int3
_IN
[ST]
5
g_bool3:=MINIMUM_E(g_bool1,g_int1,g_int2,g_int3);
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
167
FXCPU Structured Programming Manual
(Application Functions)
5.6.4
5.6 Standard Selection Functions
LIMITATION(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function judges whether data is located within the range between the upper limit value and the lower limit
value.
1. Format
Expression in each language
Function name
Structured ladder
D0
D10
D20
LIMITATION
X000
LIMITATION_E
*1.
D0
D10
D20
LIMITATION
_MN
*1
_IN
_MX
LIMITATION_E
EN
ENO
*1
_MN
_IN
_MX
ST
D30
D30
LIMITATION(_MN,_IN,_MX);
Example:
D30:=
LIMITATION(D0,D10,D20);
LIMITATION_E(EN,_MN,_IN,_MX,
Output label);
Example:
LIMITATION_E(X000,D0,D10,D20,
D30);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_MN ( s1 )
Lower limit data, or word device which stores such data
ANY_SIMPLE
_IN ( s2 )
Input data, or word device which stores such data
ANY_SIMPLE
_MX ( s3 )
Upper limit data, or word device which stores such data
ANY_SIMPLE
ENO
Execution status
Bit
Word device which will store the output data
ANY_SIMPLE
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function outputs data whose type is same as the data stored in devices specified in s1 , s2 and s3
to a device specified in d in accordance with ANY_SIMPLE type data stored in devices specified in s1 ,
s2 and s3 .
1) In the case of "Contents of a device specified in s2 > Contents of a device specified in
function outputs the contents of a device specified in s3 to a device specified in d .
s3
", this
2) In the case of "Contents of a device specified in s2 < Contents of a device specified in
function outputs the contents of a device specified in s1 to a device specified in d .
s1
", this
3) In the case of "Contents of a device specified in s1 ≤ Contents of a device specified in s2 ≤ Contents
of a device specified in s3 ", this function outputs the contents of a device specified in s2 to a device
specified in d .
Example: When the data type is word [signed]
Output value
-100
Word [signed] data
120
Word [signed] data
100
Word [signed] data
168
LIMITATION
_MN
_IN
_MX
Minimum input value
100
Word [signed] data
Input value
Maximum input value
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
1
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
An operation error occurs when this function is executed in the following setting status. The error flag M8067
turns ON, and D8067 stores the error code K6706.
Contents of a device specified in s1 > Contents of a device specified in s3
(Lower limit data)
(Upper limit data)
3
Error
In this program, data whose type is same as the data stored in devices specified in s1 , s2 and s3 is
output to a device specified in d in accordance with ANY_SIMPLE type data stored in devices specified in
s1 , s2 and s3 .
[Structured ladder]
g_int4=1300
5
_IN
_MX
Applied
Functions
g_int3=5000
LIMITATION
_MN
4
How to Read
Explanation of
Functions
1) Function without EN/ENO(LIMITATION)
g_int1=500
g_int2=1300
Function
Construction
Program example
Function List
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
[ST]
g_int4:=LIMITATION(g_int1,g_int2,g_int3);
6
2) Function with EN/ENO(LIMITATION_E)
Standard
Function Blocks
[Structured ladder]
g_bool1
g_bool3
g_int4
A
_IN
_MX
Correspondence
between Devices
and Addresses
g_int1
g_int2
g_int3
LIMITATION_E
EN
ENO
_MN
[ST]
g_bool3:=LIMITATION_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
169
FXCPU Structured Programming Manual
(Application Functions)
5.6.5
5.6 Standard Selection Functions
MUX(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function selects data, and outputs the selected data.
1. Format
Expression in each language
Function name
Structured ladder
ST
MUX(_K,_IN,_IN);
Example:
D30:=
MUX(D0,D10,D20);
MUX
D0
D10
D20
MUX
X000
MUX_E
*1.
D0
D10
D20
_K
_IN
_IN
*1
MUX_E
EN
ENO
_K
*1
_IN
_IN
D30
MUX_E(EN,_K,_IN,_IN,Output
label);
Example:
MUX_E(X000,D0,D10,D20,D30);
D30
Output variable
2. Set data
Variable
EN
Input
variable
Output
variable
_K
( n )
Description
Data type
Execution condition
Bit
Selection data, or word device which stores such data
Word [signed]
ANY
_IN ( s1 …)
Selectable data, or word device which stores such data
ENO
Execution status
Bit
*1
Word device which will store the selected data
ANY
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function outputs either one among values stored in devices specified in s1 … to a device specified
in d in accordance with the value specified in n using the data type of data stored in devices
specified in s1 ….
a) When the value specified in n is "1", this function outputs the value stored in a device specified in
s1 to a device specified in d .
b) When the value specified in n is "n", this function outputs the value stored in a device specified in
sn to a device specified in d .
Example: When the data type is word [signed]
1
Word [signed] data
MUX
K
_IN
_IN
1234
Word [signed] data
5678
Word [signed] data
1234
Word [signed] data
2) When a value input to n is outside the pin number range for s1 …, this function outputs an indefinite
value to a device specified in d .
(An operation error does not occur. "MUX_E" outputs "FALSE" from ENO.)
3) The number of pins in
170
s
can be changed.
FXCPU Structured Programming Manual
(Application Functions)
5.6 Standard Selection Functions
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
In this example, either one among values stored in devices specified in s1 … is output to a device specified
in d in accordance with the value specified in n using the data type of data stored in devices specified in
s1 ….
3
Function
Construction
1) Function without EN/ENO(MUL)
Function List
Program example
[Structured ladder]
MUX
g_int1=2
g_int2=1234
_K
g_int3=5678
_IN
g_int4=5678
4
_IN
How to Read
Explanation of
Functions
[ST]
g_int4:=MUX(g_int1,g_int2,g_int3);
5
2) Function with EN/ENO(MUL_E)
Applied
Functions
[Structured ladder]
MUX_E
g_bool1
ENO
g_bool3
g_int4
6
_IN
_IN
Standard
Function Blocks
g_int1
g_int2
g_int3
EN
_K
[ST]
g_bool3:=MUX_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
A
Correspondence
between Devices
and Addresses
171
FXCPU Structured Programming Manual
(Application Functions)
5.7 Standard Comparison Functions
5.7
Standard Comparison Functions
5.7.1
GT_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function compares data with regard to "> (larger)".
1. Format
Expression in each language
Function name
Structured ladder
X000
GT_E
*1.
D0
D10
EN
_IN
_IN
GT_E
ENO
*1
ST
GT_E(EN,_IN,_IN,Output label);
Example:
GT_E(X000,D0,D10,M0);
M0
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
*1
( d )
Execution status
Bit
Device which will store the comparison result
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function compares the contents of devices specified in s1 …, and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 > s2 ] & [ s2 > s3 ] & … & [ sn -1 > sn ].
a) This function outputs "TRUE" when all comparison results are " s (n-1) >
s
(n)".
b) This function outputs "FALSE" when any comparison result is " s (n-1) ≤
s
(n)".
2) The number of pins in
s
can be changed.
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects.
Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
172
FXCPU Structured Programming Manual
(Application Functions)
5.7 Standard Comparison Functions
1
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
2
g_int1
g_int2
EN
_IN
ENO
Function List
GT_E
g_bool1
Outline
Program example
g_bool3
g_bool2
_IN
3
[ST]
Function
Construction
g_bool3:=GT_E(g_bool1,g_int1,g_int2,g_bool2);
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
173
FXCPU Structured Programming Manual
(Application Functions)
5.7.2
5.7 Standard Comparison Functions
GE_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function compares data with regard to "≥ (larger or equal)".
1. Format
Expression in each language
Function name
Structured ladder
X000
GE_E
*1.
D0
D10
EN
_IN
_IN
GE_E
ENO
*1
ST
GE_E(EN,_IN,_IN,Output label);
Example:
GE_E(X000,D0,D10,M0);
M0
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
*1
( d )
Execution status
Bit
Device which will store the comparison result
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function compares the contents of devices specified in s1 …, and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 ≥ s2 ] & [ s2 ≥ s3 ] & … & [ sn -1 ≥ sn ].
a) This function outputs "TRUE" when all comparison results are " s (n-1) ≥
s
(n)".
b) This function outputs "FALSE" when any comparison result is " s (n-1) <
s
(n)".
2) The number of pins in
s
can be changed.
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Program example
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
GE_E
g_bool1
g_int1
g_int2
EN
_IN
ENO
g_bool3
g_bool2
_IN
[ST]
g_bool3:=GE_E(g_bool1,g_int1,g_int2,g_bool2);
174
FXCPU Structured Programming Manual
(Application Functions)
1
EQ_E
Outline
5.7.3
5.7 Standard Comparison Functions
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function compares data with regard to "= (equal)".
1. Format
Expression in each language
Function name
Structured ladder
EQ_E
*1.
D0
D10
EN
_IN
_IN
EQ_E
ENO
*1
Function
Construction
X000
3
ST
EQ_E(EN,_IN,_IN,Output label);
Example:
EQ_E(X000,D0,D10,M0);
M0
4
Output variable
Variable
Description
Data type
EN
Execution condition
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
Execution status
Bit
Device which will store the comparison result
Bit
*1
( d )
Bit
5
Applied
Functions
Input
variable
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
s
(n)".
b) This function outputs "FALSE" when any comparison result is " s (n-1) ≠
s
(n)".
s
A
can be changed.
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Program example
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
EQ_E
g_bool1
g_int1
g_int2
EN
_IN
ENO
g_bool3
g_bool2
_IN
[ST]
g_bool3:=EQ_E(g_bool1,g_int1,g_int2,g_bool2);
175
Correspondence
between Devices
and Addresses
2) The number of pins in
6
Standard
Function Blocks
1) This function compares the contents of devices specified in s1 …, and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 = s2 ] & [ s2 = s3 ] & … & [ sn -1 = sn ].
a) This function outputs "TRUE" when all comparison results are " s (n-1) =
How to Read
Explanation of
Functions
2. Set data
FXCPU Structured Programming Manual
(Application Functions)
5.7.4
5.7 Standard Comparison Functions
LE_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function compares data with regard to "≤ (smaller or equal)".
1. Format
Expression in each language
Function name
Structured ladder
X000
LE_E
*1.
D0
D10
EN
_IN
_IN
LE_E
ENO
*1
ST
LE_E(EN,_IN,_IN,Output label);
Example:
LE_E(X000,D0,D10,M0);
M0
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
Bit
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
*1
( d )
Execution status
Bit
Device which will store the comparison result
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function compares the contents of devices specified in s1 …, and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 ≤ s2 ] & [ s2 ≤ s3 ] & … & [ sn -1 ≤ sn ].
a) This function outputs "TRUE" when all comparison results are " s (n-1) ≤
s
(n)".
b) This function outputs "FALSE" when any comparison result is " s (n-1) >
s
(n)".
2) The number of pins in
s
can be changed.
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
176
FXCPU Structured Programming Manual
(Application Functions)
5.7 Standard Comparison Functions
1
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
2
g_int1
g_int2
EN
_IN
ENO
Function List
LE_E
g_bool1
Outline
Program example
g_bool3
g_bool2
_IN
3
[ST]
Function
Construction
g_bool3:=LE_E(g_bool1,g_int1,g_int2,g_bool2);
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
177
FXCPU Structured Programming Manual
(Application Functions)
5.7.5
5.7 Standard Comparison Functions
LT_E
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function compares data with regard to "< (smaller)".
1. Format
Expression in each language
Function name
Structured ladder
X000
LT_E
*1.
D0
D10
EN
_IN
_IN
LT_E
ENO
*1
ST
LT_E(EN,_IN,_IN,Output label);
Example:
LT_E(X000,D0,D10,M0);
M0
Output variable
2. Set data
Variable
Description
Data type
Input
variable
EN
Execution condition
_IN ( s1 …)
Compared data, or word device which stores such data
ANY_SIMPLE
Output
variable
ENO
Execution status
Bit
Device which will store the comparison result
Bit
*1
( d )
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function compares the contents of devices specified in s1 …, and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 < s2 ] & [ s2 < s3 ] & … & [ sn -1 < sn ].
a) This function outputs "TRUE" when all comparison results are " s (n-1) <
s
(n)".
b) This function outputs "FALSE" when any comparison result is " s (n-1) ≥
s
(n)".
2) The number of pins in
s
can be changed.
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Program example
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
LT_E
g_bool1
g_int1
g_int2
EN
_IN
ENO
g_bool3
g_bool2
_IN
[ST]
g_bool3:=LT_E(g_bool1,g_int1,g_int2,g_bool2);
178
FXCPU Structured Programming Manual
(Application Functions)
1
NE_E
Outline
5.7.6
5.7 Standard Comparison Functions
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function compares data with regard to "≠ (unequal)".
1. Format
Expression in each language
Function name
Structured ladder
NE_E
M0
4
Output variable
2. Set data
Variable
Input
variable
Data type
Execution condition
Bit
_IN1 ( s1 )
Compared data, or word device which stores such data
ANY_SIMPLE
_IN2 ( s2 )
Compared data, or word device which stores such data
ANY_SIMPLE
ENO
*1
( d )
Execution status
Bit
Device which will store the comparison result
Bit
5
Applied
Functions
Output
variable
Description
EN
How to Read
Explanation of
Functions
*1.
D0
D10
NE_E
EN
ENO
*1
_IN1
_IN2
Function
Construction
X000
3
ST
NE_E(EN,_IN1,_IN2,Output label);
Example:
NE_E(X000,D0,D10,M0);
In explanation of functions, I/O variables inside ( ) are described.
6
This function compares the contents of devices specified in s1 and s2 , and outputs the operation result
expressed as the bit type data to a device specified in d .
This function executes comparison [ s1 ≠ s2 ].
Standard
Function Blocks
Explanation of function and operation
A
a) This function outputs "TRUE" when in the case of " s1 ≠ s2 "
Cautions
When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from
simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when
specifying labels.
179
Correspondence
between Devices
and Addresses
b) This function outputs "FALSE" when in the case of " s1 = s2 "
FXCPU Structured Programming Manual
(Application Functions)
5.7 Standard Comparison Functions
Program example
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is
output to a device specified in d .
[Structured ladder]
NE_E
g_bool1
g_int1
g_int2
EN
_IN1
ENO
g_bool3
g_bool2
_IN2
[ST]
g_bool3:=NE_E(g_bool1,g_int1,g_int2,g_bool2);
180
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Standard Character String Functions
5.8.1
MID(_E)
FX3U(C)
FX3G
FX2N(C)
Outline
5.8
1
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Function List
Outline
This function obtains a character string from a specified position.
3
Function
Construction
1. Format
Expression in each language
Function name
Structured ladder
ST
MID
MID
_IN
_L
_P
X000
MID_E
EN
ENO
_IN
*1
_L
_P
Label 1
D10
D20
*1
Label 2
Label 2
4
MID_E(EN,_IN,_L ,_P,Output label);
Example:
MID_E(X000,Label 1,D10,D20,
Label 2);
5
Applied
Functions
Label 1
D10
D20
MID(_IN,_L ,_P);
Example:
Label 2:=
MID(Label 1,D10,D20);
How to Read
Explanation of
Functions
MID_E
*1.
2
Output variable
2. Set data
Variable
EN
_IN ( s )
Head word device which stores a character string
String
_L
( n1 )
Word device which stores the number of characters to be obtained
Word [signed]
_P
( n2 )
Word device which stores the head character position of a character
Word [signed]
string to be obtained
ENO
*1
( d )
Execution status
Bit
Head word device which will store the obtained character string
String
A
Correspondence
between Devices
and Addresses
Output
variable
6
Data type
Bit
Standard
Function Blocks
Input
variable
Description
Execution condition
In explanation of functions, I/O variables inside ( ) are described.
181
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Explanation of function and operation
1) This function extracts specified number of characters from an arbitrary position of a character string
stored in devices specified in s , and outputs the obtained data to devices specified in d . The value
specified in n1 specifies the number of characters to be extracted.
The value specified in n2 specifies the head character position of characters to be extracted.
Example: When "5" is specified in n1 and n2
"ABCDEF12345"
"EF123"
High-order byte Low-order byte
1st word
42H(B)
2nd word
44H(D)
43H(C)
3rd word
46H(F)
45H(E)
4th word
32H(2)
31H(1)
5th word
34H(4)
33H(3)
6th word
00H
35H(5)
41H(A)
High-order byte Low-order byte
Head character
position of a
character string to
be extracted n2
= 5th character
46H(F)
45H(E)
1st word
32H(2)
31H(1)
2nd word
00H
33H(3)
3rd word
Number of characters to
be extracted n1 = 5
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
3) When the number of characters to be extracted specified in n1 is "0", this function does not execute
processing.
4) When the number of characters to be extracted specified in n1 is "-1", this function outputs the final
character of a character string specified in s to devices specified in d .
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When "00H" is not set in the corresponding device range after the device specified in
(Error code: K6706)
s
2) When the head character position specified in n2 exceeds the number of characters of a character
string stored in devices specified in s
(Error code: K6706)
3) When the number of characters specified in n1 exceeds the range of devices specified in
(Error code: K6706)
d
4) When the number of devices after the device number specified in d is smaller than the number of
devices required for storing an extracted character string
(In this case, "00H" cannot be stored after all character strings and the final character.)
(Error code: K6706)
5) When the value specified in n2 is negative
(Error code: K6706)
6) When the value specified in n1 is "-2" or less
(Error code: K6706)
7) When the value specified in n1
devices specified in s
(Error code: K6706)
182
exceeds the number of characters of a character string stored in
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
In this program, specified number of characters are extracted from an arbitrary position of a character string
stored in devices specified in s , and the obtained data is output to devices specified in d .
Outline
Program example
1) Function without EN/ENO(MID)
2
[Structured ladder]
Function List
MID
g_string1="ABCDEF12345"
g_int1=5
g_int2=5
g_string2="EF123"
_IN
_L
_P
3
[ST]
Function
Construction
g_string2:=MID(g_string1,g_int1,g_int2);
2) Function with EN/ENO(MID_E)
[Structured ladder]
EN
_IN
ENO
How to Read
Explanation of
Functions
g_string1
g_int1
g_int2
4
MID_E
g_bool1
g_bool3
g_string2
_L
_P
5
[ST]
Applied
Functions
g_bool3:=MID_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
183
FXCPU Structured Programming Manual
(Application Functions)
5.8.2
5.8 Standard Character String Functions
CONCAT(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
Outline
This function connects character strings.
1. Format
Expression in each language
Function name
Structured ladder
ST
CONCAT
CONCAT
Label 1
Label 2
X000
CONCAT_E
*1.
Label 1
Label 2
_IN
_IN
*1
CONCAT_E
EN
ENO
_IN
*1
_IN
Label 3
Label 3
CONCAT(_IN,_IN);
Example:
Label 3:=
CONCAT(Label 1,Label 2);
CONCAT_E(EN,_IN,_IN,Output
label);
Example:
CONCAT_E(X000,Label 1,Label 2,
Label 3);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Execution condition
_IN ( s1 )
_IN ( s2 )
Head word device which stores the data (character string) to be
String
connected, or directly specified character string
ENO
Execution status
*1
Head word device which will store the connected data (character
String
string)
( d )
In explanation of functions, I/O variables inside ( ) are described.
184
Data type
EN
Bit
Bit
FX0(S)
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
"ABCDE123456"
"123456"
"ABCDE"
High-order byte Low-order byte
High-order byte Low-order byte
High-order byte Low-order byte
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)
0000H
3) For direct specification, up to 32 characters can be specified (input).
When word devices are specified in s1 and s2 , this restriction (up to 32 characters) is not applicable.
5
Applied
Functions
4) When both a character string stored in devices specified in s1 and a character string stored in devices
specified in s2 begin with "00H" (when character = 0), this function stores "0000H" in devices specified
in d .
4
How to Read
Explanation of
Functions
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
3
Function
Construction
1st word
4th word
2
Function List
1) This function connects a character string stored in devices specified in s2 after a character string
stored in devices specified in s1 , and outputs the character string obtained by connection to devices
specified in d .
When connecting a character string stored in devices specified in s2 , this function ignores "00H" which
indicates the end of a character string stored in devices specified in s1 .
After two character strings are connected, "00H" is automatically added at the end.
Outline
Explanation of function and operation
Cautions
1) Use the function having "_E" in its name to connect a bus.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
2) When devices which store character strings specified in s1 and s2 overlap device numbers specified
in d which will store the character string obtained by connection
(Error code: K6706)
3) When "00H" does not exist in the corresponding device range after devices specified in s1 and s2
(Error code: K6706)
185
A
Correspondence
between Devices
and Addresses
1) When the number of devices after the device number specified in d is smaller than the number of
devices required for storing the character string obtained by connection
(In this case, "00H" cannot be stored after all character strings and final character.)
(Error code: K6706)
6
Standard
Function Blocks
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Program example
In this program, a character string stored in devices specified in s2 is connected after a character string
stored in devices specified in s1 , and the character string obtained by connection is output to devices
specified in d .
1) Function without EN/ENO(CONCAT)
[Structured ladder]
CONCAT
g_string1="ABCDEF"
g_string2="12345"
g_string3="ABCDEF12345"
_IN
_IN
[ST]
g_string3:=CONCAT(g_string1,g_string2);
2) Function with EN/ENO(CONCAT_E)
[Structured ladder]
g_bool1
g_string1
g_string2
CONCAT_E
EN
ENO
_IN
g_bool3
g_string3
_IN
[ST]
g_bool3:=CONCAT_E(g_bool1,g_string1,g_string2,g_string3);
186
FXCPU Structured Programming Manual
(Application Functions)
1
INSERT(_E)
Outline
5.8.3
5.8 Standard Character String Functions
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function inserts a character string.
1. Format
Expression in each language
Function name
Structured ladder
*1.
_IN1
_IN2
_P
X000
INSERT_E
EN
ENO
_IN1
*1
_IN2
_P
Label 1
Label 2
D20
*1
Label 3
Label 3
INSERT_E(EN,_IN1,_IN2,_P,
Output label);
Example:
INSERT_E(X000,Label 1,Label 2,
D20,Label 3);
4
How to Read
Explanation of
Functions
INSERT_E
Label 1
Label 2
D20
Function
Construction
INSERT
INSERT
3
ST
INSERT(_IN1,_IN2,_P);
Example:
Label 3:=
INSERT(Label 1,Label 2,D20);
Output variable
5
Variable
Input
variable
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Head word device which stores a character string to get insertion
String
_IN2 ( s2 )
Head word device which stores a character string to be inserted
String
_P
Word device which stores a character position to get insertion
Word [signed]
ENO
Execution status
Bit
*1
Head word device which will store a character string obtained by
String
insertion
( n )
( d )
6
Standard
Function Blocks
Output
variable
Description
Applied
Functions
2. Set data
In explanation of functions, I/O variables inside ( ) are described.
A
Correspondence
between Devices
and Addresses
187
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Explanation of function and operation
1) This function inserts a character string stored in devices specified in s2 into an arbitrary position
(counted from the head) of a character string stored in devices specified in s1 , and outputs the
character string obtained by insertion to devices specified in d .
The value specified in n specifies the position from which the character string stored in devices
specified in s2 is inserted.
After inserting a character string stored in devices specified in s2 into a character string stored in
devices specified in s1 , this function ignores "00H" which indicates the end of a character string stored
in devices specified in s2 .
Example: When "4" is specified in n
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)
Insertion start
position 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
0000H
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When the number of devices after the device number specified in
devices required for storing the output data obtained by insertion
(Error code: K6706)
d
is smaller than the number of
2) When devices which store character strings specified in s1 and s2 overlap device numbers specified
in d which will store the character string obtained by connection
(Error code: K6706)
3) When "00H" does not exist in the corresponding device range after devices specified in s1 and s2
(Error code: K6706)
4) When the number of characters of a character string stored in devices specified in s2 is 32768 or more
(Error code: K6706)
5) When the value specified in
(Error code: K6706)
188
n
is negative
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
In this program, a character string stored in devices specified in s2 is inserted into an arbitrary position
(counted from the head) of a character string stored in devices specified in s1 , and the character string
obtained by insertion is output to devices specified in d .
2
1) Function without EN/ENO(INSERT)
Function List
[Structured ladder]
INSERT
g_string1="ABCDEF"
g_string2="12345"
g_int1=3
g_string3="AB12345CDEF"
_IN1
_IN2
3
_P
Function
Construction
[ST]
g_string3:=INSERT(g_string1,g_string2,g_int1);
2) Function with EN/ENO(INSERT_E)
4
g_string1
g_string2
g_int1
INSERT_E
EN
ENO
_IN1
How to Read
Explanation of
Functions
[Structured ladder]
g_bool1
Outline
Program example
g_bool3
g_string3
_IN2
5
_P
Applied
Functions
[ST]
g_bool3:=INSERT_E(g_bool1,g_string1,g_string2,g_int1,g_string3);
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
189
FXCPU Structured Programming Manual
(Application Functions)
5.8.4
5.8 Standard Character String Functions
DELETE(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function deletes a character string.
1. Format
Expression in each language
Function name
Structured ladder
ST
DELETE
DELETE
Label 1
D10
D20
_IN
_L
_P
X000
DELETE_E
EN
ENO
_IN
*1
_L
_P
DELETE_E
*1.
Label 1
D10
D20
*1
Label 2
Label 2
DELETE(_IN,_L ,_P);
Example:
Label 2:=
DELETE(Label 1,D10,D20);
DELETE_E(EN,_IN,_L ,_P,
Output label);
Example:
DELETE_E(X000, Label 1,
D10, D20, Label 2);
Output variable
2. Set data
Variable
Input
variable
Data type
Execution condition
Bit
_IN ( s )
Head word device which stores a character string to get deletion
String
_L
( n1 )
Number of characters to be deleted
Word [signed]
( n2 )
Head position to get deletion
Word [signed]
ENO
Execution status
Bit
*1
Head word device which will store a character string remaining after
String
deletion
_P
Output
variable
Description
EN
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function deletes specified number of characters from an arbitrary position of a character string stored
in devices specified in s , and outputs the character string remaining after deletion to devices specified
in d .
The value specified in n1 specifies the number of characters to be deleted.
The value specified in n2 specifies the position from which specified number of characters are deleted.
Example: When "5" is specified in n1 and n2
"ABCDEF12345"
"ABCD45"
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
46H(F)
45H(E)
4th word
32H(2)
31H(1)
5th word
34H(4)
33H(3)
6th word
00H
35H(5)
Deletion start
position n2
= 5th character
42H(B)
41H(A)
1st word
44H(D)
43H(C)
2nd word
35H(5)
34H(4)
3rd word
0000H
4th word
Number of characters
to be deleted n1 = 5
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
190
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
Outline
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
2
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
Function List
1) When "00H" does not exist in the corresponding device range after the device specified in
(Error code: K6706)
3
Error
s
is 32768 or more
4) When the value specified in n2 is negative
(Error code: K6706)
Program example
1) Function without EN/ENO(DELETE)
[Structured ladder]
6
g_int2="3"
Standard
Function Blocks
DELETE
g_string1="ABCDEF12345"
g_int1="4"
g_string2="AB12345"
_IN
_L
_P
[ST]
A
Correspondence
between Devices
and Addresses
g_string2:=DELETE(g_string1,g_int1,g_int2);
2) Function with EN/ENO(DELETE_E)
[Structured ladder]
g_bool1
g_string1
g_int1
g_int2
DELETE_E
EN
ENO
_IN
5
Applied
Functions
In this program, specified number of characters are deleted from an arbitrary position of a character string
stored in devices specified in s , and the character string remaining after deletion is output to devices
specified in d .
4
How to Read
Explanation of
Functions
3) When the number of devices after the device number specified in d is smaller than the number of
devices required for storing the character string remaining after deletion of specified number of
characters
(Error code: K6706)
Function
Construction
2) When the number of characters of a character string stored in devices specified in
(Error code: K6706)
s
g_bool3
g_string2
_L
_P
[ST]
g_bool3:=DELETE_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
191
FXCPU Structured Programming Manual
(Application Functions)
5.8.5
5.8 Standard Character String Functions
REPLACE(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function replaces a character string.
1. Format
Expression in each language
Function name
Structured ladder
Label 1
Label 2
D20
D30
REPLACE
X000
Label 1
Label 2
D20
D30
REPLACE_E
*1.
REPLACE
_IN1
*1
_IN2
_L
_P
REPLACE_E
EN
ENO
_IN1
*1
_IN2
_L
_P
ST
Label 3
Label 3
REPLACE(_IN1,_IN2,_L ,_P);
Example:
Label 3:=
REPLACE(Label 1,Label 2,
D20,D30);
REPLACE_E(EN,_IN1,_IN2,
_L ,_P,Output label);
Example:
REPLACE_E(X000,Label 1,
Label 2,D20,D30,Label 3);
Output variable
2. Set data
Variable
Input
variable
Bit
_IN1 ( s1 )
Head word device which stores a character string to be replaced
String
_IN2 ( s2 )
Head word device which stores a replacement character string
String
_L
( n1 )
Word device which stores the number of characters to be replaced
Word [signed]
( n2 )
Word device which stores the head character position to be
Word [signed]
replaced in a character string to be replaced
ENO
Execution status
*1
Head word device which will store a character string obtained by
String
replacement
( d )
In explanation of functions, I/O variables inside ( ) are described.
192
Data type
Execution condition
_P
Output
variable
Description
EN
Bit
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
Input value to s1
"ABCDEFGH123"
Output value
"ABCD1234523"
High-order byte Low-order byte
High-order byte Low-order byte
42H(B)
41H(A)
2nd word
44H(D)
43H(C)
Replacement start
position n2
= 5th character
3
42H(B)
41H(A)
1st word
44H(D)
43H(C)
2nd word
32H(2)
31H(1)
3rd word
34H(4)
33H(3)
4th word
46H(F)
45H(E)
4th word
48H(H)
47H(G)
5th word
32H(2)
31H(1)
32H(2)
35H(5)
5th word
6th word
00H
33H(3)
00H
33H(3)
6th word
Input value to s2
"123456"
4
How to Read
Explanation of
Functions
3rd word
Function
Construction
1st word
Number of characters
to be replaced n1 = 5
High-order byte Low-order byte
32H(2)
31H(1)
2nd word
34H(4)
33H(3)
3rd word
36H(6)
35H(5)
4th word
5
Applied
Functions
1st word
2
Function List
1) This function replaces specified number of characters from an arbitrary position of a character string
stored in devices specified in s1 with a character string stored in devices specified in s2 , and outputs
the character string obtained by replacement to devices specified in d .
The value specified in n1 specifies the number of characters to be replaced.
The value specified in n2 specifies the position from which specified number of characters are replaced.
Example: When "5" is specified in n1 and n2
Outline
Explanation of function and operation
0000H
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
4) When "-1" is specified in n1 , the number of characters of a character string stored in devices specified
in s2 is regarded as the value specified in n1 .
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
193
A
Correspondence
between Devices
and Addresses
Cautions
Standard
Function Blocks
3) When "n1+n2" exceeds the number of characters of a character string stored in devices specified in s1 ,
excessive characters are not output to devices specified in d .
6
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When "00H" does not exist in the corresponding device range after the devices specified in s1
and
s2
(Error code: K6706)
2) When the value specified in n1
devices specified in s2
(Error code: K6706)
exceeds the number of characters of a character string stored in
3) When the value specified in n2 is negative
(Error code: K6706)
4) When the value specified in n1 is "-2" or less
(Error code: K6706)
5) When the value specified in n2
devices specified in s1
(Error code: K6706)
exceeds the number of characters of a character string stored in
Program example
In this program, specified number of characters starting from an arbitrary position of a character string stored
in devices specified in s1 are replaced with a character string stored in devices specified in s2 , and the
character string obtained by replacement is output to devices specified in d .
1) Function without EN/ENO(REPLACE)
[Structured ladder]
REPLACE
g_string1="ABCDEFGH"
_IN1
g_string2="012345678"
g_int1=6
_IN2
g_int2=3
g_string3="AB012345"
_L
_P
[ST]
g_string3:=REPLACE(g_string1,g_string2,g_int1,g_int2);
2) Function with EN/ENO(REPLACE_E)
[Structured ladder]
g_bool1
g_string1
g_string2
REPLACE_E
EN
ENO
_IN1
g_bool3
g_string3
_IN2
g_int1
_L
g_int2
_P
[ST]
g_bool3:=REPLACE_E(g_bool1,g_string1,g_string2,g_int1,g_int2,g_string3);
194
FXCPU Structured Programming Manual
(Application Functions)
1
FIND(_E)
Outline
5.8.6
5.8 Standard Character String Functions
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function searches a character string.
1. Format
Expression in each language
Function name
Structured ladder
Label 1
Label 2
X000
*1.
Label 1
Label 2
FIND_E
EN
ENO
_IN1
*1
_IN2
D20
D20
FIND_E(EN,_IN1,_IN2,Output
label);
Example:
FIND_E(X000,Label 1,Label 2,
D20);
4
How to Read
Explanation of
Functions
FIND_E
FIND
_IN1
*1
_IN2
Function
Construction
FIND
3
ST
FIND(_IN1,_IN2);
Example:
D20:=
FIND(Label 1,Label 2);
Output variable
5
2. Set data
Input
variable
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Head word device which stores a character string to get search
String
_IN2 ( s2 )
Head word device which stores a character string to be searched
String
ENO
Execution status
Bit
Head word device which will store the search result
Word [signed]
*1
( d )
6
Standard
Function Blocks
Output
variable
Description
Applied
Functions
Variable
In explanation of functions, I/O variables inside ( ) are described.
A
Correspondence
between Devices
and Addresses
195
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
Explanation of function and operation
1) This function searches a character string stored in devices specified in s2 from the beginning of a
character string stored in devices specified in s1 , and outputs the search result to devices specified in
d .
This function outputs the head character position of the searched character string detected first as the
search result.
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first
in units of byte in the range starting from the specified device.
3) If a character string stored in devices specified in s2 cannot be detected in a character string stored in
devices specified in s1 , this function outputs "0".
Input value to s1
"ABCD1234567"
Output value
5
High-order byte Low-order byte
Word [signed]
1st word
42H(B)
41H(A)
2nd word
44H(D)
43H(C)
3rd word
32H(2)
31H(1)
4th word
34H(4)
33H(3)
5th word
36H(6)
35H(5)
6th word
00H
37H(7)
Input value to s2
"1234"
Search of
character string
High-order byte Low-order byte
1st word
32H(2)
31H(1)
2nd word
34H(4)
33H(3)
3rd word
0000H
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling character string data in structured programs, you cannot specify 16-bit devices directly,
different from simple projects. Use labels when handling character string data.
Use global labels when specifying labels.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When "00H (NULL)" does not exist in the corresponding device range specified in s1
(Error code: K6706)
2) When "00H (NULL)" does not exist in the corresponding device range specified in s2
(Error code: K6706)
196
FXCPU Structured Programming Manual
(Application Functions)
5.8 Standard Character String Functions
1
In this program, a character string stored in devices specified in s2 is searched from the beginning of a
character string stored in devices specified in s1 , and the search result is output to devices specified in
d .
2
1) Function without EN/ENO(FIND)
Function List
[Structured ladder]
FIND
g_string1="ABCDEFGHIJK"
_IN1
g_string2="EFGHIJK"
_IN2
Outline
Program example
g_int1=5
3
[ST]
Function
Construction
g_int1:=FIND(g_string1,g_string2);
2) Function with EN/ENO(FIND_E)
4
[Structured ladder]
g_string1
g_string2
EN
_IN1
ENO
How to Read
Explanation of
Functions
FIND_E
g_bool1
g_bool3
g_int1
_IN2
5
[ST]
Applied
Functions
g_bool3:=FIND_E(g_bool1,g_string1,g_string2,g_int1);
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
197
FXCPU Structured Programming Manual
(Application Functions)
5.9 Functions Of Time Data Types
5.9
Functions Of Time Data Types
5.9.1
ADD_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function adds time data.
1. Format
Expression in each language
Function name
Structured ladder
ADD_TIME
Label 1
Label 2
X000
ADD_TIME_E
*1.
Label 1
Label 2
ADD_TIME
_IN1
*1
_IN2
ADD_TIME_E
EN
ENO
_IN1
*1
_IN2
ST
Label 3
Label 3
ADD_TIME(_IN1,_IN2);
Example:
Label 3:=
ADD_TIME(Label 1,Label 2);
ADD_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
ADD_TIME_E(X000,Label 1,
Label 2,Label 3);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
_IN1 ( s1 )
Head word device which stores time data to get addition
Time
_IN2 ( s2 )
Head word device which stores addition time data
Time
ENO
Execution status
Bit
Head word device which will store the operation result
Time
*1
( d )
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function performs addition ( s1 + s2 ) of time data stored in devices specified in s1 and s2 , and
outputs the operation result expressed as time data to devices specified in d .
198
FXCPU Structured Programming Manual
(Application Functions)
5.9 Functions Of Time Data Types
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
M8020
Zero
M8021
Borrow
ON : When the operation result is less than "-32,768" (16-bit operation) or less than "2,147,483,648" (32-bit operation)
OFF: When the operation result is "-32,768" (16-bit operation) or more or "-2,147,483,648" (32bit operation) or more
Carry
ON : When the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit
operation)
OFF: When the operation result is "32,767" (16-bit operation) or less or "2,147,483,647" (32-bit
operation) or less
M8022
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
Zero flag
Zero flag
-1 , 0 , 1
-32,768
Borrow flag
The most
significant bit
of data is "1".
32,767 ,
The most
significant bit
of data is "0".
Zero flag
5
0, 1, 2
Carry flag
Zero flag
-1 , 0 , 1
-2,147,483,648
Borrow flag
Zero flag
2,147,483,647 ,
6
0, 1, 2
Standard
Function Blocks
-2 , -1 , 0 ,
Carry flag
Program example
1) Function without EN/ENO(ADD_TIME)
[Structured ladder]
ADD_TIME
_IN1
_IN2
g_time3
[ST]
g_time3:=ADD_TIME(g_time1,g_time2);
2) Function with EN/ENO(ADD_TIME_E)
[Structured ladder]
g_bool1
g_time1
g_time2
ADD_TIME_E
EN
ENO
_IN1
_IN2
g_bool3
g_time3
[ST]
g_bool3:=ADD_TIME_E(g_bool1,g_time1,g_time2,g_time3);
199
A
Correspondence
between Devices
and Addresses
In this program, addition ( s1 + s2 ) is performed using time data stored in devices specified in s1 and
s2 , and the operation result expressed as time data is output to devices specified in d .
g_time1
g_time2
4
Applied
Functions
-2 , -1 , 0 ,
Zero flag
3
How to Read
Explanation of
Functions
Name
Function
Construction
Device
Function List
3) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
However, note that the accurate operation result cannot be obtained in this case.
("ADD_TIME_E" outputs "TRUE" from ENO.)
FXCPU Structured Programming Manual
(Application Functions)
5.9.2
5.9 Functions Of Time Data Types
SUB_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs subtraction of time data.
1. Format
Expression in each language
Function name
Structured ladder
SUB_TIME
Label 1
Label 2
X000
SUB_TIME_E
*1.
Label 1
Label 2
SUB_TIME
_IN1
*1
_IN2
SUB_TIME_E
EN
ENO
_IN1
*1
_IN2
ST
Label 3
Label 3
SUB_TIME(_IN1,_IN2);
Example:
Label 3:=
SUB_TIME(Label 1,Label 2);
SUB_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
SUB_TIME_E(X000,Label 1,
Label 2,Label 3);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Head word device which stores time data to get subtraction
Time
_IN2 ( s2 )
Head word device which stores subtraction data
Time
ENO
Execution status
Bit
Head word device which will store the operation result
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function performs subtraction ( s1 - s2 ) of time data stored in devices specified in s1 and s2 , and
outputs the operation result expressed as time data to devices specified in d .
200
FXCPU Structured Programming Manual
(Application Functions)
5.9 Functions Of Time Data Types
1
1) Use the function having "_E" in its name to connect a bus.
Outline
Cautions
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
M8020
Zero
M8021
Borrow
ON : When the operation result is less than "-32,768" (16-bit operation) or less than "2,147,483,648" (32-bit operation)
OFF: When the operation result is "-32,768" (16-bit operation) or more or "-2,147,483,648" (32bit operation) or more
Carry
ON : When the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit
operation)
OFF: When the operation result is "32,767" (16-bit operation) or less or "2,147,483,647" (32-bit
operation) or less
M8022
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
Zero flag
Zero flag
The most
significant bit
of data is "1".
32,767 ,
The most
significant bit
of data is "0".
Zero flag
5
0, 1, 2
Carry flag
Zero flag
-1 , 0 , 1
-2,147,483,648
Borrow flag
Zero flag
2,147,483,647 ,
6
0, 1, 2
Standard
Function Blocks
-2 , -1 , 0 ,
Carry flag
Program example
1) Function without EN/ENO(SUB_TIME)
[Structured ladder]
SUB_TIME
_IN1
_IN2
g_time3
[ST]
g_time3:=SUB_TIME(g_time1,g_time2);
2) Function with EN/ENO(SUB_TIME_E)
[Structured ladder]
g_bool1
g_time1
g_time2
SUB_TIME_E
EN
ENO
_IN1
_IN2
g_bool3
g_time3
[ST]
g_bool3:=SUB_TIME_E(g_bool1,g_time1,g_time2,g_time3);
201
A
Correspondence
between Devices
and Addresses
In this program, subtraction ( s1 - s2 ) is performed using time data stored in devices specified in s1 and
s2 , and the operation result expressed as time data is output to devices specified in d .
g_time1
g_time2
4
Applied
Functions
-1 , 0 , 1
-2 , -1 , 0 , -32,768
Borrow flag
Zero flag
3
How to Read
Explanation of
Functions
Name
Function
Construction
Device
Function List
3) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
However, note that the accurate operation result cannot be obtained in this case.
("SUB_TIME_E" outputs "TRUE" from ENO.)
FXCPU Structured Programming Manual
(Application Functions)
5.9.3
5.9 Functions Of Time Data Types
MUL_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs multiplication of time data.
1. Format
Expression in each language
Function name
Structured ladder
MUL_TIME
Label 1
Label 2
X000
MUL_TIME_E
*1.
Label 1
Label 2
MUL_TIME
_IN1
*1
_IN2
MUL_TIME_E
EN
ENO
_IN1
*1
_IN2
ST
Label 3
Label 3
MUL_TIME(_IN1,_IN2);
Example:
Label 3:=
MUL_TIME(Label 1,Label 2);
MUL_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
MUL_TIME_E(X000,Label 1,
Label 2,Label 3);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Head word device which stores time data to get multiplication
Time
_IN2 ( s2 )
Multiplication data, or head word device which stores such data
ANY_NUM
ENO
Execution status
Bit
Head word device which will store the operation result
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function performs multiplication( s1 × s2 ) using time data stored in devices specified in s1 and
s2 , and outputs the operation result expressed as time data to devices specified in d .
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
However, note that the accurate operation result cannot be obtained in this case.
("MUL_TIME_E" outputs "TRUE" from ENO.)
202
FXCPU Structured Programming Manual
(Application Functions)
5.9 Functions Of Time Data Types
1
In this program, multiplication ( s1 × s2 ) is performed using time data stored in devices specified in s1
and s2 , and the operation result expressed as time data is output to devices specified in d .
1) Function without EN/ENO(MUL_TIME)
2
[Structured ladder]
MUL_TIME
_IN1
_IN2
Function List
g_time1
g_int1
g_time2
[ST]
3
g_time2:=MUL_TIME(g_time1,g_int1);
Function
Construction
2) Function with EN/ENO(MUL_TIME_E)
[Structured ladder]
g_bool1
4
g_bool3
g_time2
How to Read
Explanation of
Functions
g_time1
g_int1
MUL_TIME_E
EN
ENO
_IN1
_IN2
Outline
Program example
[ST]
g_bool3:=MUL_TIME_E(g_bool1,g_time1,g_int1,g_time2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
203
FXCPU Structured Programming Manual
(Application Functions)
5.9.4
5.9 Functions Of Time Data Types
DIV_TIME(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function performs division using time data.
1. Format
Expression in each language
Function name
Structured ladder
DIV_TIME
Label 1
Label 2
X000
DIV_TIME_E
*1.
Label 1
Label 2
DIV_TIME
_IN1
*1
_IN2
DIV_TIME_E
EN
ENO
_IN1
*1
_IN2
ST
Label 3
Label 3
DIV_TIME(_IN1,_IN2);
Example:
Label 3:=
DIV_TIME(Label 1,Label 2);
DIV_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
DIV_TIME_E(X000,Label 1,
Label 2,Label 3);
Output variable
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
EN
Execution condition
Bit
_IN1 ( s1 )
Head word device which stores time data to get division
Time
_IN2 ( s2 )
Division data, or head word device which stores such data
ANY_NUM
ENO
Execution status
Bit
Head word device which will store the operation result
Time
*1
( d )
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
1) This function performs division ( s1 / s2 ) using time data stored in devices specified in s1 and s2 ,
and outputs the operation result expressed as time data to devices specified in d .
2) The contents of devices specified in s2 are ANY_NUM type data except "0".
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
Error
1) An operation error occurs when the divisor stored in devices specified in s2 is "0", and the function is
not executed.
2) An operation error occurs when the operation result exceeds "2,147,483,647".
204
FXCPU Structured Programming Manual
(Application Functions)
5.9 Functions Of Time Data Types
1
In this program, division ( s1 / s2 ) is performed using time data stored in devices specified in s1 and
s2 , and the operation result expressed as time data is output to devices specified in d .
1) Function without EN/ENO(DIV_TIME)
2
[Structured ladder]
DIV_TIME
_IN1
_IN2
Function List
g_time1
g_int1
g_time2
[ST]
3
g_time2:=DIV_TIME(g_time1,g_int1);
Function
Construction
2) Function with EN/ENO(DIV_TIME_E)
[Structured ladder]
g_bool1
4
g_bool3
How to Read
Explanation of
Functions
g_time1
g_int1
DIV_TIME_E
EN
ENO
_IN1
_IN2
Outline
Program example
g_time2
[ST]
g_bool3:=DIV_TIME_E(g_bool1,g_time1,g_int1,g_time2);
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
205
FXCPU Structured Programming Manual
(Application Functions)
6.
6 Standard Function Blocks
6.1 R_TRIG(_E)
Standard Function Blocks
6.1
R_TRIG(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block detects the rising edge of a signal, and outputs pulse signal.
1. Format
Expression in each language
Function name
Structured ladder
ST
M10
R_TRIG(_CLK); *1
Example:
Instance name(_CLK:=M0);
M10:=Instance name.Q;
M10
R_TRIG_E(EN,_CLK); *1
Example:
Instance name(EN:=X000,
_CLK:=M0);
M10:=Instance name.Q;
Instance name
R_TRIG
M0
R_TRIG
_CLK
Q
Instance name
X000
R_TRIG_E
M0
*1.
R_TRIG_E
EN
ENO
_CLK
Q
Refer to caution points.
2. Set data
Variable
Input
variable
EN
Output
variable
ENO
_CLK
Q
Description
( s )
( d )
Data type
Execution condition
Bit
Input signal whose rising edge is to be detected
Bit
Execution status
Bit
Output signal
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function block sets to ON a device specified in d when a device specified in
keeps ON the device specified in d only for 1 operation cycle.
s
turns ON, and
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) Expression of function blocks in each language
*1.
Set the instance when using a function block.
Describe the instance name when programming a function block.
Error
1) When an output number is specified in d and the specified output number does not exist due to
indexing, M8316 (I/O inexistence error) turns ON.
(Applicable to the FX3U and FX3UC PLCs only)
2) When a device (M, T or C) other than I/O number is specified in d and the specified device number
does not exist due to indexing, an operation error (Error code: 6706) occurs.
206
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.1 R_TRIG(_E)
1
In this program, a device specified in d turns ON when the bit data stored in a device specified in
turns ON from OFF, and the device specified in d remains ON only for 1 operation cycle.
s
1) Function without EN/ENO(R_TRIG)
2
[Structured ladder]
Function List
R_TRIG_Instance
R_TRIG
_CLK
g_bool1
Q
g_bool2
[ST]
3
R_TRIG_Instance(_CLK:=g_bool1);g_bool2:=R_TRIG_Instance.Q;
Function
Construction
2) Function with EN/ENO(R_TRIG_E)
[Structured ladder]
X000
4
Y010
How to Read
Explanation of
Functions
g_bool1
R_TRIG_E_Instance
R_TRIG_E
EN
ENO
_CLK
Q
Outline
Program example
g_bool2
[ST]
R_TRIG_E_Instance(EN:=X000,_CLK:=g_bool1);Y010=R_TRIG_E_Instance.ENO;
g_bool2:=R_TRIG_E_Instance.Q;
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
207
FXCPU Structured Programming Manual
(Application Functions)
6.2
6 Standard Function Blocks
6.2 F_TRIG(_E)
F_TRIG(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block detects the falling edge of a signal, and outputs pulse signal.
1. Format
Expression in each language
Function name
Structured ladder
ST
M10
F_TRIG(_CLK); *1
Example:
Instance name(_CLK:=M0);
M10:=Instance name.Q;
M10
F_TRIG_E(EN,_CLK); *1
Example:
Instance name(EN:=X000,
_CLK:=M0);
M10:=Instance name.Q;
Instance name
F_TRIG
M0
F_TRIG
_CLK
Q
Instance name
X000
F_TRIG_E
M0
*1.
F_TRIG_E
EN
ENO
_CLK
Q
Refer to caution points.
2. Set data
Variable
Description
Data type
Input
variable
EN
Output
variable
ENO
Execution status
Bit
Q
Output signal
Bit
_CLK
( s )
( d )
Execution condition
Bit
Input signal whose falling edge is to be detected
Bit
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function block sets to ON a device specified in d when a device specified in
keeps ON the device specified in d only for 1 operation cycle.
s
turns OFF, and
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) Expression of function blocks in each language
*1.
Set the instance when using a function block.
Describe the instance name when programming a function block.
Error
1) When an output number is specified in d and the specified output number does not exist due to
indexing, M8316 (I/O inexistence error) turns ON.
(Applicable to the FX3U and FX3UC PLCs only)
2) When a device (M, T or C) other than I/O number is specified in d and the specified device number
does not exist due to indexing, an operation error (Error code: 6706) occurs.
208
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.2 F_TRIG(_E)
1
In this program, a device specified in d turns ON when the bit data stored in a device specified in
turns OFF from ON, and the device specified in d remains ON only for 1 operation cycle.
s
1) Function without EN/ENO(F_TRIG)
2
[Structured ladder]
Function List
F_TRIG_Instance
F_TRIG
_CLK
g_bool1
Q
g_bool2
[ST]
3
F_TRIG_Instance(_CLK:=g_bool1);g_bool2:=F_TRIG_Instance.Q;
Function
Construction
2) Function with EN/ENO(F_TRIG_E)
[Structured ladder]
X000
4
Y010
How to Read
Explanation of
Functions
g_bool1
F_TRIG_E_Instance
F_TRIG_E
EN
ENO
_CLK
Q
Outline
Program example
g_bool2
[ST]
F_TRIG_E_Instance(EN:=X000,_CLK:=g_bool1);Y010=F_TRIG_E_Instance;
g_bool2:=F_TRIG_E_Instance.Q;
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
209
FXCPU Structured Programming Manual
(Application Functions)
6.3
6 Standard Function Blocks
6.3 CTU(_E)
CTU(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block counts up the number of times of rising of a signal.
1. Format
Expression in each language
Function name
Structured ladder
ST
CTU(CU,RESET,PV); *1
Example:
Instance name(CU:=M0,
RESET=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
Instance name
CTU
M0
M10
D0
CTU
CU
Q
RESET CV
PV
M20
D10
Instance name
X000
CTU_E
*1.
M0
M10
D0
CTU_E
EN
ENO
CU
Q
RESET CV
PV
M20
D10
CTU_E(EN,CU,RESET,PV); *1
Example:
Instance name(EN=X000,
CU:=M0, RESET=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
Refer to caution points.
2. Set data
Variable
Description
EN
Input
variable
Bit
Count source signal
Bit
RESET ( s2 )
Reset input signal
Bit
PV
Counter set value
Word [signed]
CU
( s1 )
( n )
ENO
Output
variable
Data type
Execution condition
Execution status
Bit
Q
( d1 )
Count-up output signal
Bit
CV
( d2 )
Number of times of rising
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function block counts up (adds "1" to) the value stored in a device specified in d2 when a device
specified in s1 turns ON.
When the count value reaches a value specified in n , a device specified in d1 turns ON.
When a device specified in s2 turns ON, this function block turns OFF a device specified in d1 , and
resets the count value of a device specified in d2 .
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) Expression of function blocks in each language
*1.
210
Set the instance when using a function block.
Describe the instance name when programming a function block.
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.3 CTU(_E)
1
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is
counted, and the count value is output to a device specified in d2 .
1) Function without EN/ENO(CTU)
2
[Structured ladder]
Function List
CTU_Instance
CTU
g_bool1
CU
g_bool2
RESET
g_int1
Q
CV
Outline
Program example
g_bool3
g_int2
3
PV
Function
Construction
[ST]
CTU_Instance(CU:=g_bool1,RESET:=g_bool2,PV:=g_int1);
g_bool3:=CTU_Instance.Q;
g_int2:=CTU_Instance.CV;
4
2) Function with EN/ENO(CTU_E)
How to Read
Explanation of
Functions
[Structured ladder]
CTU_E_Instance
CTU_E
M10
g_bool2
g_int1
RESET
PV
ENO
Q
CV
M11
5
g_bool3
g_int2
Applied
Functions
g_bool1
EN
CU
[ST]
CTU_E_Instance(EN:=M10,CU:=g_bool1,RESET:=g_bool2,PV:=g_int1);
M11:=CTU_E_Instance.ENO;
g_bool3:=CTU_E_Instance.Q;
g_int2:=CTU_E_Instance.CV;
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
211
FXCPU Structured Programming Manual
(Application Functions)
6.4
6 Standard Function Blocks
6.4 CTD(_E)
CTD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block counts down the number of times of rising of a signal.
1. Format
Expression in each language
Function name
Structured ladder
ST
CTD(CD,LOAD,PV); *1
Example:
Instance name(CD:=M0,
LOAD=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
Instance name
CTD
M0
M10
D0
CTD
CD
Q
LOAD
CV
PV
M20
D10
Instance name
X000
CTD_E
*1.
M0
M10
D0
CTD_E
EN
ENO
CD
Q
LOAD
CV
PV
CTD_E(EN,CD,LOAD,PV); *1
Example:
Instance name(EN=X000,
CD:=M0, LOAD=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
M20
D10
Refer to caution points.
2. Set data
Variable
Description
EN
Input
variable
Output
variable
Data type
Execution condition
Bit
CD
( s1 )
Count source signal
Bit
LOAD
( s2 )
Reset input signal
Bit
PV
( n )
Counter set value
Word [signed]
ENO
Execution status
Bit
Q
( d1 )
Output signal (which turns ON when the current counter value
Bit
becomes "0" or less)
CV
( d2 )
Number of times of rising
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function block counts down (subtracts "1" from) the value stored in a device specified in d2 when a
device specified in s1 turns ON.
The value n specifies the initial value for subtraction.
This function block turns ON a device specified in d1 when the count value becomes "0".
When a device specified in s2 turns ON, this function block turns OFF a device specified in d1 , and sets
the initial value for subtraction specified in n to the count value of a device specified in d2 .
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) Expression of function blocks in each language
*1.
212
Set the instance when using a function block.
Describe the instance name when programming a function block.
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.4 CTD(_E)
1
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is
counted, and a device specified in d1 turns ON when the value stored in a device specified in d2
becomes "0".
2
1) Function without EN/ENO(CTD)
Function List
[Structured ladder]
CTD_Instance
CTD
g_bool1
CD
g_bool2
LOAD
g_int1
Outline
Program example
Q
CV
g_bool3
g_int2
3
PV
Function
Construction
[ST]
CTD_Instance(CD:=g_bool1,LOAD:=g_bool2,PV:=g_int1);
g_bool3:=CTD_Instance.Q;
g_int2:=CTD_Instance.CV;
4
How to Read
Explanation of
Functions
2) Function with EN/ENO(CTD_E)
[Structured ladder]
CTD_E_Instance
CTD_E
M10
g_bool2
g_int1
LOAD
PV
ENO
Q
CV
5
M11
g_bool3
Applied
Functions
g_bool1
EN
CD
g_int2
[ST]
CTD_E_Instance(EN:=M10,CD:=g_bool1,LOAD:=g_bool2,PV:=g_int1);
M11:=CTD_E_Instance.ENO;
g_bool3:=CTD_E_Instance.Q;
g_int2:=CTD_E_Instance.CV;
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
213
FXCPU Structured Programming Manual
(Application Functions)
6.5
6 Standard Function Blocks
6.5 CTUD(_E)
CTUD(_E)
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block counts up/down the number of times of rising of a signal.
1. Format
Expression in each language
Function name
Structured ladder
ST
CTUD(CU,CD,RESET,LOAD,PV);
*1
Example:
Instance name(CU:=M0,
CD:=M10,RESET:=M20,LOAD:=
M30,PV:=D0);
M40:=Instance name.QU;
M50:=Instance name.QD;
D10:=Instance name.CV;
Instance name
M0
M10
M20
M30
D0
CTUD
CTUD
CU
QU
CD
QD
RESET CV
LOAD
PV
M40
M50
D10
Instance name
X000
M0
M10
M20
M30
D0
CTUD_E
*1.
CTUD_E
EN
ENO
QU
CU
CD
QD
RESET CV
LOAD
PV
M40
M50
D10
CTUD_E(EN,CU,CD,RESET,LOA
D,PV); *1
Example:
Instance name(EN=X000,
CU:=M0,CD:=M10,RESET:=M20,
LOAD:=M30,PV:=D0);
M40:=Instance name.QU;
M50:=Instance name.QD;
D10:=Instance name.CV;
Refer to caution points.
2. Set data
Variable
Description
EN
Input
variable
Execution condition
CU
( s1 )
Count up signal
Bit
CD
( s2 )
Count down signal
Bit
RESET ( s3 )
Reset input signal
Bit
LOAD
( s4 )
Resetting signal
Bit
PV
( n )
Counter set value
Word [signed]
Execution status
Bit
( d1 )
Count-up output signal
Bit
QD
( d2 )
Output signal (which turns ON when the current counter value
Bit
becomes "0" or less)
CV
( d3 )
Count value data
ENO
Output
variable
Data type
Bit
QU
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function block counts up (adds "1" to) the value stored in a device specified in d3 when a device
specified in s1 turns ON.
This function block counts down (subtracts "1" from) the value stored in a device specified in d3 when a
device specified in s2 turns ON.
n specifies the maximum value of the counter.
When the value stored in a device specified in d3 reaches the maximum value n of the counter, a device
specified in d1 turns ON.
When the value stored in a device specified in d3 becomes "0", a device specified in d2 turns ON.
214
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.5 CTUD(_E)
1
2
Cautions
Function List
1) Use the function having "_E" in its name to connect a bus.
2) Expression of function blocks in each language
*1.
Outline
This function block resets the count value of a device specified in d3 when a device specified in s3 turns
ON.
This function block sets the value stored in n to a device specified in d3 when a device specified in s4
turns ON.
Set the instance when using a function block.
Describe the instance name when programming a function block.
3
Function
Construction
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
215
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.5 CTUD(_E)
Program example
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is
counted up (added by "1"). When the value stored in a device specified in d3 reaches the value specified in
n , a device specified in d1 turns ON.
At the same time, the number of times the bit data stored in a device specified in s2 turns ON from OFF is
counted down (subtracted by "1"). When the value stored in a device specified in d3 becomes "0", a device
specified in d2 turns ON.
1) Function without EN/ENO(CTUD)
[Structured ladder]
CTUD_Instance
CTUD
g_bool1
CU
QU
g_bool2
CD
QD
g_bool5
g_bool6
g_bool3
RESET
CV
g_int2
g_bool4
LOAD
g_int1
PV
[ST]
CTUD_Instance(CU:=g_bool1,CD:=g_bool2,RESET:=g_bool3,LOAD:=g_bool4,PV:=g_int1);
g_bool5:=CTUD_Instance.QU;
g_bool6:=CTUD_Instance.QD;
g_int2:=CTUD_Instance.CV;
2) Function with EN/ENO(CTUD_E)
[Structured ladder]
CTUD_E_Instance
CTUD_E
M0
g_bool1
EN
CU
g_bool2
g_bool3
g_bool4
g_int1
CD
RESET
LOAD
PV
ENO
QU
QD
CV
M10
g_bool5
g_bool6
g_int2
[ST]
CTUD_E_Instance(EN:=M0,CU:=g_bool1,CD:=g_bool2,RESET:=g_bool3,LOAD:=g_bool4,PV:=g_int1);
M10:=CTUD_E_Instance.ENO;
g_bool5:=CTUD_E_Instance.QU;
g_bool6:=CTUD_E_Instance.QD;
g_int2:=CTUD_E_Instance.CV;
216
FXCPU Structured Programming Manual
(Application Functions)
6.6 TP(_E)
1
TP(_E)
Outline
6.6
6 Standard Function Blocks
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function block keeps ON a signal for specified duration.
1. Format
Expression in each language
Function name
Structured ladder
TP
M0
Label 1
IN
PT
Q
ET
M10
Label 2
Instance name
M0
Label 1
*1.
EN
IN
PT
TP_E
ENO
Q
ET
M10
Label 2
4
TP_E(EN,IN,PT); *1
Example:
Instance name(EN:=X000,
IN:=M0,PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
How to Read
Explanation of
Functions
X000
TP_E
Function
Construction
Instance name
TP
3
ST
TP(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
5
Refer to caution points.
Applied
Functions
2. Set data
Variable
EN
Input
variable
Data type
Bit
ON start input signal
Bit
PT ( n )
ON duration data
Time
ENO
Execution status
Bit
Output signal
Bit
ON duration current value
Time
IN
Q
( s )
( d1 )
ET ( d2 )
6
Standard
Function Blocks
Output
variable
Description
Execution condition
In explanation of functions, I/O variables inside ( ) are described.
A
When a device specified in s turns ON, this function block turns ON a device specified in d1 , and keeps
it ON for duration specified in n .
The elapsed time while a device specified in d1 remains ON is set to a device specified in d2 .
A device specified in d1 turns OFF when the elapsed time reaches the set value.
Even if a device specified in d1 turns OFF, this function block does not reset the elapsed time. When a
device specified in s turns ON from OFF next time, this function block resets the elapsed time and turns
ON again a device specified in d1 .
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) Expression of function blocks in each language
*1.
Set the instance when using a function block.
Describe the instance name when programming a function block.
217
Correspondence
between Devices
and Addresses
Explanation of function and operation
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.6 TP(_E)
Program example
In this program, when bit data stored in a device specified in
specified in d1 turns ON and remains ON for 10 seconds.
1) Function without EN/ENO(TP)
[Structured ladder]
TP_Instance
TP
g_bool1
IN
PT
T#10s
Q
ET
g_bool2
g_time1
[ST]
TP_Instance(IN:=g_bool1,PT:=T#10s);
g_bool2:=TP_Instance.Q;
g_time1:=TP_Instance.ET;
2) Function with EN/ENO(TP_E)
[Structured ladder]
M0
g_bool1
T#10s
TP_E_Instance
TP_E
EN
ENO
IN
Q
M10
PT
g_time1
ET
g_bool2
[ST]
TP_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s);
M10:=TP_E_Instance.ENO;
g_bool2:=TP_E_Instance.Q;
g_time1:=TP_E_Instance.ET;
218
s
turns ON, bit data stored in a device
FXCPU Structured Programming Manual
(Application Functions)
6.7 TON(_E)
1
TON(_E)
Outline
6.7
6 Standard Function Blocks
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function block turns ON after specified time.
1. Format
Expression in each language
Function name
Structured ladder
TON
M0
Label 1
IN
PT
Q
ET
M10
Label 2
Instance name
M0
Label 1
*1.
TON_E
EN
ENO
Q
IN
PT
ET
M10
Label 2
4
TON_E(EN,IN,PT); *1
Example:
Instance name(EN:=X000,
IN:=M0,PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name.ET;
How to Read
Explanation of
Functions
X000
TON_E
Function
Construction
Instance name
TON
3
ST
TON(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
5
Refer to caution points.
Applied
Functions
2. Set data
Variable
EN
Input
variable
Data type
Bit
Input signal
Bit
PT ( n )
ON start time data
Time
ENO
Execution status
Bit
Output signal
Bit
ON start time current value
Time
IN
Q
( s )
( d1 )
ET ( d2 )
6
Standard
Function Blocks
Output
variable
Description
Execution condition
In explanation of functions, I/O variables inside ( ) are described.
A
When a device specified in s turns ON, this function block turns ON a device specified in d1 after the
time specified in n .
The delay elapsed time until a device specified in d1 turns ON is set to a device specified in d2 .
When a device specified in s turns OFF, this function block turns OFF a device specified in d1 and
resets the delay elapsed time.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) Expression of function blocks in each language
*1.
Set the instance when using a function block.
Describe the instance name when programming a function block.
219
Correspondence
between Devices
and Addresses
Explanation of function and operation
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.7 TON(_E)
Program example
In this program, when bit data stored in a device specified in
specified in d1 turns ON 10 seconds later.
1) Function without EN/ENO(TON)
[Structured ladder]
TON_Instance
TON
g_bool1
IN
PT
T#10s
Q
ET
g_bool2
g_time1
[ST]
TON_Instance(IN:=g_bool1,PT:=T#10s);
g_bool2:=TON_Instance.Q;
g_time1:=TON_Instance.ET;
2) Function with EN/ENO(TON_E)
[Structured ladder]
M0
g_bool1
T#10s
TON_E_Instance
TON_E
EN
ENO
IN
Q
M10
PT
g_time1
ET
g_bool2
[ST]
TON_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s);
M10:=TON_E_Instance.ENO;
g_bool2:=TON_E_Instance.Q;
g_time1:=TON_E_Instance.ET;
220
s
turns ON, bit data stored in a device
FXCPU Structured Programming Manual
(Application Functions)
6.8 TOF(_E)
1
TOF(_E)
Outline
6.8
6 Standard Function Blocks
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
When the input signal turns OFF, this function block turns OFF the output signal after the specified time.
1. Format
Expression in each language
Function name
Structured ladder
IN
PT
Q
ET
M10
Label 2
Instance name
M0
Label 1
*1.
TOF_E
EN
ENO
Q
IN
PT
ET
M10
Label 2
4
TON_F(EN,IN,PT); *1
Example:
Instance name(EN:=X000,
IN:=M0,PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name.ET;
How to Read
Explanation of
Functions
X000
TOF_E
TOF(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
Function
Construction
TOF
M0
Label 1
3
ST
Instance name
TOF
5
Refer to caution points.
Applied
Functions
2. Set data
Variable
EN
Input
variable
Data type
Bit
Bit
PT ( n )
OFF duration data
Time
ENO
Execution status
Bit
Output signal
Bit
OFF duration current value
Time
Q
( s )
( d1 )
ET ( d2 )
6
Standard
Function Blocks
Output
variable
Description
Execution condition
Input signal
IN
In explanation of functions, I/O variables inside ( ) are described.
A
When a device specified in s turns ON, this function block turns ON a device specified in d1 .
When a device specified in s turns OFF from ON, this function block turns OFF a device specified in d1
after the time specified in n .
The elapsed time until a device specified in d1 turns OFF is set to a device specified in d2 .
When a device specified in s turns ON again, this function block turns ON a device specified in d1 and
resets the elapsed time.
Cautions
1) Use the function having "_E" in its name to connect a bus.
2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
3) Expression of function blocks in each language
Set the instance when using a function block.
Describe the instance name when programming a function block.
221
Correspondence
between Devices
and Addresses
Explanation of function and operation
*1.
Function List
Outline
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.8 TOF(_E)
Program example
In this program, when bit data stored in a device specified in s turns ON, bit data stored in a device
specified in d1 turns ON. When bit data stored in a device specified in s turns OFF, bit data stored in a
device specified in d1 turns OFF 10 seconds later.
1) Function without EN/ENO(TOF)
[Structured ladder]
TOF_Instance
TOF
g_bool1
IN
PT
T#10s
Q
ET
g_bool2
g_time1
[ST]
TOF_Instance(IN:=g_bool1,PT:=T#10s);
g_bool2:=TOF_Instance.Q;
g_time1:=TOF_Instance.ET;
2) Function with EN/ENO(TOF_E)
[Structured ladder]
M0
g_bool1
T#10s
TOF_E_Instance
TOF_E
EN
ENO
IN
Q
M10
PT
g_time1
ET
g_bool2
[ST]
TOF_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s);
M10:=TOF_E_Instance.ENO;
g_bool2:=TOF_E_Instance.Q;
g_time1:=TOF_E_Instance.ET;
222
FXCPU Structured Programming Manual
(Application Functions)
6.9 COUNTER_FB_M
1
COUNTER_FB_M
Outline
6.9
6 Standard Function Blocks
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
This counter starts counting when the condition turns ON from OFF and generates an output when counting
up to the set value.
A counter initial value can be set.
1. Format
3
Structured ladder
Function
Construction
Expression in each language
Function name
ST
COUNTER_FB_M(Coil,Preset,
ValueIn); *1
Instance name
COUNTER_FB_M
Coil
ValueOut
Preset
Status
ValueIn
*1.
Example:
Instance name
(Coil:=X000,Preset:=D0,
ValueIn:=D10);
D20:=Instance name
ValueOut;
M0:=Instance name
Status;
4
How to Read
Explanation of
Functions
COUNTER_FB_M
5
Refer to "Cautions".
Applied
Functions
2. Set data
Variable
Input
variable
Description
Data type
Coil
Execution condition
Bit
Preset
Counter set value
Word [signed]
ValueIn
Counter initial value
Word [signed]
ValueOut
Counter current value
ANY16
Status
Counter output contact
Bit
6
Standard
Function Blocks
Output
variable
Function and operation explanation
[Structured ladder]
Instance name
COUNTER_FB_M
Coil
ValueOut
Preset
Status
ValueIn
timing chart
Var_M0
Var_D10 *1
Var_M10 *2
Value of Var_D10
[ ST ]
Instance name (Coil:= Var_M0,Preset:=10,Valueln:=1);
Var_D10:=Instance name.ValueOut;
Var_M10:=Instance name.Status;
*1.
Var_D10 is a global label and is defined as D10.
*2.
Var_M10 is a global label and is defined as M10.
Var_M10
1
ON
ON
2
3
ON
10
ON
223
A
Correspondence
between Devices
and Addresses
The counter starts counting when detecting the rising edge (from OFF to ON) of the input argument Coil. It
does not start counting if the Coil remains ON.
The counter starts counting from the value of input argument ValueIn. When the input argument Preset value
is reached, the output argument Status turns ON.
The current count value is stored in the output argument ValueOut.
Var_M0
10
1
Function List
Outline
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.9 COUNTER_FB_M
Cautions
1) Expression in each language of function block
*1.
Set the instance when using the function block.
Describe the instance name when programming the function block.
2) For the function block, the automatic allocation device needs to be set as the counter numbers are
allocated automatically.
224
FXCPU Structured Programming Manual
(Application Functions)
6.10 TIMER_10_FB_M
1
TIMER_10_FB_M
Outline
6.10
6 Standard Function Blocks
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
2
Function List
Outline
This function block generates an output when the condition continues for the specified time.
The initial value and setting value of the timer is multiplied by 10 ms.
1. Format
Function name
Instance name
TIMER_10_FB_M
Coil
ValueOut
Preset
Status
ValueIn
TIMER_10_FB_M(Coil,Preset,
ValueIn); *1
4
How to Read
Explanation of
Functions
*1.
ST
Function
Construction
TIMER_10_FB_M
3
Expression in each language
Structured ladder
Refer to "Cautions".
2. Set data
Variable
Output
variable
Data type
Execution condition
Bit
Preset
Timer set value
Word [signed]
ValueIn
Initial timer value
Word [signed]
ValueOut
Current timer value
ANY16
Status
Timer output contact
Bit
5
Applied
Functions
Input
variable
Description
Coil
6
Function and operation explanation
1) When the execution condition of the input argument Coil turns ON, counting the current value starts.
The timer starts counting from "ValueIn × 10 ms". When it counts up to "Preset × 10 ms", the output
argument Status turns ON.
The current measurement value is outputted into ValueOut.
Standard
Function Blocks
2) When the execution condition of the input argument Coil turns OFF, the current value takes on the value
of ValueIn and the output argument Status also turns OFF.
A
Correspondence
between Devices
and Addresses
[Structured ladder]
Instance name
TIMER_10_FB_M
ValueOut
Var_M0 Coil
Status
10 Preset
1 ValueIn
timing chart
ON
Var_M0
Var_D10 *1
Var_M10 *2
10
Value of Var_D10
1
90ms
[ ST ]
Instance name (Coil:= Var_M0,Preset:= 10,Valueln:= 1);
Var_D10:=Instance name.ValueOut;
Var_M10:= Instance name.Status;
*1.
Var_D10 is a global label and is defined as D10.
*2.
Var_M10 is a global label and is defined as M10.
Var_M10
ON
Cautions
1) Expression in each language of function block
*1.
Set the instance when using the function block.
Describe the instance name when programming the function block.
2) For the function block, the automatic allocation device needs to be set as the timer numbers are allocated
automatically.
225
FXCPU Structured Programming Manual
(Application Functions)
6.11
6 Standard Function Blocks
6.11 TIMER_CONT_FB_M
TIMER_CONT_FB_M
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block counts the period of time while the condition is satisfied, and generates an output when
the timer counts up the specified time.
1. Format
Function name
ST
Instance name
TIMER_CONT_FB_M
Coil
ValueOut
Preset
Status
ValueIn
TIMER_
CONT_FB_M
*1.
Expression in each language
Structured ladder
TIMER_CONT_FB_M(Coil,
Preset,ValueIn); *1
Refer to "Cautions".
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
Coil
Execution condition
Bit
Preset
Timer set value
Word [signed]
ValueIn
Initial timer value
Word [signed]
ValueOut
Current timer value
ANY16
Status
Timer output contact
Bit
Function and operation explanation
1) This is a retentive timer that counts the time when the variable is ON. It starts counting the current value
when the execution condition of the input argument Coil turns ON.
The timer starts counting from "ValueIn × 1 to 1000 ms". When it counts up to "Preset × 1 to 1000 ms",
the output argument Status turns ON.
The current measurement value is outputted into ValueOut.
2) The condition of measurement ValueOut and output argument ON/OFF status is maintained even if the
execution condition of the input argument Coil turns OFF.
When the execution condition of the input argument Coil turns ON, the timer resume counting from the
measurement it holds.
[Structured ladder]
Instance name
TIMER_CONT_FB_M
Var_M0 Coil
ValueOut
200 Preset
Status
0 ValueIn
timing chart
Var_M0
Var_D10 *1
Var_M10 *2
Value of Var_D10
0
1
ON
ON
15 sec
5 sec
-
150
151-200
[ ST ]
Instance name (Coil:= Var_M0,Preset:= 10,Valueln:= 1);
Var_D10:=Instance name.ValueOut;
Var_M10:=Instance name.Status;
226
*1.
Var_D10 is a global label and is defined as D10.
*2.
Var_M10 is a global label and is defined as M10.
Var_M10
ON
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.11 TIMER_CONT_FB_M
1
Outline
Cautions
1) Expression in each language of function block
*1.
Set the instance when using the function block.
Describe the instance name when programming the function block.
2
Function List
2) For the function block, the automatic allocation device needs to be set as the timer numbers are allocated
automatically.
3
Function
Construction
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
227
FXCPU Structured Programming Manual
(Application Functions)
6.12
6 Standard Function Blocks
6.12 TIMER_100_FB_M
TIMER_100_FB_M
FX3U(C)
FX3G
FX2N(C)
FX1N(C)
FX1S
FXU/FX2C
FX0N
FX0(S)
Outline
This function block generates an output when the condition continues for the specified time.
The initial value and setting value of the timer is multiplied by 100 ms.
1. Format
Function name
TIMER_100_FB_M
*1.
Expression in each language
Structured ladder
ST
Instance name
TIMER_100_FB_M
Coil
ValueOut
Preset
Status
ValueIn
TIMER_100_FB_M(Coil,
Preset,ValueIn); *1
Refer to "Cautions".
2. Set data
Variable
Input
variable
Output
variable
Description
Data type
Coil
Execution condition
Bit
Preset
Timer set value
Word [signed]
ValueIn
Initial timer value
Word [signed]
ValueOut
Current timer value
ANY16
Status
Timer output contact
Bit
Function and operation explanation
1) When the execution condition of the input argument Coil turns ON, counting the current value starts.
The timer starts counting from "ValueIn × 100 ms". When it counts up to "Preset × 100 ms", the output
argument Status turns ON.
The current measurement value is outputted into ValueOut.
2) When the execution condition of the input argument Coil turns OFF, the current value takes on the value
of ValueIn and the output argument Status also turns OFF.
[Structured ladder]
Var_M0
10
1
[ ST ]
Instance name
TIMER_100_FB_M
Coil
ValueOut
Status
Preset
ValueIn
timing chart
ON
Var_M0
Var_D10 *1
Var_M10 *2
10
Value of Var_D10
Instance name (Coil:= Var_M0,Preset:= 10,Valueln:= 1);
Var_D10:=Instance name.ValueOut;
Var_M10:=Instance name.Status;
*1.
Var_D10 is a global label and is defined as D10.
*2.
Var_M10 is a global label and is defined as M10.
1
Var_M10
900ms
ON
Cautions
1) Expression in each language of function block
*1.
Set the instance when using the function block.
Describe the instance name when programming the function block.
2) For the function block, the automatic allocation device needs to be set as the timer numbers are allocated
automatically.
228
FXCPU Structured Programming Manual
(Application Functions)
Appendix A: Correspondence between Devices and
1
Outline
Appendix A: Correspondence between Devices and
Addresses
2
Example of correspondence between device
and address
Notation
Device
Device
Address
Device
Address
X
Xn
%IXn
X367
%IX247
Output relay
Y
Yn
%QXn
Y367
%QX247
Timer
Auxiliary relay
M
Mn
%MX0.n
M499
%MX0.499
Contact
TS
Tn
%MX3.n
TS191
%MX3.191
Coil
TC
Tn
%MX5.n
TC191
%MX5.191
TN190
T190
%MW3.191
%MD3.190
Tn
Contact
CS
Cn
%MX4.n
CS99
%MX4.99
Coil
CC
Cn
%MX6.n
CC99
%MX6.99
CN
Cn
%MW4.n
%MD4.n
CN98
C98
%MW4.99
%MD4.98
Data register
D
Dn
%MW0.n
%MD0.n
D198*
D198
%MW0.199
%MD0.198
Intelligent function unit
device
G
Ux\Gn
%MW14.x.n
%MD14.x.n
U0\G09
U0\G09
%MW14.0.10
%MD14.0.9
Extension register
R
Rn
%MW2.n
%MD2.n
R32766
R32766
%MW2.32767
%MD2.32766
ER
ERn
No correspondence
Pointer
P
Pn
" "(NULL character)
Interrupt pointer
I
In
No correspondence
-
-
Nesting
N
Nn
No correspondence
-
-
Z
Zn
%MW7.n
%MD7.n
V
Vn
%MW6.n
V7
%MW6.7
S
Sn
%MX2.n
S4095
%MX2.4095
Counter
TN
State
P4095
Z6
Z6
No correspondence
6
Standard
Function Blocks
Index register
-
5
Applied
Functions
Extension file register
4
How to Read
Explanation of
Functions
Current value
%MW3.n
%MD3.n
Current value
3
Function
Construction
Input relay
Function List
The table below shows the correspondence between devices and addresses.
%MW7.7
%MD7.6
A
Correspondence
between Devices
and Addresses
229
FXCPU Structured Programming Manual
(Application Functions)
Warranty
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 on-site 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)
2)
230
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.
Even within the gratis warranty term, repairs shall be
charged for in the following cases.
a) Failure occurring from inappropriate storage or
handling, carelessness or negligence by the user.
Failure caused by the user's hardware or software
design.
b) Failure caused by unapproved modifications, etc.,
to the product by the user.
c) 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.
d) Failure that could have been avoided if
consumable parts (battery, backlight, fuse, etc.)
designated in the instruction manual had been
correctly serviced or replaced.
e) Relay failure or output contact failure caused by
usage beyond the specified Life of contact
(cycles).
f) 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.
g) Failure caused by reasons unpredictable by
scientific technology standards at time of
shipment from Mitsubishi.
h) 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 of damages caused by any
cause found not to be the responsibility of Mitsubishi, loss
in opportunity, lost profits incurred to the user or third
person 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.
6. Product application
1)
In using the Mitsubishi MELSEC programmable logic
controller, the usage conditions shall be that the
application will not lead to a major accident even if any
problem or fault should occur in the programmable logic
controller device, and that backup and fail-safe
functions are systematically provided outside of the
device for any problem or fault.
2)
The Mitsubishi programmable logic controller has
been designed and manufactured for applications in
general industries, etc. Thus, applications in which the
public could be affected such as in nuclear power
plants and other power plants operated by respective
power companies, and applications in which a special
quality assurance system is required, such as for
Railway companies or Public service purposes shall
be excluded from the programmable logic controller
applications.
In addition, applications in which human life or
property that could be greatly affected, such as in
aircraft, medical applications, incineration and fuel
devices, manned transportation, equipment for
recreation and amusement, and safety devices, shall
also be excluded from the programmable logic
controller range of applications.
However, in certain cases, some applications may be
possible, providing the user consults their local
Mitsubishi representative outlining the special
requirements of the project, and providing that all
parties concerned agree to the special circumstances,
solely at the users discretion.
FXCPU Structured Programming Manual
(Application Functions)
Revision History
Revision History
Date of preparation
Revision
Description
1/2009
A
First Edition.
7/2009
B
• Equivalent circuits are deleted.
• Following instructions are not supported in FX0,FX0S and FX0N PLCs.
CTD(_E), CTU(_E), CTUD(_E), TOF(_E), TON(_E), TP(_E)
• Function blocks (SR(_E), RS(_E)) are deleted.
231
FXCPU Structured Programming Manual
(Application Functions)
Revision History
MEMO
232
FXCPU
Structured Programming Manual [Application Functions]
HEAD OFFICE: TOKYO BUILDING, 2-7-3 MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
HIMEJI WORKS: 840, CHIYODA CHO, HIMEJI, JAPAN
MODEL
FX-KP-OK-E
MODEL CODE
09R927
JY997D34801B
(MEE)
Effective Jul. 2009
Specifications are subject to change without notice.
MITSUBISHI ELECTRIC
HEADQUARTERS
EUROPEAN REPRESENTATIVES
EUROPEAN REPRESENTATIVES
MITSUBISHI ELECTRIC EUROPE B.V.
EUROPE
German Branch
Gothaer Straße 8
D-40880 Ratingen
Phone: +49 (0)2102 / 486-0
Fax: +49 (0)2102 / 486-1120
MITSUBISHIELECTRICEUROPEB.V.-org.sl. CZECH REP.
Czech Branch
Avenir Business Park, Radlická 714/113a
CZ-158 00 Praha 5
Phone: +420 - 251 551 470
Fax: +420 - 251-551-471
MITSUBISHI ELECTRIC EUROPE B.V.
FRANCE
French Branch
25, Boulevard des Bouvets
F-92741 Nanterre Cedex
Phone: +33 (0)1 / 55 68 55 68
Fax: +33 (0)1 / 55 68 57 57
MITSUBISHI ELECTRIC EUROPE B.V.
IRELAND
Irish Branch
Westgate Business Park, Ballymount
IRL-Dublin 24
Phone: +353 (0)1 4198800
Fax: +353 (0)1 4198890
MITSUBISHI ELECTRIC EUROPE B.V.
ITALY
Italian Branch
Viale Colleoni 7
I-20041 Agrate Brianza (MB)
Phone: +39 039 / 60 53 1
Fax: +39 039 / 60 53 312
MITSUBISHI ELECTRIC EUROPE B.V.
POLAND
Poland Branch
Krakowska 50
PL-32-083 Balice
Phone: +48 (0)12 / 630 47 00
Fax: +48 (0)12 / 630 47 01
MITSUBISHI ELECTRIC EUROPE B.V.
RUSSIA
52, bld. 3 Kosmodamianskaya nab 8 floor
RU-115054 Мoscow
Phone: +7 495 721-2070
Fax: +7 495 721-2071
MITSUBISHI ELECTRIC EUROPE B.V.
SPAIN
Spanish Branch
Carretera de Rubí 76-80
E-08190 Sant Cugat del Vallés (Barcelona)
Phone: 902 131121 // +34 935653131
Fax: +34 935891579
MITSUBISHI ELECTRIC EUROPE B.V.
UK
UK Branch
Travellers Lane
UK-Hatfield, Herts. AL10 8XB
Phone: +44 (0)1707 / 27 61 00
Fax: +44 (0)1707 / 27 86 95
MITSUBISHI ELECTRIC CORPORATION
JAPAN
Office Tower “Z” 14 F
8-12,1 chome, Harumi Chuo-Ku
Tokyo 104-6212
Phone: +81 3 622 160 60
Fax: +81 3 622 160 75
MITSUBISHI ELECTRIC AUTOMATION, Inc.
USA
500 Corporate Woods Parkway
Vernon Hills, IL 60061
Phone: +1 847 478 21 00
Fax: +1 847 478 22 53
GEVA
AUSTRIA
Wiener Straße 89
AT-2500 Baden
Phone: +43 (0)2252 / 85 55 20
Fax: +43 (0)2252 / 488 60
TEHNIKON
BELARUS
Oktyabrskaya 16/5, Off. 703-711
BY-220030 Minsk
Phone: +375 (0)17 / 210 46 26
Fax: +375 (0)17 / 210 46 26
ESCO DRIVES & AUTOMATION
BELGIUM
Culliganlaan 3
BE-1831 Diegem
Phone: +32 (0)2 / 717 64 30
Fax: +32 (0)2 / 717 64 31
Koning & Hartman b.v.
BELGIUM
Woluwelaan 31
BE-1800 Vilvoorde
Phone: +32 (0)2 / 257 02 40
Fax: +32 (0)2 / 257 02 49
INEA BH d.o.o.
BOSNIA AND HERZEGOVINA
Aleja Lipa 56
BA-71000 Sarajevo
Phone: +387 (0)33 / 921 164
Fax: +387 (0)33/ 524 539
AKHNATON
BULGARIA
4 Andrej Ljapchev Blvd. Pb 21
BG-1756 Sofia
Phone: +359 (0)2 / 817 6044
Fax: +359 (0)2 / 97 44 06 1
INEA CR d.o.o.
CROATIA
Losinjska 4 a
HR-10000 Zagreb
Phone: +385 (0)1 / 36 940 - 01/ -02/ -03
Fax: +385 (0)1 / 36 940 - 03
AutoCont C.S. s.r.o.
CZECH REPUBLIC
Technologická 374/6
CZ-708 00 Ostrava-Pustkovec
Phone: +420 595 691 150
Fax: +420 595 691 199
Beijer Electronics A/S
DENMARK
Lykkegårdsvej 17
DK-4000 Roskilde
Phone: +45 (0)46/ 75 76 66
Fax: +45 (0)46 / 75 56 26
Beijer Electronics Eesti OÜ
ESTONIA
Pärnu mnt.160i
EE-11317 Tallinn
Phone: +372 (0)6 / 51 81 40
Fax: +372 (0)6 / 51 81 49
Beijer Electronics OY
FINLAND
Peltoie 37
FIN-28400 Ulvila
Phone: +358 (0)207 / 463 540
Fax: +358 (0)207 / 463 541
UTECO
GREECE
5, Mavrogenous Str.
GR-18542 Piraeus
Phone: +30 211 / 1206 900
Fax: +30 211 / 1206 999
MELTRADE Kft.
HUNGARY
Fertő utca 14.
HU-1107 Budapest
Phone: +36 (0)1 / 431-9726
Fax: +36 (0)1 / 431-9727
Beijer Electronics SIA
LATVIA
Ritausmas iela 23
LV-1058 Riga
Phone: +371 (0)784 / 2280
Fax: +371 (0)784 / 2281
Beijer Electronics UAB
LITHUANIA
Savanoriu Pr. 187
LT-02300 Vilnius
Phone: +370 (0)5 / 232 3101
Fax: +370 (0)5 / 232 2980
ALFATRADE Ltd.
MALTA
99, Paola Hill
Malta- Paola PLA 1702
Phone: +356 (0)21 / 697 816
Fax: +356 (0)21 / 697 817
INTEHSIS srl
MOLDOVA
bld. Traian 23/1
MD-2060 Kishinev
Phone: +373 (0)22 / 66 4242
Fax: +373 (0)22 / 66 4280
HIFLEX AUTOM.TECHNIEK B.V.
NETHERLANDS
Wolweverstraat 22
NL-2984 CD Ridderkerk
Phone: +31 (0)180 – 46 60 04
Fax: +31 (0)180 – 44 23 55
Koning & Hartman b.v.
NETHERLANDS
Haarlerbergweg 21-23
NL-1101 CH Amsterdam
Phone: +31 (0)20 / 587 76 00
Fax: +31 (0)20 / 587 76 05
Beijer Electronics AS
NORWAY
Postboks 487
NO-3002 Drammen
Phone: +47 (0)32 / 24 30 00
Fax: +47 (0)32 / 84 85 77
Fonseca S.A.
PORTUGAL
R. João Francisco do Casal 87/89
PT - 3801-997 Aveiro, Esgueira
Phone: +351 (0)234 / 303 900
Fax: +351 (0)234 / 303 910
Sirius Trading & Services srl
ROMANIA
Aleea Lacul Morii Nr. 3
RO-060841 Bucuresti, Sector 6
Phone: +40 (0)21 / 430 40 06
Fax: +40 (0)21 / 430 40 02
Craft Con. & Engineering d.o.o.
SERBIA
Bulevar Svetog Cara Konstantina 80-86
SER-18106 Nis
Phone:+381 (0)18 / 292-24-4/5
Fax: +381 (0)18 / 292-24-4/5
INEA SR d.o.o.
SERBIA
Izletnicka 10
SER-113000 Smederevo
Phone: +381 (0)26 / 617 163
Fax: +381 (0)26 / 617 163
SIMAP s.r.o.
SLOVAKIA
Jána Derku 1671
SK-911 01 Trencín
Phone: +421 (0)32 743 04 72
Fax: +421 (0)32 743 75 20
PROCONT, spol. s r.o. Prešov
SLOVAKIA
Kúpelná 1/A
SK-080 01 Prešov
Phone: +421 (0)51 7580 611
Fax: +421 (0)51 7580 650
INEA d.o.o.
SLOVENIA
Stegne 11
SI-1000 Ljubljana
Phone: +386 (0)1 / 513 8100
Fax: +386 (0)1 / 513 8170
Beijer Electronics AB
SWEDEN
Box 426
SE-20124 Malmö
Phone: +46 (0)40 / 35 86 00
Fax: +46 (0)40 / 93 23 01
Omni Ray AG
SWITZERLAND
Im Schörli 5
CH-8600 Dübendorf
Phone: +41 (0)44 / 802 28 80
Fax: +41 (0)44 / 802 28 28
GTS
TURKEY
Bayraktar Bulvari Nutuk Sok. No:5
TR-34775 Yukarı Dudullu-Ümraniye-İSTANBUL
Phone: +90 (0)216 526 39 90
Fax: +90 (0)216 526 3995
CSC Automation Ltd.
UKRAINE
4-B, M. Raskovoyi St.
UA-02660 Kiev
Phone: +380 (0)44 / 494 33 55
Fax: +380 (0)44 / 494-33-66
EURASIAN REPRESENTATIVES
Kazpromautomatics Ltd.
Mustafina Str. 7/2
KAZ-470046 Karaganda
Phone: +7 7212 / 50 11 50
Fax: +7 7212 / 50 11 50
KAZAKHSTAN
MIDDLE EAST REPRESENTATIVES
TEXEL ELECTRONICS Ltd.
ISRAEL
2 Ha´umanut, P.O.B. 6272
IL-42160 Netanya
Phone: +972 (0)9 / 863 39 80
Fax: +972 (0)9 / 885 24 30
CEG INTERNATIONAL
LEBANON
Cebaco Center/Block A Autostrade DORA
Lebanon - Beirut
Phone: +961 (0)1 / 240 430
Fax: +961 (0)1 / 240 438
AFRICAN REPRESENTATIVE
CBI Ltd.
Private Bag 2016
ZA-1600 Isando
Phone: + 27 (0)11 / 977 0770
Fax: + 27 (0)11 / 977 0761
SOUTH AFRICA
Mitsubishi Electric Europe B.V. /// FA - European Business Group /// Gothaer Straße 8 /// D-40880 Ratingen /// Germany
Tel.: +49(0)2102-4860 /// Fax: +49(0)2102-4861120 /// [email protected] /// www.mitsubishi-automation.com
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