Mitsubishi Electronics Mitsubishi Digital Electronics Welding System FXCPU Programming Manual
Add to my manuals
236 Pages
advertisement
FXCPU
Structured Programming Manual [Application Functions]
FXCPU Structured Programming Manual
(Application Functions)
FXCPU Structured Programming Manual
(Application Functions)
Manual number
Manual revision
Date
JY997D34801
B
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
4. How to Read Explanation of Functions 34
3
FXCPU Structured Programming Manual
(Application Functions) Table of Contents
4
FXCPU Structured Programming Manual
(Application Functions) Table of Contents
5
FXCPU Structured Programming Manual
(Application Functions) Table of Contents
6. Standard Function Blocks 206
Appendix A: Correspondence between Devices and Addresses 229
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 FX 3U /FX 3UC /FX 3G 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
FX
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
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 3U
FX 3UC
FX 3G
FX 3G /FX 3U /FX 3UC User's Manual- Analog Control Edition (Additional Manual)
This manual explains details of analog special function blocks and analog special adapters for FX
3U
/FX
3UC
/FX
3G
PLCs and PID instruction.
Explanation of instructions and instructions used in program examples are expressed for GX Developer.
FX
FX 3U
FX 3UC
FX 3G
FX Series User's Manual -Data Communication Edition (Additional Manual)
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.
FX 3G /FX 3U /FX 3UC Series User's Manual -Positioning Edition (Additional Manual)
This manual explains details of wiring, instructions and operations of the positioning function built in FX
3U
/FX
3UC
/FX
3G
PLC main units.
Explanation of instructions and instructions used in program examples are expressed for GX Developer.
Special unit/block
Individual manuals
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 FX 1S /FX 1N /FX U /FX 1NC /FX 2NC PLCs
Q/FX
QCPU/FXCPU Structured Programming Manual (Fundamentals) (Additional Manual)
This manual explains programming methods, specifications, functions, etc. required to create structured programs.
Structured
FX
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
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
Special unit/block
FX Series User's Manual -Data Communication Edition (Additional Manual)
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
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 FX 0 /FX 0S /FX 0N /FX U /FX 2C PLCs
Q/FX
QCPU/FXCPU Structured Programming Manual (Fundamentals) (Additional Manual)
This manual explains programming methods, specifications, functions, etc. required to create structured programs.
Structured
FX
FXCPU Structured Programming Manual (Device & Common) (Additional Manual)
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
FX Series User's Manual -Data Communication Edition (Additional Manual)
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.
Special unit/block
Individual manuals
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
QCPU/FXCPU Structured
Programming Manual (Fundamentals)
FXCPU Structured Programming
Manual (Device & Common)
FXCPU Structured Programming
Manual (Basic & Applied Instruction)
FXCPU Structured Programming
Manual (Application Functions)
Manual number
Supplied with product or Additional Manual
SH-080782
JY997D26001
JY997D34701
JY997D34801
Additional Manual
Additional Manual
Additional Manual
Additional Manual
Contents
Programming methods, specifications, functions, etc. required to create structured programs
Devices, parameters, etc. provided in structured projects of GX Works2
Sequence instructions provided in structured projects of GX Works2
Application functions provided in structured projects of GX Works2
Model name code
13JW06
09R920
09R921
09R922
FX 3U /FX 3UC /FX 3G PLCs
Manual name
PLC main unit
Manual number
Supplied with product or Additional Manual
Contents
FX
FX
FX
FX
FX
FX
3U
3U
3G
Series Hardware Manual
Series User's Manual- Hardware
Edition
3UC
3UC
3UC
(D, DSS) Series Hardware
Manual
-32MT-LT-2 Hardware Manual
Series User's Manual -
Hardware Edition
Series Hardware Manual
FX 3G Series User's Manual- Hardware
Edition
JY997D18801 Supplied with product
JY997D16501
JY997D31301
Additional Manual
JY997D28601 Supplied with product
JY997D31601 Supplied with product
JY997D28701 Additional Manual
JY997D33401 Supplied with product
Additional Manual
I/O specifications, wiring and installation of the
PLC main unit FX 3U extracted from the FX 3U
Series User’s Manual - Hardware Edition. For detailed explanation, refer to the FX 3U Series
User’s Manual - Hardware Edition.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 3U PLC main unit.
I/O specifications, wiring and installation of the
PLC main unit FX 3UC (D, DSS) extracted from the
FX 3UC Series User’s Manual - Hardware Edition.
For detailed explanation, refer to the FX 3UC
Series User’s Manual - Hardware Edition.
I/O specifications, wiring and installation of the
PLC main unit FX 3UC -32MT-LT-2 extracted from the FX 3UC Series User’s Manual - Hardware
Edition. For detailed explanation, refer to the
FX 3UC Series User’s Manual - Hardware Edition.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 3UC PLC main unit.
I/O specifications, wiring and installation of the
PLC main unit FX 3G extracted from the FX 3G
Series User’s Manual - Hardware Edition. For detailed explanation, refer to the FX 3G Series
User’s Manual - Hardware Edition.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 3G PLC main unit.
Model name code
-
09R516
-
-
09R519
-
09R521
10
FXCPU Structured Programming Manual
(Application Functions)
Manual name
Programming
FX 3G /FX 3U /FX 3UC User's Manual-
Analog Control Edition
FX Series User's Manual -Data
Communication Edition
FX 3G /FX 3U /FX 3UC Series User's
Manual -Positioning Edition
FX 3U -CF-ADP User's Manual
Manual number
Supplied with product or Additional Manual
JY997D16701
JY997D16901
JY997D16801
JY997D35401
Additional Manual
Additional Manual
Additional Manual
Additional Manual
Contents
Model name code
Detaileds about the analog special function block
(FX 3U -4AD, FX 3U -4DA, FX 3UC -4AD) and analog special adapter
(FX 3U -****-ADP).
Details about simple N : N link, parallel link, computer link and no-protocol communication
(RS instruction and FX 2N -232IF).
Details about the positioning function built in the
FX 3G /FX 3U /FX 3UC Series.
Describes details of the FX 3U -CF-ADP CF card special adapter.
09R619
09R715
09R620
09R720
FX 1S /FX 1N /FX 2N /FX 1NC /FX 2NC PLCs
Manual name
PLC main unit
Manual number
Supplied with product or Additional Manual
FX 1S HARDWARE MANUAL
FX 1N HARDWARE MANUAL
FX 2N HARDWARE MANUAL
FX 1NC HARDWARE MANUAL
FX 2NC HARDWARE MANUAL
JY992D83901
JY992D89301
JY992D66301
JY992D92101
JY992D76401
Additional Manual
Additional Manual
Additional Manual
Additional Manual
Additional Manual
Contents
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 1S PLC main unit.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 1N PLC main unit.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 2N PLC main unit.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 1NC PLC main unit.
(Japanese only)
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 2NC PLC main unit.
Programming
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 FX 2N -232IF).
Model name code
-
-
09R508
09R505
09R509
09R715
11
FXCPU Structured Programming Manual
(Application Functions)
FX 0 /FX 0S /FX 0N /FX U /FX 2C PLCs [whose production is finished]
Manual name Manual number
Supplied with product or Additional Manual
Contents
PLC main unit
FX 0 /FX 0N HARDWARE MANUAL
FX 0S HARDWARE MANUAL
FX/FX 2C HARDWARE MANUAL
JY992D47501 Supplied with product
JY992D55301 Supplied with product
JY992D47401 Supplied with product
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 0 /FX 0N PLC main unit.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX 0S PLC main unit.
Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX U /FX 2C PLC main unit.
Programming
FX Series User's Manual -Data
Communication Edition
JY997D16901 Additional Manual
Manuals of models whose production is finished
Production is finished for FX
0
/FX
0S
/FX
0N
/FX
U
/FX
2C
PLCs.
Details about simple N : N link, parallel link, computer link and no-protocol communication
(RS instruction and FX 2N -232IF).
Model name code
-
-
-
09R715
12
FXCPU Structured Programming Manual
(Application Functions)
Generic Names and Abbreviations Used in Manuals
Abbreviation/generic name
PLCs
FX 3U Series or FX 3U PLC
FX 3UC Series or FX 3UC PLC
FX
FX
FX
FX
FX
3G
2N
1N
Series or FX
Series or FX
2NC
Series or FX
1NC
3G
2N
Series or FX
1N
Series or FX
PLC
PLC
2NC
1NC
PLC
PLC
PLC
Generic name of FX 3U Series PLCs
Generic name of FX 3UC Series PLCs
Generic name of FX 3G Series PLCs
Generic name of FX 2N Series PLCs
Generic name of FX 2NC Series PLCs
Generic name of FX 1N Series PLCs
Generic name of FX 1NC Series PLCs
These products can only used in Japan.
Generic name of FX 1S Series PLCs
Generic name of FX U (FX,FX 2 ) Series PLCs
Generic name of FX
2C
Series PLCs
Name
FX 1S Series or FX 1S PLC
FX U Series or FX U PLC
FX
2C
Series or FX
2C
PLC
FX 0N Series or FX 0N PLC
FX 0S Series or FX 0S PLC
FX 0 Series or FX 0 PLC
Special adapters
CF card special adapter
CF-ADP
Programming language
ST
Generic name of FX
Generic name of FX
Generic name of FX
0N
0S
0
Series PLCs
Series PLCs
Series PLCs
Generic name of CF card special adapters
FX 3U -CF-ADP
Structured ladder
Manuals
Q/FX Structured Programming Manual
(Fundamentals)
FX Structured Programming Manual
(Device & Common)
Abbreviation of structured text language
Abbreviation of ladder diagram language
Abbreviation of QCPU/FXCPU Structured Programming Manual (Fundamentals)
Abbreviation of FXCPU Structured Programming Manual (Device & Common)
FX Structured Programming Manual
(Basic & Applied Instruction)
FX Structured Programming Manual
(Application Functions)
Abbreviation of FXCPU Structured Programming Manual (Basic & Applied Instruction)
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 FX 3G /FX 3U /FX 3UC Series User's Manual-ANALOG CONTROL EDITION
POSITIONING CONTROL EDITION Abbreviation of FX 3G /FX 3U /FX 3UC Series User's Manual-POSITIONING CONTROL EDITION
13
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.1 Outline of Structured Programs and Programming
1. 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 Outline
1.2 PLC Series and Programming Software Version
1.1.2
Programming languages
The following programming languages can be used in each program block.
Graphic languages
1. Structured ladder language
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.
1 X000 X001 Y000
Output Y000
Y000
2
X001
MOV
EN ENO s d D0 D2
When X001 is ON, the contents of D0 are transferred to D2.
Text language
1. ST (Structured text) language
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.
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;
1
2
3
4
5
6
A
1.2
PLC Series and Programming Software Version
Software package name
(model name)
GX Works2 version PLC Series
FX 3U •FX 3UC
FX 3G
FX 2N •FX 2NC
FX 1N •FX 1NC
FX 1S
FX U /FX 2C
FX 0N
FX 0 •FX 0S
GX Works2
(SW1DNC-GXW2-E)
Ver. 1.08J or later
15
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.3 Cautions on Creation of Fundamental Programs
1.3
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)
Scan time
(operation cycle)
[Input processing]
Input image memory is read.
(2)
The ON/OFF status of input terminals is received at one time.
[Program processing]
Image memory of each device is updated.
Input image is read, and operation is executed according to program.
(3)
Batch I/O method
(Refresh method)
[Output processing] Output
Result is transferred to devices output latch memory.
are driven.
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
OFF ON
This "input ON" can be received.
"Input ON" cannot be received.
This "input OFF" cannot be received.
ON OFF
Program processing
Program processing
Program processing
Program processing
Input processing
Output processing ( Time)
Operation cycle
16
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.3 Cautions on Creation of Fundamental Programs
1.3.2
Double output (double coil) operation and countermeasures
This subsection explains the double output (double coil) operation and countermeasures.
1. Operation of double outputs
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.
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.
Input processing
X001=ON X002=OFF
First 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.
In the second coil Y003, however, the image memory is set to
OFF because the input X002 is OFF.
As a result, the actual output to the outside is "Y003: OFF, Y004:
ON".
X001
Y003
Second
Y003
X002
Y004
Y003
1
2
3
4
Output processing
Y003=OFF Y004=ON
2. Countermeasures against double outputs
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
A B Y000
A B
C E
C E
Ignored
Y000
D
D
A B M100
Or
M101 C
D
M100
M101
E
Y000
5
6
A
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 Outline
1.3 Cautions on Creation of Fundamental Programs
1.3.3
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 B F C E B F
A
E
C D
A
C
E D
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 A E
E B D C
Or
A E B D C
1.3.4
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
M8328:Instruction non-execution flag
*1
M8304:Zero flag
*1
M8306:Carry flag
*1
M8090:Block comparison signal
*1
M8329:Instruction execution abnormal complete flag
*2
*1.
Supported only in FX 3U /FX 3UC PLCs.
*2.
Supported only in FX
3U
/FX
3UC
/FX
3G
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
1. Program containing many flags (Example of instruction execution complete flag M8029)
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
2
Good example
M8029 works as a flag to indicate that execution of
DSW is completed.
M8000
M8029
Execution is completed.
X010
1
D0
10
EN
DSW
ENO s1 s2 d1 Y010 d2 D0
EN
MUL
ENO s1 s2 d Number of output pulses
3
4
M8029 works as a flag to indicate that execution of
DPLSY is completed.
X000
M0
1000
Number of output pulses
M8029
Execution is completed.
M0
S
DPLSY
EN ENO s1 s2 d
M0
R
Y000
Bad example
M8029 works as a flag to indicate that execution of
DPLSY (on the lower side) is completed.
M8029
Execution is completed.
M8000
M0
R Program for DPLSY (on the upper side)
X010
1
EN
DSW
ENO s1 s2 d1 d2
Y010
D0 M8029 works as a flag to indicate that execution of
DSW is completed.
X000 M0
S
M0
M8029 works as a flag to indicate that execution of DPLSY
(on the upper side) is completed.
M8029
Execution is completed.
1000
Number of output pulses
D0
10
DPLSY
EN ENO s1 s2 d
DPLSY(on the upper side)
Y000
EN
MUL
ENO s1 s2 d
Program for DSW
Number of output pulses
M1
1000
Number of output pulses2
DPLSY
EN ENO s1 s2 d
DPLSY(on the lower side)
Y001
5
6
A
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
M8029
Execution is completed.
X010
1
EN
DSW
ENO s1 s2 d1 Y010 d2 D0
DSW execution complete flag
M8029 is changed to M100.
M8029
M0
Execution is completed.
DPLSY execution complete flag
M8029 is changed to M200.
M100
1000
Number of output pulses
DPLSY
EN ENO s1 s2 d
M0
R
M200
Y000
It works as the DSW execution complete flag.
M100
It works as the DPLSY execution complete flag.
M200
D0
10
EN
MUL
ENO s1 s2 d Number of output pulses
Y030
20
FXCPU Structured Programming Manual
(Application Functions)
1 Outline
1.3 Cautions on Creation of Fundamental Programs
1.3.5
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
Error flag
M8067
Device which stores error code
D8067
Device which stores error occurrence step
FX 0 /FX 0S /FX 0N /FX U /FX 2C /FX 1S
/FX 1N /FX 2N /FX 1NC /FX 2NC /FX 3G
FX 3U /FX 3UC
D8069
*1 D8315, D8314
*1.
When an error occurs in a step up to the step No. 32767 in the FX 3U /FX 3UC 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.
• 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.)
• 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.
2. Operation error latch
Error flag
M8068
Device which stores error code
-
Device which stores error occurrence step
FX 0 /FX 0S /FX 0N /FX U /FX 2C /FX 1S
/FX 1N /FX 2N /FX 1NC /FX 2NC /FX 3G
FX 3U /FX 3UC
D8068
*2 D8313, D8312
*2.
When an error occurs in a step up to the step No. 32767 in the FX 3U /FX 3UC PLC, you can check the error occurrence step also in D8068 (16 bits).
• When an operation error has occurred, M8068 turns ON, and the device shown in the table above stores the error occurrence step.
• 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.
1
2
3
4
5
6
A
21
FXCPU Structured Programming Manual
(Application Functions)
2 Function List
2.1 Type Conversion Functions
2. Function List
This chapter introduces a list of functions available in programming.
2.1
Type Conversion Functions
Applicable PLC
Function name Function Reference
BOOL_TO_INT(_E) Converts bit data into word [signed] data.
3
BOOL_TO_DINT(_E) Converts bit data into double word [signed] data.
3
BOOL_TO_STR(_E) Converts bit data into string data.
BOOL_TO_WORD(_E)
BOOL_TO_DWORD
(_E)
Converts bit data into word [unsigned]/bit string
[16-bit] data.
Converts bit data into double word [unsigned]/bit string [32-bit] data.
BOOL_TO_TIME(_E) Converts bit data into time data.
INT_TO_DINT(_E)
DINT_TO_INT(_E)
INT_TO_BOOL(_E)
Converts word [signed] data into double word
[signed] data
Converts double word [signed] data into word
[signed] data.
Converts word [signed] data into bit data.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3 3
DINT_TO_BOOL(_E) Converts double word [signed] data into bit data.
3
INT_TO_REAL(_E)
DINT_TO_REAL(_E)
Converts word [signed] data into float (single precision) data.
Converts double word [signed] data into float
(single precision) data.
3
3
3 INT_TO_STR(_E)
DINT_TO_STR(_E)
INT_TO_WORD(_E)
DINT_TO_WORD(_E)
INT_TO_DWORD(_E)
DINT_TO_DWORD
(_E)
INT_TO_BCD(_E)
Converts word [signed] data into string data.
Converts double word [signed] data into string data.
Converts word [signed] data into word
[unsigned]/bit string [16-bit] data.
Converts double word [signed] data into word
[unsigned]/bit string [16-bit] data.
Converts word [signed] data into double word
[unsigned]/bit string [32-bit] data.
Converts double word [signed] data into double word [unsigned]/bit string[32-bit] data.
DINT_TO_BCD(_E)
INT_TO_TIME(_E)
Converts word [signed] data into BCD data.
Converts double word [signed] data into BCD data.
Converts word [signed] data into time data.
3
3
3
3
3
3
3
3
3
*1
*1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
DINT_TO_TIME(_E)
Converts double word [signed] data into time data.
3 3 3
*1.
The function is provided in the FX 3G Series Ver.1.10 or later.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.1.8
Subsection
5.1.9
Subsection
5.1.10
Subsection
5.1.11
Subsection
5.1.12
Subsection
5.1.13
Subsection
5.1.14
Subsection
5.1.1
Subsection
5.1.2
Subsection
5.1.3
Subsection
5.1.4
Subsection
5.1.5
Subsection
5.1.6
Subsection
5.1.7
Subsection
5.1.15
Subsection
5.1.16
Subsection
5.1.17
Subsection
5.1.18
Subsection
5.1.19
Subsection
5.1.20
Subsection
5.1.21
Subsection
5.1.22
22
FXCPU Structured Programming Manual
(Application Functions)
2 Function List
2.1 Type Conversion Functions
Applicable PLC
Function name Function Reference
REAL_TO_INT(_E)
REAL_TO_DINT(_E)
REAL_TO_STR(_E)
WORD_TO_BOOL(_E)
DWORD_TO_BOOL
(_E)
WORD_TO_INT(_E)
WORD_TO_DINT(_E)
DWORD_TO_INT(_E)
DWORD_TO_DINT
(_E)
WORD_TO_DWORD
(_E)
DWORD_TO_WORD
(_E)
WORD_TO_TIME(_E)
DWORD_TO_TIME
(_E)
Converts float (single precision) data into word
[signed] data.
Converts float (single precision) data into double word [signed] data.
Converts float (single precision) data into string data.
Converts word [unsigned]/bit string [16-bit] data into bit data.
Converts double word [unsigned]/bit string [32bit] data into bit data.
Converts word [unsigned]/bit string [16-bit] data into word [signed] data.
Converts word [unsigned]/bit string [16-bit] data into double word [signed] data.
Converts double word [unsigned]/bit string [32bit] data into word [signed] data.
Converts double word [unsigned]/bit string [32bit] data into double word [signed] data.
Converts word [unsigned]/bit string [16-bit] data into double word [unsigned]/bit string [32-bit].
Converts double word [unsigned]/bit string [32bit] data into word [unsigned]/bit string [16bit]data.
Converts word [unsigned]/bit string [16-bit] data into time data.
Converts double word [unsigned]/bit string [32bit] data into time data.
STR_TO_BOOL(_E) Converts string data into bit data.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
STR_TO_INT(_E)
STR_TO_DINT(_E)
STR_TO_REAL(_E)
STR_TO_TIME(_E)
Converts string data into word [signed] data.
Converts string data into double word [signed] data.
Converts string data into float (single precision) data.
Converts string data into time data.
BCD_TO_INT(_E)
BCD_TO_DINT(_E)
Converts BCD data into word [signed] data.
Converts BCD data into double word [signed] data.
TIME_TO_BOOL(_E) Converts time data into bit data.
3
3
3
3
3
3
3
3
3
*1
*1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3 3
TIME_TO_INT(_E)
TIME_TO_DINT(_E)
Converts time data into word [signed] data.
Converts time data into double word [signed] data.
Converts time data into string data.
3
3
3
3
3
3
3
3
TIME_TO_STR(_E) 3
TIME_TO_WORD(_E)
Converts time data into word [unsigned]/bit string [16-bit]data.
3 3 3
TIME_TO_DWORD
(_E)
Converts time data into double word [unsigned]/ bit string [32-bit] data.
3 3 3
*1.
The function is provided in the FX
3G
Series Ver.1.10 or later.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.1.23
Subsection
5.1.24
Subsection
5.1.25
Subsection
5.1.26
Subsection
5.1.27
Subsection
5.1.28
Subsection
5.1.29
Subsection
5.1.30
Subsection
5.1.31
Subsection
5.1.32
Subsection
5.1.33
Subsection
5.1.34
Subsection
5.1.35
Subsection
5.1.36
Subsection
5.1.37
Subsection
5.1.38
Subsection
5.1.39
Subsection
5.1.40
Subsection
5.1.41
Subsection
5.1.42
Subsection
5.1.43
Subsection
5.1.44
Subsection
5.1.45
Subsection
5.1.46
Subsection
5.1.47
Subsection
5.1.48
1
2
3
4
5
6
A
23
ADD_E
SUB_E
MUL_E
DIV_E
MOD(_E)
EXPT(_E)
MOVE(_E)
FXCPU Structured Programming Manual
(Application Functions)
2 Function List
2.2 Standard Functions Of One Numeric Variable
2.2
Standard Functions Of One Numeric Variable
Applicable PLC
Function name Function Reference
ABS(_E) Obtains the absolute value.
2.3
Standard Arithmetic Functions
3 3 3 3 3 3 3 3
Subsection
5.2.1
Applicable PLC
Function name Function Reference
Adds data.
Subtracts data.
Multiplies data.
Divides data (, and outputs the quotient).
Divides data (, and outputs the remainder).
Obtains the raised result.
Transfers data.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3 3 3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.3.1
Subsection
5.3.2
Subsection
5.3.3
Subsection
5.3.4
Subsection
5.3.5
Subsection
5.3.6
Subsection
5.3.7
24
FXCPU Structured Programming Manual
(Application Functions)
2.4
Standard Bit Shift Functions
2 Function List
2.4 Standard Bit Shift Functions
Applicable PLC
Function name Function Reference
SHL(_E)
SHR(_E)
Shifts bits leftward.
Shifts bits rightward.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.4.1
Subsection
5.4.2
2.5
Standard Bitwise Boolean Functions
Applicable PLC
Function name Function Reference
AND_E
OR_E
XOR_E
NOT(_E)
Obtains the logical product.
Obtains the logical sum.
Obtains the exclusive logical sum.
Obtains the logical not.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.5.1
Subsection
5.5.2
Subsection
5.5.3
Subsection
5.5.4
2.6
Standard Selection Functions
Function name
SEL(_E)
MAXIMUM(_E)
MINIMUM(_E)
LIMITATION(_E)
MUX(_E)
Applicable PLC
Function Reference
Selects data in accordance with the input condition.
Searches the maximum value.
3
3
Searches the minimum value.
Judges whether data is located within the range between the upper limit value and the lower limit value.
Selects data, and outputs it.
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 3 3 3
3 3 3 3
3
3
3
3
3
3
3
3
3
3
Subsection
5.6.1
Subsection
5.6.2
Subsection
5.6.3
Subsection
5.6.4
Subsection
5.6.5
1
2
3
4
5
6
A
25
FXCPU Structured Programming Manual
(Application Functions)
2.7
Standard Comparison Functions
2 Function List
2.7 Standard Comparison Functions
Applicable PLC
Function name Function Reference
GT_E
GE_E
EQ_E
LE_E
LT_E
NE_E
Compares data with regard to "> (larger)".
Compares data with regard to " ≥ (larger or equal)".
Compares data with regard to "= (equal)".
Compares data with regard to " ≤ (smaller or equal)".
Compares data with regard to "< (smaller)".
Compares data with regard to " ≠ (unequal)".
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.7.1
Subsection
5.7.2
Subsection
5.7.3
Subsection
5.7.4
Subsection
5.7.5
Subsection
5.7.6
2.8
Standard Character String Functions
Applicable PLC
Function name Function Reference
MID(_E)
CONCAT(_E)
INSERT(_E)
DELETE(_E)
REPLACE(_E)
FIND(_E)
Obtains a character string from a specified position.
Connects character strings.
3
3
Inserts a character string.
Deletes a character string.
3
3
Replaces a character string.
Searches a character string.
3
3
2.9
Functions Of Time Data Types
Function name
ADD_TIME(_E)
SUB_TIME(_E)
MUL_TIME(_E)
DIV_TIME(_E)
Function
Adds time data.
Subtracts time data.
Multiplies time data.
Divides time data.
Applicable PLC
Reference
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Subsection
5.9.1
Subsection
5.9.2
Subsection
5.9.3
Subsection
5.9.4
Subsection
5.8.1
Subsection
5.8.2
Subsection
5.8.3
Subsection
5.8.4
Subsection
5.8.5
Subsection
5.8.6
26
FXCPU Structured Programming Manual
(Application Functions)
2.10
Standard Function Blocks
2 Function List
2.10 Standard Function Blocks
Applicable PLC
Function name Function Reference
R_TRIG(_E)
F_TRIG(_E)
CTU(_E)
CTD(_E)
CTUD(_E)
TP(_E)
TON(_E)
TOF(_E)
COUNTER_FB_M
TIMER_10_FB_M
Detects the rising edge of a signal, and outputs pulse signal.
Detects the falling edge of a signal, and outputs pulse signal.
Counts up the number of times of rising of a signal.
Counts down the number of times of rising of a signal.
Counts up/down the number of times of rising of a signal.
Keeps ON a signal during specified time duration.
Keeps OFF a signal during specified time duration.
Turns OFF the output signal at specified time after the input signal turned OFF.
Counter drive
10ms timer drive
3
3
3
3
3
3
3
3
3
3
TIMER_CONT_FB_M Retentive timer drive
TIMER_100_M 100ms timer drive
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3 Section 6.1
3 Section 6.2
Section 6.3
Section 6.4
Section 6.5
Section 6.6
Section 6.7
Section 6.8
3 Section 6.9
3
Section
6.10
3
Section
6.11
Section
6.12
1
2
3
4
5
6
A
27
FXCPU Structured Programming Manual
(Application Functions)
3 Function Construction
3.1 Applied Function Expression and Execution Type
3. 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
EN
SHL_E
ENO
_IN
_N
*1 D10
_IN (
*1 ( d
K1 ( s n
) : An argument whose contents do not change even if the function is executed is called
"source", and expressed in this symbol.
) : An argument whose contents change when the function is executed is called "destination", and expressed in this symbol.
) : 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
3 Function Construction
3.2 Labels
Label types
Labels are classified into two types, global and local.
• 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.
Class Description
VAR_GLOBAL Common label available in all program components
VAR_GLOBAL_CONSTANT Common constant available in all program components
VAR
VAR_CONSTANT
Label available within declared program components, and not available in any other program component
Constant available within declared program components, and not available in any other program component
VAR_INPUT
VAR_OUTPUT
VAR_IN_OUT
Label which receives a value, and cannot be changed in program components
Label output from a function block
Local label which receives a value, outputs it from a program component, and can be changed in program components
Applicable program component
Program block
Function
Function block
3
3
3
3
3 3 3
3 3
3
3
3
3
3
Label definition
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.
In the example below, the label "VAR_D10" is set for the function "BOOL_TO_STR_E".
X000
M0
BOOL_TO_STR_E
EN ENO
_BOOL VAR_D10
• When using "VAR_D10" as a global label
Set the class, label name, data type and device (or address).
1
2
3
4
5
6
A
• 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
Bit
Binary number
Octal number
Decimal number
Hexadecimal number
Real number
Character string
Description method
Input "TRUE" or "FALSE". Or input "0" or "1".
Add "2#" before a binary number.
Add "8#" before an octal number.
Input a decimal number directly. Or add "K" before a decimal number.
Add "16#" or "H" before a hexadecimal number.
Input a real number directly. Or add "E" before a real number.
Surround a character string with single quotations (') or double quotations (").
Example
TRUE, FALSE
2#0010, 2#01101010
8#0, 8#337
123, K123
16#FF, HFF
2.34, E2.34
'ABC', "ABC"
Data type
The label data type is basic or universal.
• The table below shows a list of basic data types.
Data type
Bit
Word [signed]
Description
Boolean data
Integer
Double Word [signed] Double precision integer
Word [unsigned]/Bit String
[16-bit]
Double Word [unsigned]/Bit
String [32-bit]
16-bit data
32-bit data
FLOAT (Single Precision) Real number
String
Time
Character string
Time value
Value range
0(FALSE), 1(TRUE)
-32768 to 32767
-2147483648 to
2147483647
0 to 65535
0 to 4294967295
E ±1.175495
-38
to
E ±3.402823
+38
(Number of significant figures: 6)
(50 characters maximum)
T#-24d-0h31m23s648.00ms to
T#24d20h31m23s647.00ms
32 bits
Variable
32 bits
1 bit
16 bits
Bit length
32 bits
16 bits
32 bits
30
FXCPU Structured Programming Manual
(Application Functions)
3 Function Construction
3.2 Labels
• The universal data type indicates data type of a label which combines several basic data types.
The data type name begins with "ANY".
ANY
1
2
ANY_SIMPLE Array
*1
Structure
*1
ANY_REAL
FLOAT
(Single
Precision)
FLOAT
(Double
Precision)
ANY_NUM
ANY_INT
Word
[signed]
Double word
[signed]
ANY_BIT
Bit
Word
[unsigned]/
Bit String
[16-bit]
Double Word
[unsigned]/
Bit String
[32-bit]
Time String
The "ANY" type on a higher layer contains types on the lower layer.
The "ANY" type on the top layer contains all types.
3
4
5
ANY16 ANY32
Word
[unsigned]/
Bit String
[16-bit]
Word
[signed]
Double Word
[unsigned]/
Bit String
[32-bit]
Double word
[signed] 6
A
*1 Refer to the following manual for details.
Q/FX Structured Programming Manual (Fundamentals)
31
FXCPU Structured Programming Manual
(Application Functions)
3.3
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.
X 0 D 100
3 Function Construction
3.3 Device and Address
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
Q
Input
Output X
2nd character: Size
(Omitted) Bit
Bit
M Internal W
D
L
Word (16 bits)
Double word (32 bits)
Long Word (64 bits)
3rd and later characters:
Classification
This number is provided for detailed classification.
Period (.) is used to delimit the subsequent "Number".
The characters for classification may be omitted.
Number
This decimal number corresponds to the device number.
%I X 0 %M X 1 . 863
Memory area position
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 Function Construction
3.4 EN and ENO
3.4
EN and ENO
Execution of an instruction can be controlled when the instruction contains "EN" in its name.
• "EN" inputs the instruction execution condition.
• "ENO" outputs the instruction execution status.
• The table below shows the "ENO" status corresponding to the "EN" status and the operation result.
1
2
EN
TRUE(Executes operation.)
FALSE(Stops operation.)
ENO Operation result
TRUE(Operation error did not occur.) Operation output value
FALSE(Operation error occurred.)
FALSE
Indefinite value
Indefinite value
3
X000 BOOL_TO_STR_E
EN
_BOOL
ENO M1
VAR_D10
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.
4
5
6
A
33
4)
5)
6)
7)
FXCPU Structured Programming Manual
(Application Functions)
4 How to Read Explanation of Functions
4. How to Read Explanation of Functions
Function explanation pages have the following configuration.
1)
2)
3)
* 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) Indicates the chapter/section/subsection number and instruction name.
2) Indicates PLCs which support the function.
Item Description
The PLC Series supports the function from its first product.
The supporting status varies on the version.
Applicable versions are explained in "Cautions".
The PLC Series does not support the function.
3) Indicates the expression of each function.
Item Description
Structured ladder Indicates the instruction expression in the structured ladder language.
ST Indicates the instruction expression in the ST language.
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)
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.
6) Cautions
Cautions on using the function are described.
7) Program example
Program examples are explained in each language.
1
2
3
4
5
6
A
35
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
5. 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)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
36
Outline
This function coverts bit data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
BOOL_TO_INT
BOOL_TO_INT_E
*1.
Output variable
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_INT
_BOOL *1
BOOL_TO_INT_E
EN
_BOOL
ENO
*1
D0
D0
ST
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);
2. Set data
Input variable
Output variable
Variable
EN
_BOOL (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source bit data
Execution status
Word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Bit
Bit
Word [signed]
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.
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, bit data stored in a device specified in obtained by conversion is output to a device specified in s d
is converted into word [signed] data, and the data
.
1) Function without EN/ENO(BOOL_TO_INT)
[Structured ladder] g_bool1 BOOL_TO_INT
_BOOL g_int1
[ST] g_int1 := BOOL_TO_INT(g_bool1);
2) Function with EN/ENO(BOOL_TO_INT_E)
[Structured ladder] g_bool1 BOOL_TO_INT_E
EN ENO g_bool2 _BOOL g_bool3 g_int1
[ST] g_bool3 := BOOL_TO_INT_E(g_bool1, g_bool2, g_int1);
1
2
3
4
5
6
A
37
FXCPU Structured Programming Manual
(Application Functions)
5.1.2
BOOL_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts bit data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
BOOL_TO_DINT
BOOL_TO_DINT_
E
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_DINT
_BOOL *1
BOOL_TO_DINT_E
EN
_BOOL
ENO
*1
Label
Label
ST
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);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BOOL (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source bit data
Execution status
Double word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Bit
Bit
Double Word [signed]
Explanation of function and operation
This function converts bit data stored in a device specified in the data obtained by conversion to a device specified in d
.
s
into double word [signed] data, and outputs
FALSE 0
TRUE
Bit data
1
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.
38
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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)
[Structured ladder] g_bool1 BOOL_TO_DINT
_BOOL g_dint1
[ST] g_dint1 := BOOL_TO_DINT(g_bool1);
2) Function with EN/ENO(BOOL_TO_DINT_E)
[Structured ladder] g_bool1 BOOL_TO_DINT_E
EN ENO g_bool2 _BOOL g_bool3 g_dint1
[ST] g_bool3 := BOOL_TO_DINT_E(g_bool1, g_bool2, g_dint1);
1
2
3
4
5
6
A
39
FXCPU Structured Programming Manual
(Application Functions)
5.1.3
BOOL_TO_STR(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts bit data into string data, and outputs the data obtained by conversion.
1. Format
Function name
BOOL_TO_STR
BOOL_TO_STR_
E
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_STR
_BOOL *1 Label
ST
BOOL_TO_STR(_BOOL);
Example:
Label:=
BOOL_TO_STR(M0);
BOOL_TO_STR_E
EN
_BOOL
ENO
*1 Label
BOOL_TO_STR_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_STR_E(X000,M0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BOOL (
ENO
*1 ( s
) d
)
Execution condition
Conversion source bit data
Execution status
String data after conversion
Description
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Bit
String
Data type
Explanation of function and operation
This function converts bit data input to a deice specified in by conversion to a device specified in d
.
s
into string data, and outputs the data obtained
FALSE "0"
TRUE
Bit data
"1"
String 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.
40
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, bit data stored in a deice specified in by conversion is output to a device specified in d
.
1) Function without EN/ENO(BOOL_TO_STR) s
is converted into string data, and the data obtained
[Structured ladder] g_bool1 BOOL_TO_STR
_BOOL g_string1
[ST] g_string1 := BOOL_TO_STR(g_bool1);
2) Function with EN/ENO(BOOL_TO_STR_E)
[Structured ladder] g_bool1 BOOL_TO_STR_E
EN ENO g_bool2 _BOOL g_bool3 g_string1
[ST] g_bool3 := BOOL_TO_STR_E(g_bool1, g_bool2, g_string1);
1
2
3
4
5
6
A
41
FXCPU Structured Programming Manual
(Application Functions)
5.1.4
BOOL_TO_WORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts bit data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name
BOOL_TO_WOR
D
BOOL_TO_WOR
D_E
*1.
Output variable
2. Set data
Input variable
Variable
EN
_BOOL (
ENO s
)
Output variable
*1 ( d
)
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_WORD
_BOOL *1 D0
ST
BOOL_TO_WORD(_BOOL);
Example:
D0:=
BOOL_TO_WORD(M0);
BOOL_TO_WORD_E
EN
_BOOL
ENO
*1 D0
BOOL_TO_WORD_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_WORD_E(X000,
M0,D0);
Execution condition
Conversion source bit data
Execution status
Description
Word [unsigned]/bit string [16-bit] data after conversion
Data type
Bit
Bit
Bit
Word [unsigned]/
Bit String [16-bit]
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
Bit data
1H
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
Program example
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)
[Structured ladder] g_bool1 BOOL_TO_WORD
_BOOL g_word1
[ST] g_word1 := BOOL_TO_WORD(g_bool1);
2) Function with EN/ENO(BOOL_TO_WORD_E)
[Structured ladder] g_bool1 BOOL_TO_WORD_E
EN ENO g_bool2 _BOOL
[ST] g_bool3 g_word1 g_bool3 := BOOL_TO_WORD_E(g_bool1, g_bool2, g_word1);
1
2
3
4
5
6
A
43
FXCPU Structured Programming Manual
(Application Functions)
5.1.5
BOOL_TO_DWORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
BOOL_TO_DWO
RD
BOOL_TO_DWO
RD_E
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_DWORD
_BOOL *1 Label
ST
BOOL_TO_DWORD(_BOOL);
Example:
Label:=
BOOL_TO_DWORD(M0);
BOOL_TO_DWORD_E
EN
_BOOL
ENO
*1 Label
BOOL_TO_DWORD_E(EN,
_BOOL, Output label);
Example:
BOOL_TO_DWORD_E(X000,
M0, Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BOOL (
ENO s
)
*1 ( d
)
Execution condition
Conversion source bit data
Execution status
Description
Double word [unsigned]/bit string [32-bit] data after conversion
Data type
Bit
Bit
Bit
Double Word [unsigned]/
Bit string [32-bit]
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
Program example
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)
[Structured ladder] g_bool1 BOOL_TO_DWORD
_BOOL g_dword1
[ST] g_dword1 := BOOL_TO_DWORD(g_bool1);
2) Function with EN/ENO(BOOL_TO_DWORD_E)
[Structured ladder] g_bool1 BOOL_TO_DWORD_E
EN ENO g_bool2 _BOOL g_bool3 g_dword1
[ST] g_bool3 := BOOL_TO_DWORD_E(g_bool1, g_bool2, g_dword1);
1
2
3
4
5
6
A
45
FXCPU Structured Programming Manual
(Application Functions)
5.1.6
BOOL_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts bit data into time data, and outputs the data obtained by conversion.
1. Format
Function name
BOOL_TO_TIME
BOOL_TO_TIME_
E
X000
M0
M0
Expression in each language
Structured ladder
BOOL_TO_TIME
_BOOL *1 Label
ST
BOOL_TO_TIME(_BOOL);
Example:
Label:=
BOOL_TO_TIME(M0);
BOOL_TO_TIME_E
EN
_BOOL
ENO
*1 Label
BOOL_TO_TIME_E(EN,_BOOL,
Output label);
Example:
BOOL_TO_TIME_E(X000,M0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BOOL (
ENO
*1 ( s
) d
)
Execution condition
Conversion source bit data
Execution status
Time data after conversion
Description
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Bit
Time
Data type
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
.
s
into time data, and outputs the data
FALSE 0
TRUE
Bit data
1 ms
Time 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
Program example
In this program, bit data stored in a device specified in by conversion is output to a device specified in d
.
1) Function without EN/ENO(BOOL_TO_TIME) s
is converted into time data, and the data obtained
[Structured ladder] g_bool1 BOOL_TO_TIME
_BOOL g_time1
[ST] g_time1 := BOOL_TO_TIME(g_bool1);
2) Function with EN/ENO(BOOL_TO_TIME_E)
[Structured ladder] g_bool1 BOOL_TO_TIME_E
EN ENO g_bool2 _BOOL g_bool3 g_time1
[ST] g_bool3 := BOOL_TO_TIME_E(g_bool1, g_bool2, g_time1);
1
2
3
4
5
6
A
47
FXCPU Structured Programming Manual
(Application Functions)
5.1.7
INT_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts word [signed] data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_DINT
INT_TO_DINT_E
X000
D0
D0
INT_TO_DINT
_INT
Expression in each language
Structured ladder
*1 Label
ST
INT_TO_DINT(_INT);
Example:
Label:=
INT_TO_DINT(D0);
INT_TO_DINT_E
EN
_INT
ENO
*1 Label
INT_TO_DINT_E(EN,_INT,
Output label);
Example:
INT_TO_DINT_E(X000,D0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Double word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
Bit
Double Word [signed]
Explanation of function and operation
This function converts word [signed] data stored in a device specified in and outputs the data obtained by conversion to a device specified in d
.
s
into double word [signed] data,
1234 1234
Word [signed] data 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
Program example
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)
[Structured ladder]
INT_TO_DINT g_int1=5923 _INT g_dint1=5923
[ST] g_dint1 := INT_TO_DINT(g_int1);
2) Function with EN/ENO(INT_TO_DINT_E)
[Structured ladder] g_bool1 INT_TO_DINT_E
EN ENO g_int1 _INT g_bool3 g_dint1
[ST] g_bool3 := INT_TO_DINT_E(g_bool1, g_int1, g_dint1);
1
2
3
4
5
6
A
49
FXCPU Structured Programming Manual
(Application Functions)
5.1.8
DINT_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_INT
DINT_TO_INT_E
Label
X000
Label
DINT_TO_INT
_DINT
Expression in each language
Structured ladder
*1 D10
ST
DINT_TO_INT(_DINT);
Example:
D10:=
DINT_TO_INT(Label);
DINT_TO_INT_E
EN
_DINT
ENO
*1 D10
DINT_TO_INT_E(EN,_DINT,
Output label);
Example:
DINT_TO_INT_E(X000, Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Word [signed] data after conversion
Data type
Bit
Double Word [signed]
Bit
Word [signed]
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
.
s
into word [signed] data,
1234 1234
Double word [signed] data 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
Program example
In this program, double word [signed] data stored in a device specified in data, and the data obtained by conversion is output to a device specified in s d
is converted into word [signed]
.
1) Function without EN/ENO(DINT_TO_INT)
[Structured ladder]
DINT_TO_INT g_dint1=5923 _DINT g_int1=5923
[ST] g_int1 := DINT_TO_INT(g_dint1);
2) Function with EN/ENO(DINT_TO_INT_E)
[Structured ladder] g_bool1 DINT_TO_INT_E
EN ENO g_dint1 _DINT g_bool3 g_int1
[ST] g_bool3 := DINT_TO_INT_E(g_bool1, g_dint1, g_int1);
1
2
3
4
5
6
A
51
FXCPU Structured Programming Manual
(Application Functions)
5.1.9
INT_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_BOOL
INT_TO_BOOL_E
X000
D0
Expression in each language
Structured ladder
INT_TO_BOOL
_INT *1 M0
ST
INT_TO_BOOL(_INT);
Example:
M0:=
INT_TO_BOOL(D0);
D0
INT_TO_BOOL_E
EN
_INT
ENO
*1 M0
INT_TO_BOOL_E(EN,_INT,
Output label);
Example:
INT_TO_BOOL_E(X000,D0,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Bit data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
Bit
Bit
Explanation of function and operation
This function converts word [signed] data stored in a device specified in s 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".
into bit data, and outputs the
0 FALSE
1567
Word [signed] data
TRUE
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
Program example
In this program, word [signed] data stored in a device specified in obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(INT_TO_BOOL) s
is converted into bit data, and the data
[Structured ladder] g_int1=5923
INT_TO_BOOL
_INT g_bool1
[ST] g_bool1 := INT_TO_BOOL(g_int1);
2) Function with EN/ENO(INT_TO_BOOL_E)
[Structured ladder] g_bool1 g_int1
INT_TO_BOOL_E
EN ENO
_INT g_bool3 g_bool2
[ST] g_bool3 := INT_TO_BOOL_E(g_bool1, g_int1, g_bool2);
1
2
3
4
5
6
A
53
FXCPU Structured Programming Manual
(Application Functions)
5.1.10 DINT_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_BOOL
DINT_TO_BOOL_
E
Label
X000
Label
Expression in each language
Structured ladder
DINT_TO_BOOL
_DINT *1 M0
ST
DINT_TO_BOOL(_DINT);
Example:
M0:=
DINT_TO_BOOL(Label);
DINT_TO_BOOL_E
EN
_DINT
ENO
*1 M0
DINT_TO_BOOL_E(EN,_DINT,
Output label);
Example:
DINT_TO_BOOL_E(X000, Label,
M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Bit data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Double Word [signed]
Bit
Bit
Explanation of function and operation
This function converts double word [signed] data stored in a device specified in 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".
s
into bit data, and outputs
0 FALSE
12345678 TRUE
Double word [signed] data 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.
54
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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
.
1) Function without EN/ENO(DINT_TO_BOOL) s
is converted into bit data, and
[Structured ladder]
DINT_TO_BOOL g_dint1=0 _DINT g_bool1
[ST] g_bool1 := DINT_TO_BOOL(g_dint1);
2) Function with EN/ENO(DINT_TO_BOOL_E)
[Structured ladder] g_bool1 DINT_TO_BOOL_E
EN ENO g_dint1 _DINT g_bool3 g_bool2
[ST] g_bool3 := DINT_TO_BOOL_E(g_bool1, g_dint1, g_bool2);
1
2
3
4
5
6
A
55
FXCPU Structured Programming Manual
(Application Functions)
5.1.11 INT_TO_REAL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts word [signed] data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_REAL
INT_TO_REAL_E
X000
D0
Expression in each language
Structured ladder
INT_TO_REAL a_Int *1 Label
ST
INT_TO_REAL(a_Int);
Example:
Label:=
INT_TO_REAL(D0);
D0
INT_TO_REAL_E
EN a_Int
ENO
*1 Label
INT_TO_REAL_E(EN,a_Int,
Output label);
Example:
INT_TO_REAL_E(X000,D0,Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN a_Int (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Float (single precision) data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
Bit
FLOAT (Single Precision)
Explanation of function and operation
This function converts word [signed] data stored in a device specified in and outputs the data obtained by conversion to a device specified in d
.
s
into float (single precision) data,
1234 1234.0
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 FX
3G
Series Ver.1.10 or later.
56
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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] g_int1=5923
INT_TO_REAL a_Int
[ST] g_real1=5923.0
g_real1 := INT_TO_REAL(g_int1);
2) Function with EN/ENO(INT_TO_REAL_E)
[Structured ladder] g_bool1 g_int1
INT_TO_REAL_E
EN ENO a_Int g_bool3 g_real1
[ST] g_bool3 := INT_TO_REAL_E(g_bool1, g_int1, g_real1);
1
2
3
4
5
6
A
57
FXCPU Structured Programming Manual
(Application Functions)
5.1.12 DINT_TO_REAL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_REAL
DINT_TO_REAL_
E
Label 1
X000
Label 1
Expression in each language
Structured ladder
DINT_TO_REAL a_Dint *1 Label 2
ST
DINT_TO_REAL(a_Dint);
Example:
Label 2:=
DINT_TO_REAL(Label 1);
DINT_TO_REAL_E
EN a_Dint
ENO
*1 Label 2
DINT_TO_REAL_E(EN,a_Dint,
Output label);
Example:
DINT_TO_REAL_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN a_Dint (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Float (single precision) data after conversion
Data type
Bit
Double Word [signed]
Bit
FLOAT (Single Precision)
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 precision) data, and outputs the data obtained by conversion to a device specified in d s
.
into float (single
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 FX
3G
Series Ver.1.10 or later.
58
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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)
[Structured ladder]
DINT_TO_REAL g_dint1=65000 a_Dint g_real1=65000.0
[ST] g_real1 := DINT_TO_REAL(g_dint1);
2) Function with EN/ENO(DINT_TO_REAL_E)
[Structured ladder] g_bool1 DINT_TO_REAL_E
EN ENO g_dint1 a_Dint g_bool3 g_real1
[ST] g_bool3 := DINT_TO_REAL_E(g_bool1, g_dint1, g_real1);
1
2
3
4
5
6
A
59
FXCPU Structured Programming Manual
(Application Functions)
5.1.13 INT_TO_STR(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
60
Outline
This function converts word [signed] data into string data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_STR
INT_TO_STR_E
X000
D0
D0
Expression in each language
Structured ladder
INT_TO_STR
_INT *1 Label
ST
INT_TO_STR(_INT);
Example:
Label:=
INT_TO_STR(D0);
INT_TO_STR_E
EN
_INT
ENO
*1 Label
INT_TO_STR_E(EN,_INT,
Output label);
Example:
INT_TO_STR_E(X000, D0, Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source word [signed] data
Execution status
String data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
Bit
String
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
.
s
Word [signed] data
into string data, and outputs
High-order byte Low-order byte
ASCII code for ten-thousands place Sign data
ASCII code for hundreds place ASCII code for thousands place
String
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
High-order byte
20H (space)
31H (1)
33H (3)
Low-order byte
2DH (-)
20H (space)
32H (2)
Word [signed] data
0000H
4) "00H" is automatically stored at the end (4th word) of the character string.
String 1st word
2nd word
3rd word
4th word
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.
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
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 string data storage destination (device specified in exceeds the range of the corresponding device
(Error code: K6706) d
)
Program example
In this program, word [signed] data stored in a device specified in data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(INT_TO_STR) s
is converted into string data, and the
[Structured ladder]
INT_TO_STR g_int1=-12345 _INT g_string='-12345'
[ST] g_string1 := INT_TO_STR(g_int1);
2) Function with EN/ENO(INT_TO_STR_E)
[Structured ladder] g_bool1 g_int1
INT_TO_STR_E
EN ENO
_INT g_bool3 g_string1
[ST] g_bool3 := INT_TO_STR_E(g_bool1, g_int1, g_string1);
1
2
3
4
5
6
A
61
FXCPU Structured Programming Manual
(Application Functions)
5.1.14 DINT_TO_STR(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into string data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_STR
DINT_TO_STR_E
Label 1
X000
Label 1
DINT_TO_STR
_DINT
Expression in each language
Structured ladder
*1 Label 2
ST
DINT_TO_STR(_DINT);
Example:
Label 2:=
DINT_TO_STR(Label 1);
DINT_TO_STR_E
EN
_DINT
ENO
*1 Label 2
DINT_TO_STR_E(EN,_DINT,
Output label);
Example:
DINT_TO_STR_E(X000,
Label 1, Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
String data after conversion
Data type
Bit
Double Word [signed]
Bit
String
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
ASCII code for billions place
Low-order byte
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
00H
ASCII code for hundreds place
ASCII code for ones place
String 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
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.
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 string data storage destination (device specified in exceeds the range of the corresponding device
(Error code: K6706) d
)
Program example
In this program, double word [signed] data stored in a device specified in and the data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(DINT_TO_STR)
[Structured ladder] s
is converted into string data,
DINT_TO_STR g_dint1=-12345678 _DINT g_string1='-12345678'
[ST] g_string1 := DINT_TO_STR(g_dint1);
2) Function with EN/ENO(DINT_TO_STR_E)
[Structured ladder] g_bool1 DINT_TO_STR_E
EN ENO g_dint1 _DINT
[ST] g_bool3 g_string1 g_bool3 := DINT_TO_STR_E(g_bool1, g_dint1, g_string1);
1
2
3
4
5
6
A
63
FXCPU Structured Programming Manual
(Application Functions)
5.1.15 INT_TO_WORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
INT_TO_WORD
INT_TO_WORD_
E
X000
D0
Expression in each language
Structured ladder
INT_TO_WORD
_INT *1 D10
ST
INT_TO_WORD(_INT);
Example:
D10:=
INT_TO_WORD(D0);
D0
INT_TO_WORD_E
EN
_INT
ENO
*1 D10
INT_TO_WORD_E(EN,_INT,
Output label);
Example:
INT_TO_WORD_E(X000,D0,D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Word [unsigned]/Bit String [16-bit] data after conversion
Data type
Bit
Word [signed]
Bit
Word [unsigned]/
Bit String [16-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
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
Program example
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)
[Structured ladder]
INT_TO_WORD g_int1=5923 _INT g_word1=16#1723
[ST] g_word1 := INT_TO_WORD(g_int1);
2) Function with EN/ENO(INT_TO_WORD_E)
[Structured ladder] g_bool1 g_int1
INT_TO_WORD_E
EN ENO
_INT g_bool3 g_word1
[ST] g_bool3 := INT_TO_WORD_E(g_bool1, g_int1, g_word1);
1
2
3
4
5
6
A
65
FXCPU Structured Programming Manual
(Application Functions)
5.1.16 DINT_TO_WORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
DINT_TO_WORD
DINT_TO_WORD
_E
Label
X000
Label
Expression in each language
Structured ladder
DINT_TO_WORD
_DINT *1 D10
ST
DINT_TO_WORD(_DINT);
Example:
D10:=
DINT_TO_WORD(Label);
DINT_TO_WORD_E
EN
_DINT
ENO
*1 D10
DINT_TO_WORD_E(EN,_DINT,
Output label);
Example:
DINT_TO_WORD_E(X000, Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Word [unsigned]/bit string [16-bit] data after conversion
Data type
Bit
Double Word [signed]
Bit
Word [unsigned]/
Bit String [16-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 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 1 1 0 0 0 0 1 0 1 0 0 1 1 1 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
Program example
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)
[Structured ladder]
DINT_TO_WORD g_dint1=12345678 _DINT g_word1=16#614E
[ST] g_word1 := DINT_TO_WORD(g_dint1);
2) Function with EN/ENO(DINT_TO_WORD_E)
[Structured ladder] g_bool1 DINT_TO_WORD_E
EN ENO g_dint1 _DINT g_bool3 g_word1
[ST] g_bool3 := DINT_TO_WORD_E(g_bool1, g_dint1, g_word1);
1
2
3
4
5
6
A
67
FXCPU Structured Programming Manual
(Application Functions)
5.1.17 INT_TO_DWORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
INT_TO_DWORD
INT_TO_DWORD
_E
X000
D0
D0
Expression in each language
Structured ladder
INT_TO_DWORD
_INT *1 Label
ST
INT_TO_DWORD(_INT);
Example:
Label:=
INT_TO_DWORD(D0);
INT_TO_DWORD_E
EN
_INT
ENO
*1 Label
INT_TO_DWORD_E(EN,_INT,
Output label);
Example:
INT_TO_DWORD_E(X000,D0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Double word [unsigned]/bit string [32-bit] data after conversion
Data type
Bit
Word [signed]
Bit
Double Word [unsigned]/
Bit string [32-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
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 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 1
Data conversion
0000FEBBH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 1
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
Program example
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)
[Structured ladder]
INT_TO_DWORD g_int1=10 _INT g_dword1=16#0000000A
[ST] g_dword1 := INT_TO_DWORD(g_int1);
2) Function with EN/ENO(INT_TO_DWORD_E)
[Structured ladder] g_bool1 g_int1
INT_TO_DWORD_E
EN ENO
_INT g_bool3 g_dword1
[ST] g_bool3 := INT_TO_DWORD_E(g_bool1, g_int1, g_dword1);
1
2
3
4
5
6
A
69
FXCPU Structured Programming Manual
(Application Functions)
5.1.18 DINT_TO_DWORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
DINT_TO_DWOR
D
DINT_TO_DWOR
D_E
Label 1
Expression in each language
Structured ladder
DINT_TO_DWORD
_DINT *1 Label 2
ST
DINT_TO_DWORD(_DINT);
Example:
Label 2:=
DINT_TO_DWORD(Label 1);
X000
Label 1
DINT_TO_DWORD_E
EN
_DINT
ENO
*1 Label 2
DINT_TO_DWORD_E(EN,_DINT,
Output label);
Example:
DINT_TO_DWORD_E(X000,
Label 1, Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Double word [unsigned]/bit string [32-bit] data after conversion
Data type
Bit
Double Word [signed]
Bit
Double Word [unsigned]/
Bit string [32-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 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
Program example
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)
[Structured ladder]
DINT_TO_DWORD g_dint1=74565 _DINT g_dword1=16#00012345
[ST] g_dword1 := DINT_TO_DWORD(g_dint1);
2) Function with EN/ENO(DINT_TO_DWORD_E)
[Structured ladder] g_bool1 g_dint1
DINT_TO_DWORD_E
EN ENO
_DINT g_bool3 g_dword1
[ST] g_bool3 := DINT_TO_DWORD_E(g_bool1, g_dint1, g_dword1);
1
2
3
4
5
6
A
71
FXCPU Structured Programming Manual
(Application Functions)
5.1.19 INT_TO_BCD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_BCD
INT_TO_BCD_E
X000
D0
Expression in each language
Structured ladder
INT_TO_BCD
_INT *1 D10
ST
INT_TO_BCD(_INT);
Example:
D10:=
INT_TO_BCD(D0);
D0
INT_TO_BCD_E
EN
_INT
ENO
*1 D10
INT_TO_BCD_E(EN,_INT,
Output label);
Example:
INT_TO_BCD_E(X000,D0,D10);
*1.
Output variable
2. Set data
Input variable
Variable
EN
_INT (
ENO s
)
Output variable
*1 ( d
)
Description
Execution condition
Conversion source word [signed] data
Execution status
BCD data after conversion
Data type
Bit
Word [signed]
Bit
Word [unsigned]/
Bit String [16-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
.
s
into BCD data, and outputs the
9999 9999H
Word [signed] data Word [unsigned]/ bit string [16-bit] data
9999
32768 16384 8192 4096 2048 1024
0 0
512 256 128 64 32 16 8 4 2 1
1 0 0 1 1 1 0 0 0 0 1 1 1 1
9999H
Make sure to set them to "0".
8000 4000 2000 1000 800 400 200 100 80 40
Conversion into BCD data
20 10 8 4 2 1
1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Thousands place Hundreds place 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".
s
is outside the range from "0" to
72
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [signed] data stored in a device specified in data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(INT_TO_BCD) s
is converted into BCD data, and the
[Structured ladder]
INT_TO_BCD g_int1=5923 _INT g_word=16#5923
[ST] g_word1 := INT_TO_BCD(g_int1);
2) Function with EN/ENO(INT_TO_BCD_E)
[Structured ladder] g_bool1 g_int1
EN
INT_TO_BCD_E
ENO
_INT g_bool3 g_word1
[ST] g_bool3 := INT_TO_BCD_E(g_bool1, g_int1, g_word1);
1
2
3
4
5
6
A
73
FXCPU Structured Programming Manual
(Application Functions)
5.1.20 DINT_TO_BCD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_BCD
DINT_TO_BCD_E
Label 1
X000
Label 1
DINT_TO_BCD
_DINT
Expression in each language
Structured ladder
*1 Label 2
ST
DINT_TO_BCD(_DINT);
Example:
Label 2:=
DINT_TO_BCD(Label 1);
DINT_TO_BCD_E
EN
_DINT
ENO
*1 Label 2
DINT_TO_BCD_E(EN,_DINT,
Output label);
Example:
DINT_TO_BCD_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
BCD data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Double Word [signed]
Bit
ANY_BIT
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
.
s
into BCD data, and
99999999 99999999H
Double word [signed] data ANY_BIT data
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
Make sure to set them to "0".
Conversion into BCD data
74
99999999H 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Ten-millions place
Millions place
Hundredthousands
TenThousands Hundreds 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.
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Error
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
In this program, double word [signed] data stored in a device specified in and the data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(DINT_TO_BCD) s
is converted into BCD data,
[Structured ladder]
DINT_TO_BCD g_dint1=20000 _DINT g_dword1=16#00020000
[ST] g_dword1 := DINT_TO_BCD(g_dint1);
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
[ST] g_bool3 := DINT_TO_BCD_E(g_bool1, g_dint1, g_dword1);
1
2
3
4
5
6
A
75
FXCPU Structured Programming Manual
(Application Functions)
5.1.21 INT_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Function name
INT_TO_TIME
INT_TO_TIME_E
X000
D0
D0
Expression in each language
Structured ladder
INT_TO_TIME
_INT *1 Label
ST
INT_TO_TIME(_INT);
Example:
Label:=
INT_TO_TIME(D0);
INT_TO_TIME_E
EN
_INT
ENO
*1 Label
INT_TO_TIME_E(EN,_INT,
Output label);
Example:
INT_TO_TIME_E(X000,D0,Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_INT (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source word [signed] data
Execution status
Time data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
Bit
Time
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
.
s
into time data, and outputs the
FFFFh 1m5s535ms
Word [signed] data Time 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.
76
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, word [signed] data stored in a device specified in data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(INT_TO_TIME) s
is converted into time data, and the
[Structured ladder]
INT_TO_TIME g_int1 _INT g_time1
[ST] g_time1 := INT_TO_TIME(g_int1);
2) Function with EN/ENO(INT_TO_TIME_E)
[Structured ladder] g_bool1 INT_TO_TIME_E
EN ENO g_int1 _INT g_bool3 g_time1
[ST] g_bool3 := INT_TO_TIME_E(g_bool1, g_int1, g_time1);
1
2
3
4
5
6
A
77
FXCPU Structured Programming Manual
(Application Functions)
5.1.22 DINT_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts double word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Function name
DINT_TO_TIME
DINT_TO_TIME_
E
Label 1
X000
Label 1
Expression in each language
Structured ladder
DINT_TO_TIME
_DINT *1 Label 2
ST
DINT_TO_TIME(_DINT);
Example:
Label 2:=
DINT_TO_TIME(Label 1);
DINT_TO_TIME_E
EN
_DINT
ENO
*1 Label 2
DINT_TO_TIME_E(EN,_DINT,
Output label);
Example:
DINT_TO_TIME_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_DINT (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source double word [signed] data
Execution status
Time data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Double Word [signed]
Bit
Time
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
.
s
into time data, and
7FFFFFFFh 24d20h31m23s647ms
Double word [signed] data Time 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.
78
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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
.
1) Function without EN/ENO(DINT_TO_TIME) s
is converted into time data, and
[Structured ladder]
DINT_TO_TIME g_dint1 _DINT g_time1
[ST] g_time1 := DINT_TO_TIME(g_dint1);
2) Function with EN/ENO(DINT_TO_TIME_E)
[Structured ladder] g_bool1 DINT_TO_TIME_E
EN ENO g_dint1 _DINT g_bool3 g_time1
[ST] g_bool3 := DINT_TO_TIME_E(g_bool1, g_dint1, g_time1);
1
2
3
4
5
6
A
79
FXCPU Structured Programming Manual
(Application Functions)
5.1.23 REAL_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts float (single precision) data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
REAL_TO_INT
REAL_TO_INT_E
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN a_real (
ENO
*1 ( s
) d
)
Label
Expression in each language
Structured ladder
REAL_TO_INT a_real *1 D10
ST
REAL_TO_INT(a_real);
Example:
D10:=
REAL_TO_INT(Label);
X000 REAL_TO_INT_E
EN ENO
Label a_real *1 D10
REAL_TO_INT_E(EN,a_real,
Output label);
Example:
REAL_TO_INT_E(X000, Label,
D10);
Description
Execution condition
Conversion source float (single precision) data
Execution status
Word [signed] data after conversion
Data type
Bit
FLOAT (Single Precision)
Bit
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
.
s
into word [signed] data,
1234.0
1234
Float (single precision) data Word [signed] data
The portion after the decimal point is rounded off.
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 FX
3G
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
Program example
In this program, float (single precision) data stored in a device specified in s
[signed] data, and the data obtained by conversion is output to a device specified in
is converted into word d
.
1) Function without EN/ENO(REAL_TO_INT)
[Structured ladder]
REAL_TO_INT g_real1=5923.5
a_real g_int1=5923
[ST] g_int1 := REAL_TO_INT(g_real1);
2) Function with EN/ENO(REAL_TO_INT_E)
[Structured ladder] g_bool1 REAL_TO_INT_E
EN ENO g_real1 a_real g_bool3 g_int1
[ST] g_bool3 := REAL_TO_INT_E(g_bool1, g_real1, g_int1);
1
2
3
4
5
6
A
81
FXCPU Structured Programming Manual
(Application Functions)
5.1.24 REAL_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts float (single precision) data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
REAL_TO_DINT
REAL_TO_DINT_
E
Label 1
X000
Label 1
Expression in each language
Structured ladder
REAL_TO_DINT a_real *1 Label 2
ST
REAL_TO_DINT(a_real);
Example:
Label 2:=
REAL_TO_DINT(Label 1);
REAL_TO_DINT_E
EN a_real
ENO
*1 Label 2
REAL_TO_DINT_E(EN,a_real,
Output label);
Example:
REAL_TO_DINT_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN a_real (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source float (single precision) data
Execution status
Double word [signed] data after conversion
Data type
Bit
FLOAT (Single Precision)
Bit
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
[signed] data, and outputs the data obtained by conversion to a device specified in d
.
s
into double word
16543521.0
16543521
FLOAT (single precision) data Double word [signed] data
The portion after the decimal point is rounded off.
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 FX 3G 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
Program example
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)
[Structured ladder]
REAL_TO_DINT g_real1=65000.5
a_real g_dint1=65000
[ST] g_dint1 := REAL_TO_DINT(g_real1);
2) Function with EN/ENO(DINT_TO_TIME_E)
[Structured ladder] g_bool1 REAL_TO_DINT_E
EN ENO g_real1 a_real g_bool3 g_dint1
[ST] g_bool3 := REAL_TO_DINT_E(g_bool1, g_real1, g_dint1);
1
2
3
4
5
6
A
83
FXCPU Structured Programming Manual
(Application Functions)
5.1.25 REAL_TO_STR(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts float (single precision) data into string data, and outputs the data obtained by conversion.
1. Format
Function name
REAL_TO_STR
REAL_TO_STR_E
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_REAL (
ENO
*1 ( s
) d
)
Label 1
X000
Label 1
Expression in each language
Structured ladder
REAL_TO_STR
_REAL *1 Label 2
ST
REAL_TO_STR(_REAL);
Example:
Label 2:=
REAL_TO_STR(Label 1);
REAL_TO_STR_E
EN
_REAL
ENO
*1 Label 2
REAL_TO_STR_E(EN,_REAL,
Output label);
Example:
REAL_TO_STR_E(X000, Label 1,
Label 2);
Description
Execution condition
Conversion source float (single precision) data
Execution status
String data after conversion
Data type
Bit
FLOAT (Single Precision)
Bit
String
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
(exponent) data, and outputs the data obtained by conversion to a device specified in d
High-order byte Low-order byte
Float
(single precision) data
20H (space) Sign data (integer part)
.
s
String
.
Sign
(integer part)
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
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
into string
1st word
2nd word
3rd word
4th word
5th word
6th word
7th word
Automatically stored at the end of the character string
84
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
1
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.
Total number of digits (12 digits)
Integer part
(1 digit)
Decimal part
(5 digits)
Exponent part
(2 digits)
-12.3456
1 . 2 3 4 5 6 E + 0 1
Float (single precision) data
"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.
Total number of digits (12 digits)
-12.345678
- 1 . 2 3 4 5
7
6 7 8 E + 0 1
Float (single precision) data
Number of digits of decimal part (5)
These digits are rounded. d) "30H (0)" is stored in the decimal part when the number of significant figures is small.
Total number of digits (12 digits)
-12.34
- 1 . 2 3 4 0 0 E + 0 1
Float (single precision) data
"30H (0)" is stored.
Number of digits of decimal part (5) 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.
Total number of digits (12 digits)
-12.3456
Number of digits of exponent part (2)
- 1 . 2 3 4 5 6 E + 0 1
Float (single precision) data
"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.
2
3
4
5
6
A
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
0, ±2
-126 ≤ (Value of device specified in
(Error code: K6706) s s
is outside the following range:
) ≤ ±2 128
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 and the data obtained by conversion is output to a device specified in d
.
1) Function without EN/ENO(REAL_TO_STR) s
is converted into string data,
[Structured ladder]
REAL_TO_STR g_real1=-12.34567
_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 REAL_TO_STR_E
EN ENO g_real1 _REAL g_bool3 g_string1
[ST] g_bool3 := REAL_TO_STR_E(g_bool1, g_real1, g_string1);
86
FXCPU Structured Programming Manual
(Application Functions)
5.1.26 WORD_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts word [unsigned]/bit string [16-bit] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
WORD_TO_BOO
L
WORD_TO_BOO
L_E
X000
D0
D0
Expression in each language
Structured ladder
WORD_TO_BOOL
_WORD *1 M0
ST
WORD_TO_BOOL(_WORD);
Example:
M0:=
WORD_TO_BOOL(D0);
WORD_TO_BOOL_E
EN
_WORD
ENO
*1 M0
WORD_TO_BOOL_E(EN,
_WORD, Output label);
Example:
WORD_TO_BOOL_E(X000,D0,
M0);
*1.
Output variable
2. Set data
Variable
EN Execution condition
Description
Input variable
Output variable
_WORD ( s
ENO
*1 ( d
)
)
Conversion source word [unsigned]/bit String [16-bit] data
Execution status
Bit data after conversion
Data type
Bit
Word [unsigned]/
Bit String [16-bit]
Bit
Bit
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into bit data,
0H FALSE
1567H TRUE
Word [unsigned]/ bit string [16-bit] data
Bit data
Cautions
Use the function having "_E" in its name to connect a bus.
2
3
4
5
6
A
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) s
is converted into bit
[Structured ladder]
WORD_TO_BOOL g_word1=16#0001 _WORD g_bool1
[ST] g_bool1 := WORD_TO_BOOL(g_word1);
2) Function with EN/ENO(WORD_TO_BOOL_E)
[Structured ladder] g_bool1 WORD_TO_BOOL_E
EN ENO g_word1 _WORD g_bool3 g_bool2
[ST] g_bool3 := WORD_TO_BOOL_E(g_bool1, g_word1, g_bool2);
88
FXCPU Structured Programming Manual
(Application Functions)
5.1.27 DWORD_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts double word [unsigned]/bit string [32-bit] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
DWORD_TO_BO
OL
DWORD_TO_BO
OL_E
Label
X000
Label
Expression in each language
Structured ladder
DWORD_TO_BOOL
_DWORD *1 M0
ST
DWORD_TO_BOOL(_DWORD);
Example:
M0:=
DWORD_TO_BOOL(Label);
DWORD_TO_BOOL_E
EN
_DWORD
ENO
*1 M0
DWORD_TO_BOOL_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_BOOL_E(X000,
Label, M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN Execution condition
Description
_DWORD ( s
) Conversion source double word [unsigned]/bit string [32-bit] data
ENO
*1 ( d
Execution status
) Bit data after conversion
Data type
Bit
Double Word [unsigned]/
Bit string [32-bit]
Bit
Bit
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into
0H FALSE
12345678H TRUE
Double word [unsigned]/ bit string [32-bit] data
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.
2
3
4
5
6
A
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) s
is converted
[Structured ladder]
DWORD_TO_BOOL g_dword1=16#00000001 _DWORD g_bool1
[ST] g_bool1 := DWORD_TO_BOOL(g_dword1);
2) Function with EN/ENO(DWORD_TO_BOOL_E)
[Structured ladder] g_bool1 DWORD_TO_BOOL_E
EN ENO g_dword1 _DWORD g_bool3 g_bool2
[ST] g_bool3 := DWORD_TO_BOOL_E(g_bool1, g_dword1, g_bool2);
90
FXCPU Structured Programming Manual
(Application Functions)
5.1.28 WORD_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts word [unsigned]/bit string [16-bit] data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
WORD_TO_INT
WORD_TO_INT_
E
X000
D0
D0
Expression in each language
Structured ladder
WORD_TO_INT
_WORD *1 D10
ST
WORD_TO_INT(_WORD);
Example:
D10:=
WORD_TO_INT(D0);
WORD_TO_INT_E
EN
_WORD
ENO
*1 D10
WORD_TO_INT_E(EN,_WORD,
Output label);
Example:
WORD_TO_INT_E(X000,D0,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_WORD ( s
ENO
*1 ( d
)
)
Execution condition
Description
Conversion source word [unsigned]/bit string [16-bit] data
Execution status
Word [signed] data after conversion
Data type
Bit
Word [unsigned]/
Bit String [16-bit]
Bit
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into word
5678H 22136
Word [unsigned]/ bit string [16-bit] data
Word [signed] data
Cautions
Use the function having "_E" in its name to connect a bus.
2
3
4
5
6
A
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 word [signed] data, and the data obtained by conversion is output to a device specified in
1) Function without EN/ENO(WORD_TO_INT)
is converted into d
.
[Structured ladder]
WORD_TO_INT g_word1=16#000A _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.1.29 WORD_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts word [unsigned]/bit string [16-bit] data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
WORD_TO_DINT
WORD_TO_DINT
_E
X000
D0
D0
Expression in each language
Structured ladder
WORD_TO_DINT
_WORD *1 Label
ST
WORD_TO_DINT(_WORD);
Example:
Label:=
WORD_TO_DINT(D0);
WORD_TO_DINT_E
EN
_WORD
ENO
*1 Label
WORD_TO_DINT_E(EN,_WORD,
Output label);
Example:
WORD_TO_DINT_E(X000,D0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_WORD ( s
ENO
*1 ( d
)
)
Execution condition
Description
Conversion source word [unsigned]/bit string [16-bit] data
Execution status
Double word [signed] data after conversion
Data type
Bit
Word [unsigned]/
Bit String [16-bit]
Bit
Double Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data storeds in a device specified in word [signed] data, and outputs the data obtained by conversion to a device specified in d
.
s
into double
5678H 22136
Word [unsigned]/ bit string [16-bit] data
Double word [signed] data
5678H
22136
0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
Data conversion
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
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.
2
3
4
5
6
A
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]
WORD_TO_DINT g_word1=16#1234 _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.1.30 DWORD_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts double word [unsigned]/bit string [32-bit] data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
DWORD_TO_INT
DWORD_TO_INT
_E
Label
X000
Label
Expression in each language
Structured ladder
DWORD_TO_INT
_DWORD *1 D10
ST
DWORD_TO_INT(_DWORD);
Example:
D10:=
DWORD_TO_INT(Label);
DWORD_TO_INT_E
EN
_DWORD
ENO
*1 D10
DWORD_TO_INT_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_INT_E(X000,Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN Execution condition
Description
_DWORD ( s
) Conversion source double word [unsigned]/bit string [32-bit] data
ENO
*1 ( d
Execution status
) Word [signed] data after conversion
Data type
Bit
Double Word [unsigned]/
Bit string [32-bit]
Bit
Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into
BC614EH 24910
BC614EH
Double word [unsigned]/ bit string [32-bit] data
Word [signed] data
0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
24910 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0
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.
2
3
4
5
6
A
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 into word [signed] data, and the data obtained by conversion is output to a device specified in s d
is converted
.
1) Function without EN/ENO(DWORD_TO_INT)
[Structured ladder]
DWORD_TO_INT g_dword1=16#00012345 _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 DWORD_TO_INT_E
EN ENO g_dword1 _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.1.31 DWORD_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
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
Function name
DWORD_TO_DIN
T
DWORD_TO_DIN
T_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
DWORD_TO_DINT
_DWORD *1 Label 2
ST
DWORD_TO_DINT(_DWORD);
Example:
Label 2:=
DWORD_TO_DINT(Label 1);
DWORD_TO_DINT_E
EN
_DWORD
ENO
*1 Label 2
DWORD_TO_DINT_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_DINT_E(X000,
Label 1, Label 2);
*1.
Output variable
2. Set data
Variable
EN Execution condition
Description
Input variable
Output variable
_DWORD ( s
) Conversion source double word [unsigned]/bit string [32-bit] data
ENO
*1 ( d
Execution status
) Double word [signed] data after conversion
Data type
Bit
Double Word [unsigned]/
Bit string [32-bit]
Bit
Double Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts double word [unsigned]/bit string [32-bit] data stored in a device specified in double word [signed] data, and outputs the data obtained by conversion to a device specified in d
.
s
into
BC614EH 12345678
Double word [unsigned]/ bit string [32-bit] data
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.
2
3
4
5
6
A
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]
DWORD_TO_DINT g_dword1=16#00012345 _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 DWORD_TO_DINT_E
EN ENO g_dword1 _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.1.32 WORD_TO_DWORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
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
Function name
WORD_TO_DWO
RD
WORD_TO_DWO
RD_E
X000
D0
D0
Expression in each language
Structured ladder
WORD_TO_DWORD
_WORD *1 Label
ST
WORD_TO_DWORD(_WORD);
Example:
Label:=
WORD_TO_DWORD(D0);
WORD_TO_DWORD_E
EN
_WORD
ENO
*1 Label
WORD_TO_DWORD_E(EN,
_WORD, Output label);
Example:
WORD_TO_DWORD_E(X000,D0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_WORD ( s
ENO
)
*1 ( d
)
Execution condition
Description
Conversion source word [unsigned]/bit string [16-bit] data
Execution status
Double word[unsigned]/bit string[32-bit] data after conversion
Data type
Bit
Word [unsigned]/
Bit String [16-bit]
Bit
Double Word [unsigned]/
Bit string [32-bit]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts word [unsigned]/bit string [16-bit] data stored in a device specified in s word [unsigned]/bit [32-bit] data, and outputs the data obtained by conversion to a device specified in
Each of high-order 16 bits becomes "0" after data conversion.
into double d
.
5678H 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.
2
3
4
5
6
A
99
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]
WORD_TO_DWORD g_word1=16#1234 _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.1.33 DWORD_TO_WORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
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
Function name
DWORD_TO_WO
RD
DWORD_TO_WO
RD_E
Label
X000
Label
Expression in each language
Structured ladder
DWORD_TO_WORD
_DWORD *1 D10
ST
DWORD_TO_WORD(_DWORD);
Example:
D10:=
DWORD_TO_WORD(Label);
DWORD_TO_WORD_E
EN
_DWORD
ENO
*1 D10
DWORD_TO_WORD_E(EN,
_DWORD, Output label);
Example:
DWORD_TO_WORD_E(X000,
Label, D10);
*1.
Output variable
2. Set data
Variable
EN
Input variable
Output variable
Execution condition
Description
_DWORD ( s
) Conversion source double word [unsigned]/bit string [32-bit] data
ENO Execution status
*1 ( d
) Word [unsigned]/bit string [16-bit] data after conversion
Data type
Bit
Double Word [unsigned]
/Bit string [32-bit]
Bit
Word [unsigned]/
Bit String [16-bit]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
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
.
12345678H 5678H
Double word [unsigned]/ bit string [32-bit] data
Word [unsigned]/ bit string [16-bit] data
12345678H
1 2 3 4 5 6 7 8
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
5678H 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0
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.
2
3
4
5
6
A
101
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]
DWORD_TO_WORD g_dword1=16#12345678 _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 DWORD_TO_WORD_E
EN ENO g_dword1 _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.1.34 WORD_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts word [unsigned]/bit string [16-bit] data into time data, and outputs the data obtained by conversion.
1. Format
Function name
WORD_TO_TIME
WORD_TO_TIME
_E
X000
D0
D0
Expression in each language
Structured ladder
WORD_TO_TIME
_WORD *1 Label
ST
WORD_TO_TIME(_WORD);
Example:
Label:=
WORD_TO_TIME(D0);
WORD_TO_TIME_E
EN
_WORD
ENO
*1 Label
WORD_TO_TIME_E(EN,_WORD,
Output label);
Example:
WORD_TO_TIME_E(X000,D0,
Label);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_WORD ( s
ENO
*1 ( d
)
)
Execution condition
Description
Conversion source word [unsigned]/bit string [16-bit] data
Execution status
Time data after conversion
Data type
Bit
Word [unsigned]/
Bit String[ 16-bit]
Bit
Time
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into time
0 0ms
1234 1s234ms
Word [unsigned]/ bit string [16-bit] data
Time 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.
2
3
4
5
6
A
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) s
is converted into
[Structured ladder]
WORD_TO_TIME g_word1 _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
FXCPU Structured Programming Manual
(Application Functions)
5.1.35 DWORD_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts double word [unsigned]/bit string [32-bit] data into time data, and outputs the data obtained by conversion.
1. Format
Function name
DWORD_TO_TIM
E
DWORD_TO_TIM
E_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
DWORD_TO_TIME
_DWORD *1 Label 2
ST
DWORD_TO_TIME(_DWORD);
Example:
Label 2:=
DWORD_TO_TIME(Label 1);
DWORD_TO_TIME_E
EN
_DWORD
ENO
*1 Label 2
DWORD_TO_TIME_E(EN,_
DWORD, Output label);
Example:
DWORD_TO_TIME_E(X000,
Label 1, Label 2);
*1.
Output variable
2. Set data
Variable
EN Execution condition
Description
Input variable
Output variable
_DWORD ( s
) Conversion source double word [unsigned]/bit string [32-bit] data
ENO
*1 ( d
Execution status
) Time data after conversion
Data type
Bit
Double Word [unsigned]/
Bit string [32-bit]
Bit
Time
In explanation of functions, I/O variables inside ( ) are described.
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
.
s
into
0 0ms
1234567 20m34s567ms
Double word [unsigned]/ bit string [32-bit] data
Time 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.
2
3
4
5
6
A
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) s
is converted
[Structured ladder]
DWORD_TO_TIME g_dword1 _DWORD g_time1
[ST] g_time1 := DWORD_TO_TIME(g_dword1);
2) Function with EN/ENO(DWORD_TO_TIME_E)
[Structured ladder] g_bool1 DWORD_TO_TIME_E
EN ENO g_dword1 _DWORD g_bool3 g_time1
[ST] g_bool3 := DWORD_TO_TIME_E(g_bool1, g_dword1, g_time1);
106
FXCPU Structured Programming Manual
(Application Functions)
5.1.36 STR_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts string data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
STR_TO_BOOL
STR_TO_BOOL_
E
Label
X000
Label
Expression in each language
Structured ladder
STR_TO_BOOL
_STRING *1 M0
ST
STR_TO_BOOL(_STRING);
Example:
M0:=
STR_TO_BOOL(Label);
STR_TO_BOOL_E
EN
_STRING
ENO
*1 M0
STR_TO_BOOL_E(EN,_STRING,
Output label);
Example:
STR_TO_BOOL_E(X000, Label,
M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_STRING (
ENO
*1 ( s d
Description
Execution condition
) Conversion source string data
Execution status
) Bit data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Bit
String
Bit
Bit
Data type
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
.
s
into bit data, and outputs the data
'0' FALSE
'12'
String data
TRUE
Bit data
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.
2
3
4
5
6
A
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) s
is converted into bit data, and the data
[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
EN
STR_TO_BOOL_E
ENO g_string1 _STRING g_bool3 g_bool2
[ST] g_bool3 := STR_TO_BOOL_E(g_bool1, g_string1, g_bool2);
108
FXCPU Structured Programming Manual
(Application Functions)
5.1.37 STR_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts string data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
STR_TO_INT
STR_TO_INT_E
Label
X000
Label
STR_TO_INT
_STRING
Expression in each language
Structured ladder
*1 D10
ST
STR_TO_INT(_STRING);
Example:
D10:=
STR_TO_INT(Label);
EN
STR_TO_INT_E
_STRING
ENO
*1 D10
STR_TO_INT_E(EN,_STRING,
Output label);
Example:
STR_TO_INT_E(X000, Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_STRING (
ENO
*1 ( s d
Description
Execution condition
) Conversion source string data
Execution status
) Word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
String
Bit
Word [signed]
Explanation of function and operation
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
.
s
into word [signed] data, and
String 1st word
2nd word
3rd word
High-order byte
ASCII code for ten-thousands place
Low-order byte
Sign data
ASCII code for hundreds place ASCII code for thousands place
ASCII code for ones place ASCII code for tens place
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.
2
3
4
5
6
A
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) s
to s s
is any other than
+2 is any other than "30H" to "39H",
3) When the value stored in
-32768 to +32767
(Error code: K6706) s
to s
+2 is outside the following range:
4) When any of devices
(Error code: K6706) s
to s
+2 exceeds the device range
Program example
In this program, string 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(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
EN
STR_TO_INT_E
ENO g_string1 _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.1.38 STR_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts string data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
STR_TO_DINT
STR_TO_DINT_E
Label 1
X000
Label 1
STR_TO_DINT
_STRING
Expression in each language
Structured ladder
*1 Label 2
ST
STR_TO_DINT(_STRING);
Example:
Label 2:=
STR_TO_DINT(Label 1);
STR_TO_DINT_E
EN
_STRING
ENO
*1 Label 2
STR_TO_DINT_E(EN,_STRING,
Output label);
Example:
STR_TO_DINT_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Variable
Input variable
Output variable
EN
_STRING (
ENO
*1 ( s d
Description
Execution condition
) Conversion source string data
Execution status
) Double word [signed] data after conversion
Data type
Bit
String
Bit
Double Word [signed]
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
This function converts string data (6 words) stored in a device specified in data, and outputs the data obtained by conversion to a device specified in d
.
s
String 1st word
2nd word
3rd word
4th word
5th word
6th word
High-order byte
ASCII code for billions place
Low-order byte
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
into double word [signed]
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.
2
3
4
5
6
A
111
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
-2,147,483,648 to +2,147,483,647
(Error code: K6706) s
4) When any of devices
(Error code: K6706) s
to s
+5 is outside the following range:
+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
EN
STR_TO_DINT_E
ENO g_string1 _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.1.39 STR_TO_REAL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function converts string data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name
STR_TO_REAL
STR_TO_REAL_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
STR_TO_REAL
_STRING *1 Label 2
ST
STR_TO_REAL(_STRING);
Example:
Label 2:=
STR_TO_REAL(Label 1);
STR_TO_REAL_E
EN
_STRING
ENO
*1 Label 2
STR_TO_REAL_E(EN,_STRING,
Output label);
Example:
STR_TO_REAL_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_STRING (
ENO
*1 ( s d
Description
Execution condition
) Conversion source string data
Execution status
) Float (single precision) data after conversion
Data type
Bit
String
Bit
FLOAT (Single Precision)
In explanation of functions, I/O variables inside ( ) are described.
Explanation of function and operation
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
String 1st word
2nd word
3rd word
4th word
5th word
6th word
7th word
High-order byte
ASCII code for 1st character
Low-order byte
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 9th character
ASCII code for 6th character
ASCII code for 8th character
ASCII code for 11th character ASCII code for 10th character
0000H (Indicates the end of the character string.)
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)
0000H
- 1 . 3 5 0 3 4
-1.35034
Float (single precision) data
2
3
4
5
6
A
113
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions b) In the case of exponent format
String 1st word
2nd word
3rd word
4th word
5th word
6th word
7th word
High-order byte
31H (1)
33H (3)
30H (0)
34H (4)
2DH (-)
30H (0)
0000H
Low-order byte
2DH (-)
2EH (3)
35H (5)
33H (3)
45H (E)
31H (1)
-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
Discarded b) In the case of exponent format
- 1 . 3 5 0 3 4 1 2 E - 1 0
Float (single precision) data
-1.35034E-10
Discarded
Float (single precision) data
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
Ignored b) In the case of exponent format
-
Float (single precision) data
0 1 . 3 5 0 3 4 E - 1 0 -1.35034E-10
Ignored
Float (single precision) data
7) 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 -1.35034E-2
Ignored 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
Error
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) When "2EH (.)" exists in two or more positions inside the character string specified in
(Error code: K6706) 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)
4) When the number of characters after
(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
.
1) Function without EN/ENO(STR_TO_REAL)
[Structured ladder] g_string1
STR_TO_REAL
_STRING g_real1
[ST] g_real1 := STR_TO_REAL(g_string1);
2) Function with EN/ENO(STR_TO_REAL_E)
[Structured ladder] g_bool1
EN
STR_TO_REAL_E
ENO g_string1 _STRING g_bool3 g_real1
[ST] g_bool3 := STR_TO_REAL_E(g_bool1, g_string1, g_real1);
1
2
3
4
5
6
A
115
FXCPU Structured Programming Manual
(Application Functions)
5.1.40 STR_TO_TIME(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts string data into time data, and outputs the data obtained by conversion.
1. Format
Function name
STR_TO_TIME
STR_TO_TIME_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
STR_TO_TIME
_STRING *1 Label 2
ST
STR_TO_TIME(_STRING);
Example:
Label 2:=
STR_TO_TIME(Label 1);
STR_TO_TIME_E
EN
_STRING
ENO
*1 Label 2
STR_TO_TIME_E(EN,_STRING,
Output label);
Example:
STR_TO_TIME_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_STRING (
ENO
*1 ( s d
Description
Execution condition
) Conversion source string data
Execution status
) Time data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Bit
String
Bit
Time
Data type
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
.
s
into time data, and outputs the data
'0' 0ms
'1234567'
String data
20m34s567ms
Time 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
Error
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 (-)"
2) When the ASCII code for each digit of character string data specified in
"39H (9)", "20H (space)" or "00H (NULL)"
(Error code: K6706) s
is any other than "30H (0)" to
3) When the numeric value specified in
-2,147,483,648 to +2,147,483,647
(Error code: K6706) s
is outside the following range:
Program example
In this program, string data stored in a device specified in obtained by conversion is output to a device specified in d
.
s
1) Function without EN/ENO(STR_TO_TIME)
is converted into time data, and the data
[Structured ladder] g_string1
STR_TO_TIME
_STRING g_time1
[ST] g_time1 := STR_TO_TIME(g_string1);
2) Function with EN/ENO(STR_TO_TIME_E)
[Structured ladder] g_bool1
EN
STR_TO_TIME_E
ENO g_string1 _STRING g_bool3 g_time1
[ST] g_bool3 := STR_TO_TIME_E(g_bool1, g_string1, g_time1);
1
2
3
4
5
6
A
117
FXCPU Structured Programming Manual
(Application Functions)
5.1.41 BCD_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts BCD data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
BCD_TO_INT
BCD_TO_INT_E
X000
D0
D0
BCD_TO_INT
_BCD
Expression in each language
Structured ladder
*1 D10
ST
BCD_TO_INT(_BCD);
Example:
D10:=
BCD_TO_INT(D0);
EN
BCD_TO_INT_E
_BCD
ENO
*1 D10
BCD_TO_INT_E(EN,_BCD,
Output label);
Example:
BCD_TO_INT_E(X000,D0,D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BCD ( s
)
ENO
*1 ( d
)
Description
Execution condition
Conversion source BCD data
Execution status
Word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [unsigned]/
Bit String [16-bit]
Bit
Word [signed]
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
.
s
into word [signed] data, and outputs the
9999H 9999
Word [unsigned]/ bit string [16-bit] data
Word [signed] data
8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1
9999H 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
9999
Thousands place Hundreds place Tens place Ones place
Conversion into word [signed] data
3276516354 8192 4095 2048 1024 512 256 128 64 32 16
0 0 1 0 0 1 1 1 0 0 0 0
8
1
4
1
2
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
Program example
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)
[Structured ladder] g_word1=16#1234
BCD_TO_INT
_BCD g_int1=1234
[ST] g_int1 := BCD_TO_INT(g_word1);
2) Function with EN/ENO(BCD_TO_INT_E)
[Structured ladder] g_bool1
EN
BCD_TO_INT_E
ENO g_word1 _BCD g_bool3 g_int1
[ST] g_bool3 := BCD_TO_INT_E(g_bool1, g_word1, g_int1);
1
2
3
4
5
6
A
119
FXCPU Structured Programming Manual
(Application Functions)
5.1.42 BCD_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts BCD data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
BCD_TO_DINT
BCD_TO_DINT_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
BCD_TO_DINT
_BCD *1 Label 2
ST
BCD_TO_DINT(_BCD);
Example:
Label 2:=
BCD_TO_DINT(Label 1);
BCD_TO_DINT_E
EN
_BCD
ENO
*1 Label 2
BCD_TO_DINT_E(EN,_BCD,
Output label);
Example:
BCD_TO_DINT_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_BCD (
ENO
*1 ( s d
)
)
Description
Execution condition
Conversion source BCD data
Execution status
Double word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_BIT
Bit
Double Word [signed]
Explanation of function and operation
This function converts BCD data stored in a device specified in outputs the data obtained by conversion to a device specified in d s
.
into double word [signed] data, and
99999999H 99999999
ANY_BIT data Double word [signed] data
120
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
Tenmillions place
Millions place
Hundredthousands place
Tenthousands
Thousands Hundreds place place place
Tens place
Conversion into DINT data
Ones 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.
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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)
[Structured ladder] g_word1=16#0000
BCD_TO_DINT
_BCD g_dint1=0
[ST] g_dint1 := BCD_TO_DINT(g_word1);
2) Function with EN/ENO(BCD_TO_DINT_E)
[Structured ladder] g_bool1
EN
BCD_TO_DINT_E
ENO g_word1 _BCD g_bool3 g_dint1
[ST] g_bool3 := BCD_TO_DINT_E(g_bool1, g_word1, g_dint1);
1
2
3
4
5
6
A
121
FXCPU Structured Programming Manual
(Application Functions)
5.1.43 TIME_TO_BOOL(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts time data into bit data, and outputs the data obtained by conversion.
1. Format
Function name
TIME_TO_BOOL
TIME_TO_BOOL_
E
Label
X000
Label
Expression in each language
Structured ladder
TIME_TO_BOOL
_TIME *1 M0
ST
TIME_TO_BOOL(_TIME);
Example:
M0:=
TIME_TO_BOOL(Label);
TIME_TO_BOOL_E
EN
_TIME
ENO
*1 M0
TIME_TO_BOOL_E(EN,_TIME,
Output label);
Example:
TIME_TO_BOOL_E(X000, Label,
M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source time data
Execution status
Bit data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Bit
Time
Bit
Bit
Data type
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
.
s
into bit data, and outputs the data
0ms FALSE
20m34s567ms
Time data
TRUE
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.
122
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, time data stored in a device specified in by conversion is output to a device specified in d
.
1) Function without EN/ENO(TIME_TO_BOOL) s
is converted into bit data, and the data obtained
[Structured ladder] g_time1
TIME_TO_BOOL
_TIME g_bool1
[ST] g_bool1 := TIME_TO_BOOL(g_time1);
2) Function with EN/ENO(TIME_TO_BOOL_E)
[Structured ladder] g_bool1 g_time1
TIME_TO_BOOL_E
EN ENO
_TIME g_bool3 g_bool2
[ST] g_bool3 := TIME_TO_BOOL_E(g_bool1, g_time1, g_bool2);
1
2
3
4
5
6
A
123
FXCPU Structured Programming Manual
(Application Functions)
5.1.44 TIME_TO_INT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts time data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
TIME_TO_INT
TIME_TO_INT_E
Label
X000
Label
TIME_TO_INT
_TIME
Expression in each language
Structured ladder
*1 D10
ST
TIME_TO_INT(_TIME);
Example:
D10:=
TIME_TO_INT(Label);
TIME_TO_INT_E
EN
_TIME
ENO
*1 D10
TIME_TO_INT_E(EN,_TIME,
Output label);
Example:
TIME_TO_INT_E(X000, Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source time data
Execution status
Word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Time
Bit
Word [signed]
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
.
s
into word [signed] data, and outputs the
1s234ms 1234
Time data 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.
124
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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)
[Structured ladder] g_time1
TIME_TO_INT
_TIME g_int1
[ST] g_int1 := TIME_TO_INT(g_time1);
2) Function with EN/ENO(TIME_TO_INT_E)
[Structured ladder] g_bool1 g_time1
TIME_TO_INT_E
EN ENO
_TIME g_bool3 g_int1
[ST] g_bool3 := TIME_TO_INT_E(g_bool1, g_time1, g_int1);
1
2
3
4
5
6
A
125
FXCPU Structured Programming Manual
(Application Functions)
5.1.45 TIME_TO_DINT(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts time data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name
TIME_TO_DINT
TIME_TO_DINT_
E
Label 1
X000
Label 1
Expression in each language
Structured ladder
TIME_TO_DINT
_TIME *1 Label 2
ST
TIME_TO_DINT(_TIME);
Example:
Label 2:=
TIME_TO_DINT(Label 1);
TIME_TO_DINT_E
EN
_TIME
ENO
*1 Label 2
TIME_TO_DINT_E(EN,_TIME,
Output label);
Example:
TIME_TO_DINT_E(X000,Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source time data
Execution status
Double word [signed] data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Time
Bit
Double Word [signed]
Explanation of function and operation
This function converts time data stored in a device specified in outputs the data obtained by conversion to a device specified in d s
.
into double word [signed] data, and
20m34s567ms 1234567
Time data 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.
126
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
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)
[Structured ladder] g_time1
TIME_TO_DINT
_TIME g_dint1
[ST] g_dint1 := TIME_TO_DINT(g_time1);
2) Function with EN/ENO(TIME_TO_DINT_E)
[Structured ladder] g_bool1 g_time1
TIME_TO_DINT_E
EN ENO
_TIME g_bool3 g_dint1
[ST] g_bool3 := TIME_TO_DINT_E(g_bool1, g_time1, g_dint1);
1
2
3
4
5
6
A
127
FXCPU Structured Programming Manual
(Application Functions)
5.1.46 TIME_TO_STR(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts time data into string data, and outputs the data obtained by conversion.
1. Format
Function name
TIME_TO_STR
TIME_TO_STR_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
TIME_TO_STR
_TIME *1 Label 2
ST
TIME_TO_STR(_TIME);
Example:
Label 2:=
TIME_TO_STR(Label 1);
TIME_TO_STR_E
EN
_TIME
ENO
*1 Label 2
TIME_TO_STR_E(EN,_TIME,
Output label);
Example:
TIME_TO_STR_E(X000, Label 1,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO
*1 ( s
) d
)
Description
Execution condition
Conversion source time data
Execution status
String data after conversion
In explanation of functions, I/O variables inside ( ) are described.
Bit
Time
Bit
String
Data type
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
.
s
into string data, and outputs the data
20m34s567ms "1234567"
Time data String 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.
d
exceeds the range of the
128
FXCPU Structured Programming Manual
(Application Functions)
5 Applied Functions
5.1 Type Conversion Functions
Program example
In this program, time data stored in a device specified in obtained by conversion is output to a device specified in d
.
s
1) Function without EN/ENO(TIME_TO_STR)
is converted into string data, and the data
[Structured ladder] g_time1
TIME_TO_STR
_TIME g_string1
[ST] g_string1 := TIME_TO_STR(g_time1);
2) Function with EN/ENO(TIME_TO_STR_E)
[Structured ladder] g_bool1 g_time1
EN
TIME_TO_STR_E
ENO
_TIME g_bool3 g_string1
[ST] g_bool3 := TIME_TO_STR_E(g_bool1, g_time1, g_string1);
1
2
3
4
5
6
A
129
FXCPU Structured Programming Manual
(Application Functions)
5.1.47 TIME_TO_WORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function converts time data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name
TIME_TO_WORD
TIME_TO_WORD
_E
Label
X000
Label
Expression in each language
Structured ladder
TIME_TO_WORD
_TIME *1 D10
ST
TIME_TO_WORD(_TIME);
Example:
D10:=
TIME_TO_WORD(Label);
TIME_TO_WORD_E
EN
_TIME
ENO
*1 D10
TIME_TO_WORD_E(EN,_TIME,
Output label);
Example:
TIME_TO_WORD_E(X000, Label,
D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source time data
Execution status
Word [unsigned]/bit string [16-bit] data after conversion
Data type
Bit
Time
Bit
Word [unsigned]/
Bit String [16-bit]
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
Program example
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)
[Structured ladder] g_time1
TIME_TO_WORD
_TIME g_word1
[ST] g_word1 := TIME_TO_WORD(g_time1);
2) Function with EN/ENO(TIME_TO_WORD_E)
[Structured ladder] g_bool1 g_time1
TIME_TO_WORD_E
EN ENO
_TIME g_bool3 g_word1
[ST] g_bool3 := TIME_TO_WORD_E(g_bool1, g_time1, g_word1);
1
2
3
4
5
6
A
131
FXCPU Structured Programming Manual
(Application Functions)
5.1.48 TIME_TO_DWORD(_E)
5 Applied Functions
5.1 Type Conversion Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Function name
TIME_TO_DWOR
D
TIME_TO_DWOR
D_E
Label 1
X000
Label 1
Expression in each language
Structured ladder
TIME_TO_DWORD
_TIME *1 Label 2
ST
TIME_TO_DWORD(_TIME);
Example:
Label 2:=
TIME_TO_DWORD(Label 1);
TIME_TO_DWORD_E
EN
_TIME
ENO
*1 Label 2
TIME_TO_DWORD_E(EN,_TIME,
Output label);
Example:
TIME_TO_DWORD_E(X000,
Label 1, Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_TIME (
ENO s
)
*1 ( d
)
Description
Execution condition
Conversion source time data
Execution status
Double word [unsigned]/bit string [32-bit] data after conversion
Data type
Bit
Time
Bit
Double Word [unsigned]/
Bit string [32-bit]
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
Program example
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)
[Structured ladder] g_time1
TIME_TO_DWORD
_TIME g_dword1
[ST] g_dword1 := TIME_TO_DWORD(g_time1);
2) Function with EN/ENO(TIME_TO_DWORD_E)
[Structured ladder] g_bool1 g_time1
TIME_TO_DWORD_E
EN ENO
_TIME g_bool3 g_dword1
[ST] g_dword1 := TIME_TO_DWORD(g_time1);
1
2
3
4
5
6
A
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)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains the absolute value, and outputs it.
1. Format
Function name
ABS
ABS_E
X000
Expression in each language
Structured ladder
D0 _IN
EN
D0 _IN
ABS
ABS_E
*1
ENO
D10
*1 D10
ST
ABS(_IN);
Example:
D10:=
ABS(D0);
ABS_E(EN,_IN,Output label);
Example:
ABS_E(X000,D0,D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN ( s
)
ENO
*1 ( d
)
Description
Execution condition
Data whose absolute value is to be obtained, or word device which stores such data
Execution status
Word device which will store the operation result
Bit
Data type
ANY_NUM
Bit
ANY_NUM
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 this function outputs "-32768" to a device specified in function is "32,767".) s d
is word [signed] and the stored data is "-32768",
. (The maximum absolute value handled by this
When the data type stored in a device specified in s
2147483648", this function outputs "-2147483648" to a device specified in value handled by this function is "2147483647".)
is double word [signed] and the stored data is "d
. (The maximum absolute
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
Program example
In this program, the absolute value is obtained for word [signed] data stored in a device specified in the operation result is output to a device specified in d s
, and
using the data type same as the data stored in a device specified in s
.
1) Function without EN/ENO(ABS)
[Structured ladder] g_int1=-5923 _IN
ABS g_int2=5923
[ST] g_int2 := ABS(g_int1);
2) Function with EN/ENO(ABS_E)
[Structured ladder] g_bool1
EN g_int1 _IN
ABS_E
ENO g_bool3 g_int2
[ST] g_bool3 := ABS_E(g_bool1, g_int1, g_int2);
1
2
3
4
5
6
A
135
FXCPU Structured Programming Manual
(Application Functions)
5.3
Standard Arithmetic Functions
5.3.1
ADD_E
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs addition using two values (A + B = C), and outputs the operation result.
1. Format
Function name
ADD_E
X000
Structured ladder
D0
EN
_IN
Expression in each language
ADD_E
ENO
*1 D20
ST
ADD_E(EN,_IN,_IN,Output label);
Example:
ADD_E(X000,D0,D10,D20);
D10 _IN
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s
*1 ( d
…)
)
Description
Execution condition
Data for addition or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_NUM
Bit
ANY_NUM
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
Example: When the data type is word [signed] s1
and s2
.
1234 + 5678 6912 s1 (Word
[signed] data) s2 (Word
[signed] data) d (Word
[signed] data)
136
FXCPU Structured Programming Manual
(Application Functions) 5.3 Standard Arithmetic Functions
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.
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
M8020
M8021
M8022
Name
Zero
Borrow
Carry
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
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
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
-2 , -1 , 0 , -32,768
Zero flag
-1 , 0 , 1
Zero flag
32,767 , 0 , 1 , 2
Borrow flag The most significant bit of data is "1".
Zero flag
-2 , -1 , 0 , -2,147,483,648 -1 , 0 , 1
The most significant bit of data is "0".
Carry flag
Zero flag
2,147,483,647 , 0 , 1 , 2
Borrow flag Zero flag Carry flag
Program example
In this program, addition is performed using double word [signed] data stored in devices specified in s2
, and the operation result is output to a device specified in d
.
s1
and
[Structured ladder] g_bool1 g_dint1 g_dint2
EN
_IN
_IN
ADD_E
ENO g_bool3 g_dint3
[ST] g_bool3:=ADD_E(g_bool1,g_dint1,g_dint2,g_dint3);
1
2
3
4
5
6
A
137
FXCPU Structured Programming Manual
(Application Functions)
5.3.2
SUB_E
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs subtraction using two values (A - B = C), and outputs the operation result.
1. Format
Function name
SUB_E
X000
Expression in each language
Structured ladder
D0
D10
EN
SUB_E
ENO
_IN1
_IN2
*1 D20
ST
SUB_E(EN,_IN1,_IN2,Output label);
Example:
SUB_E(X000,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Data to be subtracted or word device which stores such data
Data for subtraction or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_NUM
ANY_NUM
Bit
ANY_NUM
Explanation of function and operation
1) This function performs subtraction ( s1
s2 precision) data stored in devices specified in
) using word [signed]/double word [signed]/float (single 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
Example: When the data type is word [signed] s1
and s2
.
12345 6789 5556 s1 (Word
[signed] data) s2 (Word
[signed] data) d (Word
[signed] data)
138
FXCPU Structured Programming Manual
(Application Functions) 5.3 Standard Arithmetic Functions
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.
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
M8020
M8021
M8022
Name
Zero
Borrow
Carry
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
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
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
-2 , -1 , 0 , -32,768
Zero flag
-1 , 0 , 1
Zero flag
32,767 , 0 , 1 , 2
Borrow flag The most significant bit of data is "1".
Zero flag
-2 , -1 , 0 , -2,147,483,648 -1 , 0 , 1
The most significant bit of data is "0".
Carry flag
Zero flag
2,147,483,647 , 0 , 1 , 2
Borrow flag Zero flag Carry flag
Program example
In this program, subtraction is performed using word [signed] data stored in devices specified in s2
, and the operation result is output to a device specified in d
.
s1
and
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN1
SUB_E
ENO
_IN2 g_bool3 g_int3
[ST] g_bool3:=SUB_E(g_bool1,g_int1,g_int2,g_int3);
1
2
3
4
5
6
A
139
FXCPU Structured Programming Manual
(Application Functions)
5.3.3
MUL_E
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs multiplication using two values (A × B = C), and outputs the operation result.
1. Format
Function name
MUL_E
X000
Expression in each language
Structured ladder
D0
D10
EN
MUL_E
ENO
_IN
_IN
*1 D20
ST
MUL_E(EN,_IN,_IN,Output label);
Example:
MUL_E(X000,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Data for multiplication or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_NUM
Data type
Bit
ANY_NUM
Explanation of function and operation
1) This function performs multiplication ( s1
× precision) data stored in devices specified in s2 s1
) using word [signed]/double word [signed]/float (single
and s2
, and outputs the operation result to a device specified in d
using the data type of data stored in devices specified in
Example: When the data type is word [signed] s1
and s2
.
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
Program example
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] g_bool1 g_dint1 g_dint2
EN
_IN
_IN
MUL_E
ENO g_bool3 g_dint3
[ST] g_bool3:=MUL_E(g_bool1,g_dint1,g_dint2,g_dint3);
1
2
3
4
5
6
A
141
FXCPU Structured Programming Manual
(Application Functions)
5.3.4
DIV_E
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs division using two values (A / B = C … remainder), and outputs the quotient.
1. Format
Function name
DIV_E
X000
Expression in each language
Structured ladder
D0
D10
EN
DIV_E
ENO
_IN1
_IN2
*1 D20
ST
DIV_E(EN,_IN1,_IN2,Output label);
Example:
DIV_E(X000,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Data to be divided, or word device which stores such data
Data for division (divisor), or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_NUM
ANY_NUM
Bit
ANY_NUM
Explanation of function and operation
This function performs division ( s1 data stored in devices specified in
/ s1 s2
) using word [signed]/double word [signed]/float (single precision)
and s2
, and outputs the operation result to a device specified in d
using the data type of data stored in devices specified in
Example: When the data type is word [signed] s1
and s2
.
5 / 2
(Quotient)
2 s1 (Word
[signed] data) s2 (Word
[signed] data) 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 not executed.
s2
is "0", and the function is
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
Program example
In this program, division is performed using double word [signed] data stored in devices specified in s2
, and the operation result is output to a device specified in devices specified in s1
and s2
.
d s1
and
using the data type of data stored in
[Structured ladder] g_bool1 g_dint1 g_dint2
EN
_IN1
_IN2
DIV_E
ENO g_bool3 g_dint3
[ST] g_bool3:=DIV_E(g_bool1,g_dint1,g_dint2,g_dint3);
1
2
3
4
5
6
A
143
FXCPU Structured Programming Manual
(Application Functions)
5.3.5
MOD(_E)
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs division using two values (A / B = C … remainder), and outputs the remainder.
1. Format
Function name
MOD
MOD_E
Label 1
Label 2
Expression in each language
Structured ladder
_IN1
_IN2
MOD
*1 Label 3
ST
_IN1 MOD _IN2; *2
Example:
Label 3:=
Label 1 MOD Label 2;
X000
Label 1
EN
MOD_E
ENO
_IN1
Label 2 _IN2
*1 Label 3
MOD_E(EN,_IN1,_IN2,Output label; *2
Example:
MOD_E(X000,Label 1,
Label 2,Label 3);
*1.
Output variable
*2.
Refer to the Cautions
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Data to be divided, or word device which stores such data
Data for division (divisor), or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_INT
Data type
ANY_INT
Bit
ANY_INT
Explanation of function and operation
This function performs division ( specified in s1
and s2 s1
/ s2
, and outputs the remainder to a device specified in data stored in devices specified in s1
) using word [signed]/double word [signed] data stored in devices d
using the data type of
and
Example: When the data type is word [signed] s2
.
5 / 2
(Quotient)
2
(Remainder)
1 s1 (Word
[signed] data) s2 (Word
[signed] data)
Not output 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
Error
1) An operation error occurs when the divisor stored in a device specified in not executed.
s2
is "0", and the function is
2) An operation error occurs when the operation result exceeds "32,767" (16-bit operation) or
"2,147,483,647" (32-bit operation).
Program example
In this program, division is performed using double word [signed] data stored in devices specified in s2
, and the remainder is output to a device specified in specified in s1
and s2
.
d s1
and
using the data type of data stored in devices
1) Function without EN/ENO(MOD)
[Structured ladder] g_dint1=5678 g_dint2=1234
_IN1
_IN2
MOD g_dint3=742
[ST] g_dint3:=g_dint1 MOD g_dint2;
2) Function with EN/ENO(MOD_E)
[Structured ladder]] g_bool1 g_dint1 g_dint2
EN
_IN1
MOD_E
ENO
_IN2 g_bool3 g_dint3
[ST] g_bool3 := MOD_E(g_bool1, g_dint1, g_dint2, g_dint3);
1
2
3
4
5
6
A
145
FXCPU Structured Programming Manual
(Application Functions)
5.3.6
EXPT(_E)
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains raised result, and outputs it.
1. Format
Function name
EXPT
EXPT_E
Label 1
D10
Expression in each language
Structured ladder
In1
In2
EXPT
*1 Label 2
ST
EXPT(In1,In2);
Example:
Label 2:=
EXPT(Label 1,D10);
X000
Label 1
EXPT_E
EN ENO
In1
D10 In2
*1 Label 2
EXPT_E(EN,In1,In2,Output label);
Example:
EXPT_E(X000,Label 1,D10,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
In1 ( s1
)
In2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Data to be raised, or word device which stores such data
Power data, or word device which stores such data
Execution status
Word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
FLOAT (Single Precision)
ANY_NUM
Bit
FLOAT (Single Precision)
Explanation of function and operation
This function raises float (single precision) data stored in a device specified in stored in a device specified in s2 s1
(to the power of the value
), and outputs the operation result to a device specified in d
.
2
4.0
16.0
s2 Word
[signed] data
precision) data 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
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
(Error code: K6706) s1
is negative
2) When the value stored in a device specified in
(Error code: K6706) s1
is "0"
3) When the operation result is outside the following range:
(Error code: K6706)
2
-126 ≤⏐Operation result⏐<2 128
Program example
In this program, the value stored in a device specified in device specified in s2 s1
, and the operation result is output to a device specified in data stored in a device specified in s1
.
is raised to the power of the value stored in a d
using the data type of
1) Function without EN/ENO(EXPT)
[Structured ladder]
EXPT g_real1 g_int1
In1
In2 g_real2
[ST] g_real2:=EXPT(g_real1,g_int1);
2) Function with EN/ENO(EXPT_E)
[Structured ladder] g_bool1 g_real1 g_int1
EN
In1
In2
EXPT_E
ENO g_bool3 g_real2
[ST] g_bool3:=EXPT_E(g_bool1,g_real1,g_int1,g_real2);
1
2
3
4
5
6
A
147
FXCPU Structured Programming Manual
(Application Functions)
5.3.7
MOVE(_E)
5.3 Standard Arithmetic Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function transfers data stored in a device to another device.
1. Format
Function name
MOVE
MOVE_E
X000
Expression in each language
Structured ladder
D0 _IN
MOVE
*1 D10
MOVE(_IN);
Example:
D10:=
MOVE(D0);
MOVE_E
EN
D0 _IN
ENO
*1 D10
ST
MOVE_E(EN,_IN,Output label);
Example:
MOVE_E(X000,D0,D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s
*1 ( d
)
)
Description
Execution condition
Transfer source data, or word device which stores such data
Execution status
Transfer destination word device
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY
Bit
ANY
Explanation of function and operation
This function transfers data stored in a device specified in s
to a device specified in d
.
12 12 s Word [signed] data d Word [signed] data
Data type
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
Program example
In this program, word [signed] data stored in a device specified in d
.
1) Function without EN/ENO(MOVE) s
is transferred to a device specified in
[Structured ladder]
MOVE g_int1 _IN g_int2
[ST] g_int2:=MOVE(g_int1);
2) Function with EN/ENO(MOVE_E)
[Structured ladder] g_bool1
EN g_int1 _IN
MOVE_E
ENO g_bool3 g_int2
[ST] g_bool3:=MOVE_E(g_bool1,g_int1,g_int2);
1
2
3
4
5
6
A
149
FXCPU Structured Programming Manual
(Application Functions)
5.4
Standard Bit Shift Functions
5.4.1
SHL(_E)
5.4 Standard Bit Shift Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function shifts data of specified bit length leftward by the specified number of bits.
1. Format
Function name
SHL
SHL_E
X000
Expression in each language
Structured ladder
D0
K1
_IN
_N
SHL
*1 D10
SHL(_IN,_N);
Example:
D10:=
SHL(D0,K1);
ST
EN
D0 _IN
K1 _N
SHL_E
ENO
*1 D10
SHL_E(EN,_IN,_N,Output label);
Example:
SHL_E(X000,D0,K1,D10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN ( s
_N (
ENO n
*1 ( d
)
)
)
Description
Execution condition
Word device which stores data to be shifted leftward
Number of shifted bits
Execution status
Word device which will store data obtained by shift
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
ANY_BIT
Bit
ANY_BIT
Data type
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
Data is shifted leftward by "n" bits specified in n
.
s
.
Example: When word [unsigned]/bit string [16-bit] data is stored in a device specified in specified in n s
, and "8" is
270FH F00H bit string [16-bit] data) 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
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.
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in by "n" bits, and the obtained data is output to a device specified in device specified in s
.
d s
is shifted leftward
using the data type of data stored in a
1) Function without EN/ENO(SHL)
[Structured ladder]
SHL g_word1=16#F30F g_const_word1=16#0008
_IN
_N g_word2=16#0F00
[ST] g_word2:=SHL(g_word1,g_const_word1);
2) Function with EN/ENO(SHL_E)
[Structured ladder] g_bool1 g_word1 g_const_word1
EN
_IN
_N
SHL_E
ENO g_bool3 g_word2
[ST] g_bool3:=SHL_E(g_bool1,g_word1,g_const_word1,g_word2);
1
2
3
4
5
6
A
151
FXCPU Structured Programming Manual
(Application Functions)
5.4.2
SHR(_E)
5.4 Standard Bit Shift Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function shifts data of specified bit length rightward by the specified number of bits.
1. Format
Function name
SHR
SHR_E
X000
D0
Expression in each language
Structured ladder
K1
_IN
_K
SHR
*1 D10
SHR(_IN,_K);
Example:
D10:=
SHR(D0,K1);
ST
SHR_E(EN,_IN,_N,Output label);
Example:
SHR_E(X000,D0,K1,D10);
D0
K1
EN
SHR_E
ENO
_IN
_N
*1 D10
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
_K,_N (
ENO
*1 ( d s n
)
)
)
Description
Execution condition
Word device which stores data to be shifted rightward
Number of shifted bits
Execution status
Word device which will store data obtained by shift
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
ANY_BIT
Bit
ANY_BIT
Data type
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 n 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 specified in s
, and "8" is
270FH 27H bit string [16-bit] data) 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
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.
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in by "n" bits, and the obtained data is output to a device specified in device specified in s
.
d s
is shifted rightward
using the data type of data stored in a
1) Function without EN/ENO(SHR)
[Structured ladder]
SHR g_word1=16#EEEE g_const_word1=16#0006
_IN
_K g_word2=16#03BB
[ST] g_word2:=SHR(g_word1,g_const_word1);
2) Function with EN/ENO(SHR_E)
[Structured ladder] g_bool1 g_word1 g_const_word1
EN
_IN
_N
SHR_E
ENO g_bool3 g_word2
[ST] g_bool3:=SHR_E(g_bool1,g_word1,g_const_word1,g_word2);
1
2
3
4
5
6
A
153
FXCPU Structured Programming Manual
(Application Functions)
5.5
Standard Bitwise Boolean Functions
5.5.1
AND_E
5.5 Standard Bitwise Boolean Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains the logical product of two or more bits, and outputs it.
1. Format
Function name
AND_E
X000
Structured ladder
M0
EN
_IN
Expression in each language
AND_E
ENO
*1 M20
ST
AND_E(EN,_IN,_IN,Output label);
Example:
AND_E(X000,M0,M10,M20);
M10 _IN
*1.
Output variable
2. Variable
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Device used to obtain the logical product
Execution status
Device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
Bit
ANY_BIT
Data type
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 s2
1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1
Logical product
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
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.
154
FXCPU Structured Programming Manual
(Application Functions) 5.5 Standard Bitwise Boolean Functions
Program example
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
.
[Structured ladder] g_bool1 g_word1=16#FF0F g_word2=16#1234
EN
_IN
_IN
AND_E
ENO g_bool3 g_word3=16#1204
[ST] g_bool3:=AND_E(g_bool1,g_word1,g_word2,g_word3);
1
2
3
4
5
6
A
155
FXCPU Structured Programming Manual
(Application Functions)
5.5.2
OR_E
5.5 Standard Bitwise Boolean Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains the logical sum of two or more bits, and outputs it.
1. Format
Function name
OR_E
X000
Expression in each language
Structured ladder ST
OR_E(EN,_IN,_IN,Output label);
Example:
OR_E(X000,M0,M10,M20);
M0
M10
EN
OR_E
ENO
_IN
_IN
*1 M20
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Device used to obtain the logical sum
Execution status
Device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
Bit
ANY_BIT
Data type
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 s2
.
Example: When the data type is word [unsigned]/bit string [16-bit]] s1
and s1 s2
1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1
Logical sum
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
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.
156
FXCPU Structured Programming Manual
(Application Functions) 5.5 Standard Bitwise Boolean Functions
Program example
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
.
[Structured ladder] g_bool1 g_word1=16#5F03 g_word2=16#9CCC
EN
_IN
_IN
OR_E
ENO g_bool3 g_word3=16#DFCF
[ST] g_bool3:=OR_E(g_bool1,g_word1,g_word2,g_word3);
1
2
3
4
5
6
A
157
FXCPU Structured Programming Manual
(Application Functions)
5.5.3
XOR_E
5.5 Standard Bitwise Boolean Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains the exclusive logical sum of two or more bits, and outputs it.
1. Format
Function name
XOR_E
X000
Expression in each language
Structured ladder
M0
M10
EN
XOR_E
ENO
_IN
_IN
*1 M20
ST
XOR_E(EN,_IN,_IN,Output label);
Example:
XOR_E(X000,M0,M10,M20);
*1.
Output variable
2. .Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Device used to obtain the exclusive logical sum
Execution status
Device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
Bit
ANY_BIT
Data type
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 s2
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
Exclusive logical sum
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
2) The number of pins in s
can be changed.
158
FXCPU Structured Programming Manual
(Application Functions) 5.5 Standard Bitwise Boolean Functions
1
3) If there are 3 or more s
, the exclusive logical sum is obtained using the "exclusive logical sum of s1
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 required number of times for all input labels
Example: When the data type is bit s4 s5
. In this way, the exclusive logical sum is obtained the s6
… s1 s2
FALSE
XOR
TRUE
Result TRUE s3
When the number of "_IN" is 3
TRUE
XOR
TRUE
Result FALSE s4
When the number of "_IN" is 4
FALSE
XOR
TRUE
Result TRUE
When the number of "_IN" is 5
TRUE
XOR s5
TRUE
Result FALSE
After that, the exclusive logical sum is obtained the required number of times.
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 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 using the data type of data stored in devices specified in s1
and s2
.
d
[Structured ladder] g_bool1 g_word1=16#AAAA g_word2=16#1BF0
EN
_IN
_IN
XOR_E
ENO g_bool3 g_word3=16#B15A
[ST] g_bool3:=XOR_E(g_bool1,g_word1,g_word2,g_word3);
2
3
4
5
6
A
159
FXCPU Structured Programming Manual
(Application Functions)
5.5.4
NOT(_E)
5.5 Standard Bitwise Boolean Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function obtains the logical negation of bits, and outputs it.
1. Format
Function name
NOT
NOT_E
M0
Expression in each language
Structured ladder
_IN
NOT
*1 M10
NOT(_IN);
Example:
M10:=
NOT(M0);
X000
EN
NOT_E
ENO
M0 _IN *1 M10
ST
NOT_E(EN,_IN,Output label);
Example:
NOT_E(X000,M0,M10);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO
*1 ( d s
)
)
Description
Execution condition
Device used to obtain the logical negation
Execution status
Device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
ANY_BIT
Bit
ANY_BIT
Data type
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
Example: When the data type is word [unsigned]/bit string [16-bit] s
.
s d
0 1 1 0 1 0 1 1 0 0 0 0 1 1 1 1
Logical negation
1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 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.
160
FXCPU Structured Programming Manual
(Application Functions) 5.5 Standard Bitwise Boolean Functions
Program example
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
.
1) Function without EN/ENO(NOT)
[Structured ladder]
NOT g_word1=16#AAAA _IN g_word2=16#5555
[ST] g_word2:= NOT(g_word1);
2) Function with EN/ENO(NOT_E)
[Structured ladder] g_bool1
EN g_word1 _IN
NOT_E
ENO g_bool3 g_word2
[ST] g_bool3:=NOT_E(g_bool1,g_word1,g_word2);
1
2
3
4
5
6
A
161
FXCPU Structured Programming Manual
(Application Functions)
5.6
Standard Selection Functions
5.6.1
SEL(_E)
5.6 Standard Selection Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function selects either one between two data in accordance with the input condition, and outputs the selection result.
1. Format
Function name
SEL
SEL_E
Expression in each language
Structured ladder
M0
D0
D10
_G
_IN0
_IN1
SEL
*1 D20
ST
SEL(_G,_IN0,_IN1);
Example:
D20:=
SEL(M0,D0,D10);
X000
M0
D0
D10
EN
SEL_E
ENO
_G
_IN0
_IN1
*1 D20
SEL_E(EN,_G,_IN0,_IN1,Output label);
Example:
SEL_E(X000,M0,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_G ( s1
)
_IN0 ( s2
)
_IN1 ( s3
ENO
*1 ( d
)
)
Description
Execution condition
Bit data used as the selection condition
Selectable data, or word device which stores such data
Selectable data, or word device which stores such data
Execution status
Word device which will store the selection result
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
ANY
ANY
Bit
ANY
Data type
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 type of data stored in a device specified in s2
and s3
.
When the value stored in a device specified in s1 s1
to a device specified in d
using the data
is "FALSE", this function outputs the value stored in a device specified in s2
to a device specified in
When the value stored in a device specified in device specified in s3
to a device specified in
Example: When the data type of input variables d s1 d s2
.
is "TRUE", this function outputs the value stored in a
.
and s3
is word [signed]
FALSE
Bit data
1234
Word [signed] data
5678
Word [signed] data
G
_IN0
_IN1
SEL
1234
Word [signed] data
162
FXCPU Structured Programming Manual
(Application Functions) 5.6 Standard Selection Functions
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.
Program example
In this program, either one between the values stored in devices specified in accordance with the value stored in a device specified in type of data stored in devices specified in s2
and s3
.
s1 s2
and
to a device specified in d
1) Function without EN/ENO(SEL) s3
is output in
using the data
[Structured ladder] g_bool1 g_word1 g_word2
_G
_IN0
_IN1
SEL g_word3
[ST] g_word3:=SEL(g_bool1,g_word1,g_word2);
2) Function with EN/ENO(SEL_E)
[Structured ladder] g_bool1 g_bool2 g_word1
EN
_G
_IN0 g_word2 _IN1
SEL_E
ENO g_bool3 g_word3
[ST] g_bool3:=SEL_E(g_bool1,g_bool2,g_word1,g_word2,g_word3);
1
2
3
4
5
6
A
163
FXCPU Structured Programming Manual
(Application Functions)
5.6.2
MAXIMUM(_E)
5.6 Standard Selection Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function searches the maximum value among data, and outputs the maximum value.
1. Format
Function name
MAXIMUM
D0
D10
Expression in each language
Structured ladder
MAXIMUM
_IN
_IN
*1 D20
ST
MAXIMUM(_IN,_IN);
Example:
D20:=
MAXIMUM(D0,D10);
MAXIMUM_E
X000 MAXIMUM_E
EN ENO
D0 _IN *1 D20
D10 _IN
MAXIMUM_E(EN,_IN,_IN,Output label);
Example:
MAXIMUM_E(X000,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Word device which will store the maximum value
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
ANY_SIMPLE
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
Example: When the data type is word [signed]
1234
Word [signed] data
5678
Word [signed] data
_IN
MAXIMUM
_IN
5678
Word [signed] data
2) The number of pins 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.
164
FXCPU Structured Programming Manual
(Application Functions) 5.6 Standard Selection Functions
Program example
In this program, the maximum value among word [signed] data stored in devices specified in output to a device specified in d
using the data type of data stored in devices specified in
1) Function without EN/ENO(MAXIMUM) s1 s1
and
and s2 s2
is
.
[Structured ladder] g_int1=5678 g_int2=1234
_IN
MAXIMUM
_IN g_int3=5678
[ST] g_int3:=MAXIMUM(g_int1,g_int2);
2) Function with EN/ENO(MAXIMUM_E)
[Structured ladder] g_bool1 g_int1 g_int2
EN
MAXIMUM_E
ENO
_IN
_IN g_bool3 g_int3
[ST] g_bool3:=MAXIMUM_E(g_bool1,g_int1,g_int2,g_int3);
1
2
3
4
5
6
A
165
FXCPU Structured Programming Manual
(Application Functions)
5.6.3
MINIMUM(_E)
5.6 Standard Selection Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function searches the minimum value among data, and outputs the minimum value.
1. Format
Function name
MINIMUM
Expression in each language
Structured ladder
D0
D10
MINIMUM
_IN
_IN
*1 D20
ST
MINIMUM(_IN,_IN);
Example:
D20:=
MINIMUM(D0,D10);
MINIMUM_E
X000 MINIMUM_E
EN ENO
D0 _IN *1 D20
D10 _IN
MINIMUM_E(EN,_IN,_IN,Output label);
Example:
MINIMUM_E(X000,D0,D10,D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Word device which will store the minimum value
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
ANY_SIMPLE
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
Example: When the data type is word [signed]
1234
Word [signed] data
5678
Word [signed] data
_IN
_IN
MINIMUM
1234
Word [signed] data
2) The number of pins 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
Program example
In this program, the minimum value among word [signed] data stored in devices specified in output to a device specified in d
using the data type of data stored in devices specified in s1 s1
1) Function without EN/ENO(MINIMUM)
and
and s2 s2
is
.
[Structured ladder] g_int1=5678 g_int2=1234
_IN
MINIMUM
_IN g_int3=1234
[ST] g_int3:=MINIMUM(g_int1,g_int2);
2) Function with EN/ENO(MINIMUM_E)
[Structured ladder] g_bool1 g_int1 g_int2
EN
MINIMUM_E
ENO
_IN
_IN g_bool3 g_int3
[ST] g_bool3:=MINIMUM_E(g_bool1,g_int1,g_int2,g_int3);
1
2
3
4
5
6
A
167
FXCPU Structured Programming Manual
(Application Functions)
5.6.4
LIMITATION(_E)
5.6 Standard Selection Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
168
Outline
This function judges whether data is located within the range between the upper limit value and the lower limit value.
1. Format
Function name
LIMITATION
LIMITATION_E
Structured ladder
D0
D10
Expression in each language
LIMITATION
_MN
_IN
*1 D30
ST
LIMITATION(_MN,_IN,_MX);
Example:
D30:=
LIMITATION(D0,D10,D20);
D20 _MX
X000
D0
D10
D20
LIMITATION_E
EN ENO
_MN
_IN
_MX
*1 D30
LIMITATION_E(EN,_MN,_IN,_MX,
Output label);
Example:
LIMITATION_E(X000,D0,D10,D20,
D30);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_MN ( s1
)
_IN ( s2
)
_MX (
ENO s3
)
*1 ( d
)
Description
Execution condition
Lower limit data, or word device which stores such data
Input data, or word device which stores such data
Upper limit data, or word device which stores such data
Execution status
Word device which will store the output data
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
ANY_SIMPLE
ANY_SIMPLE
Bit
ANY_SIMPLE
Explanation of function and operation
This function outputs data whose type is same as the data stored in devices specified in to a device specified in s2
and s3
.
d s1
, s2
and
in accordance with ANY_SIMPLE type data stored in devices specified in s3 s1
,
1) In the case of "Contents of a device specified in function outputs the contents of a device specified in s2 s3
> Contents of a device specified in
to a device specified in d
.
2) In the case of "Contents of a device specified in function outputs the contents of a device specified in s2 s1
< Contents of a device specified in
to a device specified in d
.
s3
", this s1
", this
3) In the case of "Contents of a device specified in of a device specified in s3 s1
≤ Contents of a device specified in
", this function outputs the contents of a device specified in specified in d
.
Example: When the data type is word [signed] s2 s2
≤ Contents
to a device
Output value
-100
Word [signed] data
120
Word [signed] data
100
Word [signed] data
LIMITATION
_MN
_IN
_MX
100
Minimum input value
Word [signed] data
Input value
Maximum input value
FXCPU Structured Programming Manual
(Application Functions) 5.6 Standard Selection Functions
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 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
(Lower limit data) s1
> Contents of a device specified in
(Upper limit data) s3
Program example
In this program, data whose type is same as the data stored in devices specified in output to a device specified in d s1
, s2
and s3
is
in accordance with ANY_SIMPLE type data stored in devices specified in s1
1) Function without EN/ENO(LIMITATION)
[Structured ladder] g_int1=500 g_int2=1300
LIMITATION
_MN
_IN g_int3=5000 _MX g_int4=1300
[ST] g_int4:=LIMITATION(g_int1,g_int2,g_int3);
2) Function with EN/ENO(LIMITATION_E)
[Structured ladder] g_bool1 LIMITATION_E
EN ENO
_MN g_int1 g_int2 _IN g_int3 _MX g_bool3 g_int4
[ST] g_bool3:=LIMITATION_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
1
2
3
4
5
6
A
169
FXCPU Structured Programming Manual
(Application Functions)
5.6.5
MUX(_E)
5.6 Standard Selection Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function selects data, and outputs the selected data.
1. Format
Function name
MUX
MUX_E
Expression in each language
Structured ladder
D0
D10
D20
_K
_IN
_IN
MUX
*1 D30
ST
MUX(_K,_IN,_IN);
Example:
D30:=
MUX(D0,D10,D20);
X000
D0
D10
D20
EN
MUX_E
ENO
_K
_IN
_IN
*1 D30
MUX_E(EN,_K,_IN,_IN,Output label);
Example:
MUX_E(X000,D0,D10,D20,D30);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_K ( n
)
_IN ( s1
…)
ENO
*1
Description
Execution condition
Selection data, or word device which stores such data
Selectable data, or word device which stores such data
Execution status
Word device which will store the selected data
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Word [signed]
ANY
Bit
ANY
Explanation of function and operation
1) This function outputs either one among values stored in devices specified in in d
in accordance with the value specified in specified in s1
….
n s1
… to a device specified
using the data type of data stored in devices a) When the value specified in s1
to a device specified in n d
is "1", this function outputs the value stored in a device specified in
.
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
1234
Word [signed] data
5678
Word [signed] data
K
_IN
_IN
MUX
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 s
can be changed.
170
FXCPU Structured Programming Manual
(Application Functions) 5.6 Standard Selection Functions
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.
Program example
In this example, either one among values stored in devices specified in in s1 d
in accordance with the value specified in
….
n s1
… is output to a device specified
using the data type of data stored in devices specified in
1) Function without EN/ENO(MUL)
[Structured ladder]
MUX g_int1=2 g_int2=1234
_K
_IN g_int3=5678 _IN g_int4=5678
[ST] g_int4:=MUX(g_int1,g_int2,g_int3);
2) Function with EN/ENO(MUL_E)
[Structured ladder] g_bool1 g_int1
EN
_K g_int2 _IN g_int3 _IN
MUX_E
ENO g_bool3 g_int4
[ST] g_bool3:=MUX_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
1
2
3
4
5
6
A
171
FXCPU Structured Programming Manual
(Application Functions)
5.7
Standard Comparison Functions
5.7.1
GT_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function compares data with regard to " > (larger)".
1. Format
Function name
GT_E
X000
Structured ladder
EN
Expression in each language
GT_E
ENO
ST
GT_E(EN,_IN,_IN,Output label);
Example:
GT_E(X000,D0,D10,M0);
D0
D10
_IN
_IN
*1 M0
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
1) This function compares the contents of devices specified in expressed as the bit type data to a device specified in
This function executes comparison [ s1
> s2
] & [ s2 d
.
s1 a) This function outputs "TRUE" when all comparison results are "
…, and outputs the operation result s sn
-1 > ].
(n-1) > (n)".
b) This function outputs "FALSE" when any comparison result is " s
(n-1) ≤ (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
Program example
In this program, the contents of devices specified in output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN
_IN
GT_E
ENO g_bool3 g_bool2
1
2
[ST] g_bool3:=GT_E(g_bool1,g_int1,g_int2,g_bool2);
3
4
5
6
A
173
FXCPU Structured Programming Manual
(Application Functions)
5.7.2
GE_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
174
Outline
This function compares data with regard to " ≥ (larger or equal)".
1. Format
Function name
GE_E
X000
D0
D10
Expression in each language
Structured ladder
EN
_IN
_IN
GE_E
ENO
*1 M0
ST
GE_E(EN,_IN,_IN,Output label);
Example:
GE_E(X000,D0,D10,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
1) This function compares the contents of devices specified in expressed as the bit type data to a device specified in
This function executes comparison [ s1
≥ s2
] & [ s2 d
.
s1 a) This function outputs "TRUE" when all comparison results are " b) This function outputs "FALSE" when any comparison result is "
…, and outputs the operation result s s sn
-1 ≥ ].
(n-1) ≥ (n)".
(n-1) < (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 output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN
_IN
GE_E
ENO g_bool3 g_bool2
[ST] g_bool3:=GE_E(g_bool1,g_int1,g_int2,g_bool2);
FXCPU Structured Programming Manual
(Application Functions)
5.7.3
EQ_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function compares data with regard to "= (equal)".
1. Format
Function name
EQ_E
X000
D0
D10
Expression in each language
Structured ladder
EN
_IN
_IN
EQ_E
ENO
*1 M0
ST
EQ_E(EN,_IN,_IN,Output label);
Example:
EQ_E(X000,D0,D10,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
1) This function compares the contents of devices specified in expressed as the bit type data to a device specified in d
.
This function executes comparison [ s1
= s2
] & [ s2
= s3 s1
] &
…, and outputs the operation result
… & [ sn
-1 = sn
].
a) This function outputs "TRUE" when all comparison results are " b) This function outputs "FALSE" when any comparison result is " s s
(n-1) = s
(n)".
(n-1) ≠ (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 output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN
_IN
EQ_E
ENO g_bool3 g_bool2
2
3
4
5
6
A
[ST] g_bool3:=EQ_E(g_bool1,g_int1,g_int2,g_bool2);
175
FXCPU Structured Programming Manual
(Application Functions)
5.7.4
LE_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function compares data with regard to " ≤ (smaller or equal)".
1. Format
Function name
LE_E
X000
D0
D10
Expression in each language
Structured ladder
EN
_IN
_IN
LE_E
ENO
*1 M0
ST
LE_E(EN,_IN,_IN,Output label);
Example:
LE_E(X000,D0,D10,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO s1
…)
*1 ( d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
1) This function compares the contents of devices specified in expressed as the bit type data to a device specified in d
.
This function executes comparison [ s1
≤ s2
] & [ s2 s1 a) This function outputs "TRUE" when all comparison results are " b) This function outputs "FALSE" when any comparison result is "
…, and outputs the operation result s s sn
-1 ≤ ].
(n-1) ≤ (n)".
(n-1) > (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
Program example
In this program, the contents of devices specified in output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN
_IN
LE_E
ENO g_bool3 g_bool2
1
2
[ST] g_bool3:=LE_E(g_bool1,g_int1,g_int2,g_bool2);
3
4
5
6
A
177
FXCPU Structured Programming Manual
(Application Functions)
5.7.5
LT_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
178
Outline
This function compares data with regard to " < (smaller)".
1. Format
Function name
LT_E
X000
D0
D10
Expression in each language
Structured ladder
EN
_IN
_IN
LT_E
ENO
*1 M0
ST
LT_E(EN,_IN,_IN,Output label);
Example:
LT_E(X000,D0,D10,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
ENO
*1 ( s1
…) d
)
Description
Execution condition
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
1) This function compares the contents of devices specified in expressed as the bit type data to a device specified in
This function executes comparison [ s1
< s2
] & [ s2 d
.
s1 a) This function outputs "TRUE" when all comparison results are "
…, and outputs the operation result s sn
-1 < ].
(n-1) < (n)".
b) This function outputs "FALSE" when any comparison result is " s
(n-1) ≥ (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 output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN
_IN
LT_E
ENO g_bool3 g_bool2
[ST] g_bool3:=LT_E(g_bool1,g_int1,g_int2,g_bool2);
FXCPU Structured Programming Manual
(Application Functions)
5.7.6
NE_E
5.7 Standard Comparison Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function compares data with regard to " ≠ (unequal)".
1. Format
Function name
NE_E
X000
D0
D10
Expression in each language
Structured ladder
EN
NE_E
_IN1
_IN2
ENO
*1 M0
ST
NE_E(EN,_IN1,_IN2,Output label);
Example:
NE_E(X000,D0,D10,M0);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Compared data, or word device which stores such data
Compared data, or word device which stores such data
Execution status
Device which will store the comparison result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
ANY_SIMPLE
ANY_SIMPLE
Bit
Bit
Explanation of function and operation
This function compares the contents of devices specified in expressed as the bit type data to a device specified in
This function executes comparison [ s1
≠ s2
].
d
.
s1
and a) This function outputs "TRUE" when in the case of " b) This function outputs "FALSE" when in the case of " s1 s1
≠
= s2 s2
"
" s2
, and outputs the operation result
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.
2
3
4
5
6
A
179
FXCPU Structured Programming Manual
(Application Functions) 5.7 Standard Comparison Functions
Program example
In this program, the contents of devices specified in output to a device specified in d
.
s1
and s2
are compared, and the operation result is
[Structured ladder] g_bool1 g_int1 g_int2
EN
_IN1
_IN2
NE_E
ENO g_bool3 g_bool2
[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
5.8.1
MID(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
2
Outline
This function obtains a character string from a specified position.
1. Format
Function name
MID
MID_E
Label 1
D10
Expression in each language
Structured ladder
_IN
_L
MID
*1 Label 2
ST
MID(_IN,_L ,_P);
Example:
Label 2:=
MID(Label 1,D10,D20);
D20 _P
X000
Label 1
EN
MID_E
ENO
_IN
D10 _L
D20 _P
*1 Label 2
MID_E(EN,_IN,_L ,_P,Output label);
Example:
MID_E(X000,Label 1,D10,D20,
Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN ( s
)
_L ( n1
)
_P ( n2
)
ENO
*1 ( d
)
Description
Execution condition
Head word device which stores a character string
Bit
String
Data type
Word device which stores the number of characters to be obtained Word [signed]
Word device which stores the head character position of a character string to be obtained
Execution status
Word [signed]
Bit
Head word device which will store the obtained character string String
In explanation of functions, I/O variables inside ( ) are described.
3
4
5
6
A
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"
1st word
2nd word
3rd word
4th word
5th word
6th word
High-order byte Low-order byte
42H(B)
44H(D)
46H(F)
32H(2)
34H(4)
00H
41H(A)
43H(C)
45H(E)
31H(1)
33H(3)
35H(5)
Head character position of a character string to be extracted n2
= 5th character
High-order byte Low-order byte
46H(F)
32H(2)
00H
45H(E)
31H(1)
33H(3)
1st word
2nd word
3rd word
Number of characters to
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 processing.
n1
is "0", this function does not execute
4) When the number of characters to be extracted specified in character of a character string specified in s n1
is "-1", this function outputs the final
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 string stored in devices specified in
(Error code: K6706) s n2
exceeds the number of characters of a character
3) When the number of characters specified in
(Error code: K6706) n1
exceeds the range of devices specified in 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
(Error code: K6706) n2
is negative
6) When the value specified in
(Error code: K6706) n1
is "-2" or less
7) When the value specified in devices specified in
(Error code: K6706) s n1
exceeds the number of characters of a character string stored in
182
FXCPU Structured Programming Manual
(Application Functions) 5.8 Standard Character String Functions
Program example
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
.
1) Function without EN/ENO(MID)
[Structured ladder]
MID g_string1="ABCDEF12345" g_int1=5
_IN
_L g_int2=5 _P g_string2="EF123"
[ST] g_string2:=MID(g_string1,g_int1,g_int2);
2) Function with EN/ENO(MID_E)
[Structured ladder] g_bool1 g_string1
EN
_IN g_int1 _L g_int2 _P
MID_E
ENO g_bool3 g_string2
[ST] g_bool3:=MID_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
1
2
3
4
5
6
A
183
FXCPU Structured Programming Manual
(Application Functions)
5.8.2
CONCAT(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function connects character strings.
1. Format
Function name
CONCAT
Label 1
Label 2
Expression in each language
Structured ladder
_IN
_IN
CONCAT
*1 Label 3
ST
CONCAT(_IN,_IN);
Example:
Label 3:=
CONCAT(Label 1,Label 2);
CONCAT_E
X000
EN
CONCAT_E
ENO
Label 1 _IN *1 Label 3
Label 2 _IN
CONCAT_E(EN,_IN,_IN,Output label);
Example:
CONCAT_E(X000,Label 1,Label 2,
Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN (
_IN (
ENO s1 s2
)
)
*1 ( d
)
Description
Execution condition Bit
Head word device which stores the data (character string) to be connected, or directly specified character string
String
Execution status
Head word device which will store the connected data (character string)
Bit
String
In explanation of functions, I/O variables inside ( ) are described.
Data type
184
FXCPU Structured Programming Manual
(Application Functions) 5.8 Standard Character String Functions
Explanation of function and operation
1) This function connects a character string stored in devices specified in stored in devices specified in s1 s2
after a character string
, 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.
"ABCDE" "123456" "ABCDE123456"
1st word
2nd word
3rd word
High-order byte Low-order byte
42H(B) 41H(A)
44H(D)
00H
43H(C)
45H(E)
1st word
2nd word
3rd word
4th word
High-order byte Low-order byte
32H(2) 31H(1) 1st word
High-order byte Low-order byte
42H(B) 41H(A)
34H(4)
36H(6)
0000H
33H(3)
35H(5)
2nd word
3rd word
44H(D)
31H(1)
43H(C)
45H(E)
4th word
5th word
6th word
33H(3)
35H(5)
00H
32H(2)
34H(4)
36H(6)
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) 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.
4) When both a character string stored in devices specified in specified in s2 s1
and a character string stored in devices
begin with "00H" (when character = 0), this function stores "0000H" in devices specified
1
2
3
4
5
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 character string obtained by connection d
is smaller than the number of
(In this case, "00H" cannot be stored after all character strings and final character.)
(Error code: K6706)
overlap device numbers specified 2) When devices which store character strings specified in s1
and in d
which will store the character string obtained by connection
(Error code: K6706) s2
3) When "00H" does not exist in the corresponding device range after devices specified in
(Error code: K6706) s1
and s2
6
A
185
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 stored in devices specified in s1 s2
is connected after a character string
, 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"
_IN
_IN g_string3="ABCDEF12345"
[ST] g_string3:=CONCAT(g_string1,g_string2);
2) Function with EN/ENO(CONCAT_E)
[Structured ladder] g_bool1 g_string1 g_string2
EN
CONCAT_E
ENO
_IN
_IN g_bool3 g_string3
[ST] g_bool3:=CONCAT_E(g_bool1,g_string1,g_string2,g_string3);
186
FXCPU Structured Programming Manual
(Application Functions)
5.8.3
INSERT(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
2
Outline
This function inserts a character string.
1. Format
Function name
INSERT
INSERT_E
Expression in each language
Structured ladder
Label 1 _IN1
Label 2
D20
_IN2
_P
INSERT
*1 Label 3
ST
INSERT(_IN1,_IN2,_P);
Example:
Label 3:=
INSERT(Label 1,Label 2,D20);
X000
Label 1
Label 2
D20
EN
INSERT_E
ENO
_IN1
_IN2
_P
*1 Label 3
INSERT_E(EN,_IN1,_IN2,_P,
Output label);
Example:
INSERT_E(X000,Label 1,Label 2,
D20,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
)
_P (
ENO n
)
*1 ( d
)
Description
Execution condition
Head word device which stores a character string to get insertion
Head word device which stores a character string to be inserted
Bit
String
String
Data type
Word device which stores a character position to get insertion
Execution status
Word [signed]
Bit
Head word device which will store a character string obtained by insertion
String
In explanation of functions, I/O variables inside ( ) are described.
3
4
5
6
A
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
The value specified in n d
.
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 devices specified in s1 s2
into a character string stored in
, 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
"ABCDE"
Output value
"ABC123456DE"
1st word
2nd word
3rd word
High-order byte Low-order byte
42H(B) 41H(A)
44H(D) 43H(C)
00H 45H(E)
"123456"
Insertion start position n
= 4th character
High-order byte Low-order byte
42H(B)
31H(1)
41H(A)
43H(C)
33H(3)
35H(5)
32H(2)
34H(4)
44H(D)
00H
36H(6)
45H(E)
1st word
2nd word
3rd word
4th word
5th word
6th word
1st word
2nd word
3rd word
4th word
High-order byte Low-order byte
32H(2) 31H(1)
34H(4) 33H(3)
36H(6) 35H(5)
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)
2) When devices which store character strings specified in s1
and in d
which will store the character string obtained by connection
(Error code: K6706) s2 d
is smaller than the number of
overlap device numbers specified
3) When "00H" does not exist in the corresponding device range after devices specified in
(Error code: K6706) s1
4) When the number of characters of a character string stored in devices specified in
(Error code: K6706) s2
and s2
is 32768 or more
5) When the value specified in
(Error code: K6706) n
is negative
188
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 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
.
1) Function without EN/ENO(INSERT)
[Structured ladder] g_string1="ABCDEF" g_string2="12345"
_IN1
_IN2 g_int1=3 _P
INSERT g_string3="AB12345CDEF"
[ST] g_string3:=INSERT(g_string1,g_string2,g_int1);
2) Function with EN/ENO(INSERT_E)
[Structured ladder] g_bool1
EN
INSERT_E
ENO
_IN1 g_string1 g_string2 _IN2 g_int1 _P g_bool3 g_string3
[ST] g_bool3:=INSERT_E(g_bool1,g_string1,g_string2,g_int1,g_string3);
1
2
3
4
5
6
A
189
FXCPU Structured Programming Manual
(Application Functions)
5.8.4
DELETE(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
190
Outline
This function deletes a character string.
1. Format
Function name
DELETE
DELETE_E
Expression in each language
Structured ladder
Label 1 _IN
D10
D20
_L
_P
DELETE
*1 Label 2
ST
DELETE(_IN,_L ,_P);
Example:
Label 2:=
DELETE(Label 1,D10,D20);
X000
Label 1 _IN
D10
D20
EN
DELETE_E
ENO
_L
_P
*1 Label 2
DELETE_E(EN,_IN,_L ,_P,
Output label);
Example:
DELETE_E(X000, Label 1,
D10, D20, Label 2);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN ( s
)
_L ( n1
)
_P (
ENO n2
)
*1 ( d
)
Description
Execution condition
Head word device which stores a character string to get deletion
Bit
String
Data type
Number of characters to be deleted Word [signed]
Head position to get deletion
Execution status
Head word device which will store a character string remaining after deletion
Word [signed]
Bit
String
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
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"
1st word
2nd word
3rd word
4th word
High-order byte Low-order byte
42H(B)
44H(D)
41H(A)
43H(C)
46H(F)
32H(2)
45H(E)
31H(1)
5th word
6th word
34H(4)
00H
33H(3)
35H(5)
Deletion start position n2
= 5th character
Number of characters
High-order byte Low-order byte
42H(B) 41H(A) 1st word
44H(D) 43H(C) 2nd word
35H(5)
0000H
34H(4) 3rd word
4th word
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.
FXCPU Structured Programming Manual
(Application Functions) 5.8 Standard Character String Functions
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" does not exist in the corresponding device range after the device specified in
(Error code: K6706) s
2) When the number of characters of a character string stored in devices specified in
(Error code: K6706) s
is 32768 or more
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)
4) When the value specified in
(Error code: K6706) n2
is negative
Program example
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
.
1) Function without EN/ENO(DELETE)
[Structured ladder]
DELETE g_string2="AB12345" g_string1="ABCDEF12345" g_int1="4"
_IN
_L g_int2="3" _P
[ST] g_string2:=DELETE(g_string1,g_int1,g_int2);
2) Function with EN/ENO(DELETE_E)
[Structured ladder] g_bool1
EN
DELETE_E
ENO g_string1 _IN g_int1 _L g_int2 _P g_bool3 g_string2
[ST] g_bool3:=DELETE_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
1
2
3
4
5
6
A
191
FXCPU Structured Programming Manual
(Application Functions)
5.8.5
REPLACE(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function replaces a character string.
1. Format
Function name
REPLACE
REPLACE_E
D30
Expression in each language
Structured ladder
*1 Label 3
ST
REPLACE(_IN1,_IN2,_L ,_P);
Example:
Label 3:=
REPLACE(Label 1,Label 2,
D20,D30);
_P
REPLACE
Label 1 _IN1
Label 2 _IN2
D20 _L
X000
Label 1
Label 2
EN
REPLACE_E
ENO
_IN1
_IN2
D20 _L
D30 _P
*1 Label 3
REPLACE_E(EN,_IN1,_IN2,
_L ,_P,Output label);
Example:
REPLACE_E(X000,Label 1,
Label 2,D20,D30,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
_IN2 ( s2
)
)
_L ( n1
)
_P ( n2
)
ENO
*1 ( d
)
Description
Execution condition
Head word device which stores a character string to be replaced
Bit
String
Data type
Head word device which stores a replacement character string String
Word device which stores the number of characters to be replaced Word [signed]
Word device which stores the head character position to be replaced in a character string to be replaced
Execution status
Head word device which will store a character string obtained by replacement
Word [signed]
Bit
String
In explanation of functions, I/O variables inside ( ) are described.
192
FXCPU Structured Programming Manual
(Application Functions) 5.8 Standard Character String Functions
Explanation of function and operation
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
"ABCDEFGH123"
Output value
"ABCD1234523"
1st word
2nd word
3rd word
4th word
5th word
6th word
High-order byte Low-order byte
42H(B)
44H(D)
46H(F)
48H(H)
41H(A)
43H(C)
45H(E)
47H(G)
32H(2)
00H
31H(1)
33H(3)
Replacement start position n2
= 5th character
High-order byte Low-order byte
42H(B)
44H(D)
32H(2)
34H(4)
41H(A)
43H(C)
31H(1)
33H(3)
32H(2)
00H
35H(5)
33H(3)
1st word
2nd word
3rd word
4th word
5th word
6th word
Number of characters
"123456"
1st word
2nd word
3rd word
4th word
High-order byte Low-order byte
32H(2)
34H(4)
36H(6)
31H(1)
33H(3)
35H(5)
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.
3) When "n1+n2" exceeds the number of characters of a character string stored in devices specified in excessive characters are not output to devices specified in d
.
s1
,
4) When "-1" is specified in in s2 n1
, the number of characters of a character string stored in devices specified
is regarded as the value specified in n1
.
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.
1
2
3
4
5
6
A
193
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 s2
(Error code: K6706)
and
2) When the value specified in devices specified in
(Error code: K6706) s2 n1
exceeds the number of characters of a character string stored in
3) When the value specified in
(Error code: K6706) n2
is negative
4) When the value specified in
(Error code: K6706) n1
is "-2" or less
5) When the value specified in devices specified in
(Error code: K6706) s1 n2
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] g_string1="ABCDEFGH" _IN1 g_string2="012345678" _IN2 g_int1=6 _L g_int2=3 _P
REPLACE g_string3="AB012345"
[ST] g_string3:=REPLACE(g_string1,g_string2,g_int1,g_int2);
2) Function with EN/ENO(REPLACE_E)
[Structured ladder] g_bool1
EN
REPLACE_E
ENO
_IN1 g_string1 g_string2 _IN2 g_int1 _L g_int2 _P g_bool3 g_string3
[ST] g_bool3:=REPLACE_E(g_bool1,g_string1,g_string2,g_int1,g_int2,g_string3);
194
FXCPU Structured Programming Manual
(Application Functions)
5.8.6
FIND(_E)
5.8 Standard Character String Functions
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
2
Outline
This function searches a character string.
1. Format
Function name
FIND
FIND_E
Expression in each language
Structured ladder
Label 1
Label 2
_IN1
_IN2
FIND
*1 D20
ST
FIND(_IN1,_IN2);
Example:
D20:=
FIND(Label 1,Label 2);
X000
Label 1
Label 2
EN
FIND_E
ENO
_IN1
_IN2
*1 D20
FIND_E(EN,_IN1,_IN2,Output label);
Example:
FIND_E(X000,Label 1,Label 2,
D20);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Head word device which stores a character string to get search
Head word device which stores a character string to be searched
Execution status
Head word device which will store the search result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
String
String
Bit
Word [signed]
3
4
5
6
A
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 character string stored in devices specified in s1 s2
from the beginning of a
, 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 devices specified in s1
, this function outputs "0".
s2
cannot be detected in a character string stored in
"ABCD1234567"
Output value
5
Word [signed]
1st word
2nd word
3rd word
4th word
5th word
6th word
High-order byte Low-order byte
42H(B)
44H(D)
41H(A)
43H(C)
32H(2)
34H(4)
31H(1)
33H(3)
36H(6)
00H
35H(5)
37H(7)
Search of character string
"1234"
1st word
2nd word
3rd word
High-order byte Low-order byte
32H(2)
34H(4)
31H(1)
33H(3)
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
(Error code: K6706) s1
2) When "00H (NULL)" does not exist in the corresponding device range specified in
(Error code: K6706) s2
196
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 character string stored in devices specified in s1 s2
is searched from the beginning of a
, and the search result is output to devices specified in d
.
1) Function without EN/ENO(FIND)
[Structured ladder] g_string1="ABCDEFGHIJK" g_string2="EFGHIJK"
_IN1
_IN2
FIND g_int1=5
[ST] g_int1:=FIND(g_string1,g_string2);
2) Function with EN/ENO(FIND_E)
[Structured ladder] g_bool1 g_string1 g_string2
EN
_IN1
FIND_E
ENO
_IN2 g_bool3 g_int1
[ST] g_bool3:=FIND_E(g_bool1,g_string1,g_string2,g_int1);
1
2
3
4
5
6
A
197
FXCPU Structured Programming Manual
(Application Functions)
5.9
Functions Of Time Data Types
5.9.1
ADD_TIME(_E)
5.9 Functions Of Time Data Types
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function adds time data.
1. Format
Function name
ADD_TIME
ADD_TIME_E
Label 1
Label 2
Expression in each language
Structured ladder
ADD_TIME
_IN1
_IN2
*1 Label 3
ST
ADD_TIME(_IN1,_IN2);
Example:
Label 3:=
ADD_TIME(Label 1,Label 2);
X000
Label 1
ADD_TIME_E
EN ENO
_IN1
Label 2 _IN2
*1 Label 3
ADD_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
ADD_TIME_E(X000,Label 1,
Label 2,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
_IN2 ( s2
ENO
*1 ( d
)
)
)
Description
Execution condition
Head word device which stores time data to get addition
Head word device which stores addition time data
Execution status
Head word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
Time
Time
Bit
Time
Data type
Explanation of function and operation
This function performs addition ( s1
+ s2
) of time data stored in devices specified in outputs the operation result expressed as time data to devices specified in d
.
s1
and s2
, and
198
FXCPU Structured Programming Manual
(Application Functions) 5.9 Functions Of Time Data Types
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.
("ADD_TIME_E" outputs "TRUE" from ENO.)
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
M8020
M8021
M8022
Name
Zero
Borrow
Carry
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
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
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
-2 , -1 , 0 , -32,768
Zero flag
-1 , 0 , 1
Zero flag
32,767 , 0 , 1 , 2
Borrow flag
Zero flag
-2 , -1 , 0 , -2,147,483,648
The most significant bit of data is "1".
-1 , 0 , 1
The most significant bit of data is "0".
Carry flag
Zero flag
2,147,483,647 , 0 , 1 , 2
Borrow flag Zero flag Carry flag
Program example
In this program, addition ( s2 s1
+ s2
) is performed using time data stored in devices specified in
, and the operation result expressed as time data is output to devices specified in d
.
1) Function without EN/ENO(ADD_TIME) s1
and
[Structured ladder]
ADD_TIME g_time1 _IN1 g_time2 _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
EN
ADD_TIME_E
ENO
_IN1
_IN2 g_bool3 g_time3
[ST] g_bool3:=ADD_TIME_E(g_bool1,g_time1,g_time2,g_time3);
1
2
3
4
5
6
A
199
FXCPU Structured Programming Manual
(Application Functions)
5.9.2
SUB_TIME(_E)
5.9 Functions Of Time Data Types
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs subtraction of time data.
1. Format
Function name
SUB_TIME
SUB_TIME_E
Label 1
Label 2
Expression in each language
Structured ladder
SUB_TIME
_IN1
_IN2
*1 Label 3
ST
SUB_TIME(_IN1,_IN2);
Example:
Label 3:=
SUB_TIME(Label 1,Label 2);
X000
Label 1
SUB_TIME_E
EN ENO
_IN1
Label 2 _IN2
*1 Label 3
SUB_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
SUB_TIME_E(X000,Label 1,
Label 2,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Head word device which stores time data to get subtraction
Head word device which stores subtraction data
Execution status
Head word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Bit
Time
Time
Bit
Time
Data type
Explanation of function and operation
This function performs subtraction ( s1
s2
) of time data stored in devices specified in outputs the operation result expressed as time data to devices specified in d
.
s1
and s2
, and
200
FXCPU Structured Programming Manual
(Application Functions) 5.9 Functions Of Time Data Types
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.
("SUB_TIME_E" outputs "TRUE" from ENO.)
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Device
M8020
M8021
M8022
Name
Zero
Borrow
Carry
Description
ON : When the operation result is "0"
OFF: When the operation result is any other than "0"
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
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
-2 , -1 , 0 , -32,768
Zero flag
-1 , 0 , 1
Zero flag
32,767 , 0 , 1 , 2
Borrow flag The most significant bit of data is "1".
Zero flag
-2 , -1 , 0 , -2,147,483,648 -1 , 0 , 1
The most significant bit of data is "0".
Carry flag
Zero flag
2,147,483,647 , 0 , 1 , 2
Borrow flag Zero flag Carry flag
Program example
In this program, subtraction ( s2 s1
s2
) is performed using time data stored in devices specified in
, and the operation result expressed as time data is output to devices specified in d
.
1) Function without EN/ENO(SUB_TIME) s1
and
[Structured ladder]
SUB_TIME g_time1 _IN1 g_time2 _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
EN
SUB_TIME_E
ENO
_IN1
_IN2 g_bool3 g_time3
[ST] g_bool3:=SUB_TIME_E(g_bool1,g_time1,g_time2,g_time3);
1
2
3
4
5
6
A
201
FXCPU Structured Programming Manual
(Application Functions)
5.9.3
MUL_TIME(_E)
5.9 Functions Of Time Data Types
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs multiplication of time data.
1. Format
Function name
MUL_TIME
MUL_TIME_E
Label 1
Label 2
Expression in each language
Structured ladder
MUL_TIME
_IN1
_IN2
*1 Label 3
ST
MUL_TIME(_IN1,_IN2);
Example:
Label 3:=
MUL_TIME(Label 1,Label 2);
X000
Label 1
MUL_TIME_E
EN ENO
_IN1
Label 2 _IN2
*1 Label 3
MUL_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
MUL_TIME_E(X000,Label 1,
Label 2,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Head word device which stores time data to get multiplication
Multiplication data, or head word device which stores such data
Execution status
Head word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Time
ANY_NUM
Bit
Time
Explanation of function and operation
This function performs multiplication( s2 s1
× s2
) using time data stored in devices specified in
, and outputs the operation result expressed as time data to devices specified in d
.
s1
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.
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
Program example
In this program, multiplication ( and s2 s1
× s2
) is performed using time data stored in devices specified in
, and the operation result expressed as time data is output to devices specified in d
.
1) Function without EN/ENO(MUL_TIME) s1
[Structured ladder]
MUL_TIME g_time1 _IN1 g_int1 _IN2 g_time2
[ST] g_time2:=MUL_TIME(g_time1,g_int1);
2) Function with EN/ENO(MUL_TIME_E)
[Structured ladder] g_bool1
EN
MUL_TIME_E
ENO g_time1 _IN1 g_int1 _IN2 g_bool3 g_time2
[ST] g_bool3:=MUL_TIME_E(g_bool1,g_time1,g_int1,g_time2);
1
2
3
4
5
6
A
203
FXCPU Structured Programming Manual
(Application Functions)
5.9.4
DIV_TIME(_E)
5.9 Functions Of Time Data Types
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function performs division using time data.
1. Format
Function name
DIV_TIME
DIV_TIME_E
Label 1
Label 2
Expression in each language
Structured ladder
DIV_TIME
_IN1
_IN2
*1 Label 3
ST
DIV_TIME(_IN1,_IN2);
Example:
Label 3:=
DIV_TIME(Label 1,Label 2);
X000
Label 1
DIV_TIME_E
EN ENO
_IN1
Label 2 _IN2
*1 Label 3
DIV_TIME_E(EN,_IN1,_IN2,
Output label);
Example:
DIV_TIME_E(X000,Label 1,
Label 2,Label 3);
*1.
Output variable
2. Set data
Input variable
Output variable
Variable
EN
_IN1 ( s1
)
_IN2 ( s2
ENO
*1 ( d
)
)
Description
Execution condition
Head word device which stores time data to get division
Division data, or head word device which stores such data
Execution status
Head word device which will store the operation result
In explanation of functions, I/O variables inside ( ) are described.
Data type
Bit
Time
ANY_NUM
Bit
Time
Explanation of function and operation
1) This function performs division ( s1
/ s2
) using time data stored in devices specified in 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".
s1
and s2
,
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 not executed.
s2
2) An operation error occurs when the operation result exceeds "2,147,483,647".
is "0", and the function is
204
FXCPU Structured Programming Manual
(Application Functions) 5.9 Functions Of Time Data Types
Program example
In this program, division ( s2 s1
/ s2
) is performed using time data stored in devices specified in
, and the operation result expressed as time data is output to devices specified in d
.
1) Function without EN/ENO(DIV_TIME) s1
and
[Structured ladder]
DIV_TIME g_time1 _IN1 g_int1 _IN2 g_time2
[ST] g_time2:=DIV_TIME(g_time1,g_int1);
2) Function with EN/ENO(DIV_TIME_E)
[Structured ladder] g_bool1
EN
DIV_TIME_E
ENO g_time1 _IN1 g_int1 _IN2 g_bool3 g_time2
[ST] g_bool3:=DIV_TIME_E(g_bool1,g_time1,g_int1,g_time2);
1
2
3
4
5
6
A
205
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.1 R_TRIG(_E)
6. Standard Function Blocks
6.1
R_TRIG(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function block detects the rising edge of a signal, and outputs pulse signal.
1. Format
Function name
R_TRIG
R_TRIG_E
M0
Expression in each language
Structured ladder
Instance name
R_TRIG
_CLK Q M10
ST
R_TRIG(_CLK); *1
Example:
Instance name(_CLK:=M0);
M10:=Instance name.Q;
X000
M0
Instance name
R_TRIG_E
EN
_CLK
ENO
Q M10
R_TRIG_E(EN,_CLK); *1
Example:
Instance name(EN:=X000,
_CLK:=M0);
M10:=Instance name.Q;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
_CLK (
ENO
Q ( s
) d
)
Description
Execution condition
Input signal whose rising edge is to be detected
Execution status
Output signal
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Bit
Bit
Data type
Explanation of function and operation
This function block sets to ON a device specified in keeps ON the device specified in d d
when a device specified in
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 FX
3U
and FX
3UC
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)
Program example
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.
1) Function without EN/ENO(R_TRIG) s
[Structured ladder]
R_TRIG_Instance g_bool1 _CLK
R_TRIG
Q g_bool2
[ST]
R_TRIG_Instance(_CLK:=g_bool1);g_bool2:=R_TRIG_Instance.Q;
2) Function with EN/ENO(R_TRIG_E)
[Structured ladder]
X000 g_bool1
R_TRIG_E_Instance
EN
_CLK
R_TRIG_E
ENO
Q
Y010 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;
1
2
3
4
5
6
A
207
FXCPU Structured Programming Manual
(Application Functions)
6.2
F_TRIG(_E)
6 Standard Function Blocks
6.2 F_TRIG(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function block detects the falling edge of a signal, and outputs pulse signal.
1. Format
Function name
F_TRIG
F_TRIG_E
X000
M0
M0
Expression in each language
Structured ladder
Instance name
F_TRIG
_CLK Q M10
ST
F_TRIG(_CLK); *1
Example:
Instance name(_CLK:=M0);
M10:=Instance name.Q;
Instance name
F_TRIG_E
EN ENO
_CLK Q M10
F_TRIG_E(EN,_CLK); *1
Example:
Instance name(EN:=X000,
_CLK:=M0);
M10:=Instance name.Q;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
_CLK (
ENO
Q ( s
) d
)
Description
Execution condition
Input signal whose falling edge is to be detected
Execution status
Output signal
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Bit
Bit
Data type
Explanation of function and operation
This function block sets to ON a device specified in keeps ON the device specified in d d
when a device specified in
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 FX
3U
and FX
3UC
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)
Program example
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.
1) Function without EN/ENO(F_TRIG) s
[Structured ladder]
F_TRIG_Instance g_bool1 _CLK
F_TRIG
Q g_bool2
[ST]
F_TRIG_Instance(_CLK:=g_bool1);g_bool2:=F_TRIG_Instance.Q;
2) Function with EN/ENO(F_TRIG_E)
[Structured ladder]
X000 g_bool1
F_TRIG_E_Instance
EN
_CLK
F_TRIG_E
ENO Y010
Q g_bool2
[ST]
F_TRIG_E_Instance(EN:=X000,_CLK:=g_bool1);Y010=F_TRIG_E_Instance; g_bool2:=F_TRIG_E_Instance.Q;
1
2
3
4
5
6
A
209
FXCPU Structured Programming Manual
(Application Functions)
6.3
CTU(_E)
6 Standard Function Blocks
6.3 CTU(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function block counts up the number of times of rising of a signal.
1. Format
Function name
CTU
M0
M10
D0
Expression in each language
Structured ladder
Instance name
CU
CTU
RESET
PV
Q M20
CV D10
ST
CTU(CU,RESET,PV); *1
Example:
Instance name(CU:=M0,
RESET=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
CTU_E
X000
M0
M10
D0
Instance name
EN
CTU_E
ENO
CU
RESET
Q M20
CV D10
PV
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
CU (
RESET (
PV
ENO
( s1 s2 n
Q
CV
(
( d1 d2
)
)
)
)
)
Execution condition
Count source signal
Reset input signal
Counter set value
Execution status
Count-up output signal
Number of times of rising
Description
In explanation of functions, I/O variables inside ( ) are described.
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;
Data type
Bit
Bit
Bit
Word [signed]
Bit
Bit
Word [signed]
Explanation of function and operation
This function block counts up (adds "1" to) the value stored in a device specified in specified in s1
turns ON.
When the count value reaches a value specified in
When a device specified in s2 n
, a device specified in d1
turns ON.
turns ON, this function block turns OFF a device specified in resets the count value of a device specified in d2
.
d2
when a device d1
, 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.
210
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.3 CTU(_E)
Program example
In this program, the number of times the bit data stored in a device specified in counted, and the count value is output to a device specified in d2
.
s1
1) Function without EN/ENO(CTU)
turns ON from OFF is
[Structured ladder] g_bool1 g_bool2
CTU_Instance
CTU
CU
RESET
Q g_bool3
CV g_int2 g_int1 PV
[ST]
CTU_Instance(CU:=g_bool1,RESET:=g_bool2,PV:=g_int1); g_bool3:=CTU_Instance.Q; g_int2:=CTU_Instance.CV;
2) Function with EN/ENO(CTU_E)
[Structured ladder]
M10
EN g_bool1 CU
CTU_E_Instance
CTU_E g_bool2 RESET g_int1 PV
ENO M11
Q g_bool3
CV g_int2
[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;
1
2
3
4
5
6
A
211
FXCPU Structured Programming Manual
(Application Functions)
6.4
CTD(_E)
6 Standard Function Blocks
6.4 CTD(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function block counts down the number of times of rising of a signal.
1. Format
Function name
CTD
M0
M10
D0
Expression in each language
Structured ladder
Instance name
CD
CTD
LOAD
PV
Q M20
CV D10
ST
CTD(CD,LOAD,PV); *1
Example:
Instance name(CD:=M0,
LOAD=M10, PV=D0);
M20:=Instance name.Q;
D10:=Instance name.CV;
CTD_E
X000
M0
M10
D0
Instance name
EN
CTD_E
ENO
CD
LOAD
Q M20
CV D10
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;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
CD (
LOAD (
PV
ENO
( s1 s2 n
)
)
)
Q
CV
(
( d1 d2
)
)
Description Data type
Execution condition
Count source signal
Reset input signal
Counter set value
Bit
Bit
Bit
Word [signed]
Execution status
Output signal (which turns ON when the current counter value becomes "0" or less)
Number of times of rising
Bit
Bit
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 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 the initial value for subtraction specified in n
to the count value of a device specified in d2
.
d1 d2
when a
, and sets
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.
212
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.4 CTD(_E)
Program example
In this program, the number of times the bit data stored in a device specified in counted, and a device specified in becomes "0".
d1 s1
turns ON from OFF is
turns ON when the value stored in a device specified in d2
1) Function without EN/ENO(CTD)
[Structured ladder] g_bool1 g_bool2
CTD_Instance
CTD
CD
LOAD
Q g_bool3
CV g_int2 g_int1 PV
[ST]
CTD_Instance(CD:=g_bool1,LOAD:=g_bool2,PV:=g_int1); g_bool3:=CTD_Instance.Q; g_int2:=CTD_Instance.CV;
2) Function with EN/ENO(CTD_E)
[Structured ladder]
M10
EN g_bool1 CD
CTD_E_Instance
CTD_E g_bool2 LOAD g_int1 PV
ENO M11
Q g_bool3
CV 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;
1
2
3
4
5
6
A
213
FXCPU Structured Programming Manual
(Application Functions)
6.5
CTUD(_E)
6 Standard Function Blocks
6.5 CTUD(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
Outline
This function block counts up/down the number of times of rising of a signal.
1. Format
Function name
CTUD
M0
M10
M20
M30
D0
Expression in each language
Structured ladder
Instance name
CU
CD
CTUD
RESET
LOAD
PV
QU M40
QD
CV
M50
D10
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;
CTUD_E
X000
M0
M10
M20
M30
D0
Instance name
CTUD_E
EN ENO
CU
CD
QU
QD
M40
M50
CV D10 RESET
LOAD
PV
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;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
CU ( s1
)
CD (
RESET ( s2 s3
LOAD ( s4
PV
ENO
QU
(
( n d1
)
)
)
)
)
QD ( d2
)
Description Data type
Execution condition
Count up signal
Count down signal
Reset input signal
Resetting signal
Bit
Bit
Bit
Bit
Bit
Counter set value
Execution status
Count-up output signal
Output signal (which turns ON when the current counter value becomes "0" or less)
Count value data
Word [signed]
Bit
Bit
Bit
Word [signed] CV ( d3
)
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 specified in s1
turns ON.
d3
when a device
This function block counts down (subtracts "1" from) the value stored in a device specified in device specified in s2
turns ON.
d3
when a n
specifies the maximum value of the counter.
When the value stored in a device specified in d3 specified in d1
turns ON.
When the value stored in a device specified in d3
reaches the maximum value n
of the counter, a device
becomes "0", a device specified in d2
turns ON.
214
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.5 CTUD(_E)
This function block resets the count value of a device specified in
ON.
This function block sets the value stored in turns ON.
n d3
when a device specified in
to a device specified in d3 s3
turns
when a device specified in s4
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.
1
2
3
4
5
6
A
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 counted up (added by "1"). When the value stored in a device specified in d3 s1
turns ON from OFF is
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 counted down (subtracted by "1"). When the value stored in a device specified in specified in d2
turns ON.
s2 d3
turns ON from OFF is
becomes "0", a device
1) Function without EN/ENO(CTUD)
[Structured ladder]
CTUD_Instance
CTUD g_bool1 CU g_bool2 CD g_bool3 RESET g_bool4 LOAD g_int1 PV
QU g_bool5
QD g_bool6
CV g_int2
[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]
M0
EN g_bool1 CU g_bool2 g_bool3
CTUD_E_Instance
CTUD_E
CD
RESET g_bool4 LOAD g_int1 PV
ENO
QU
M10 g_bool5
QD g_bool6
CV 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)
6 Standard Function Blocks
6.6 TP(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function block keeps ON a signal for specified duration.
1. Format
Function name
TP
TP_E
M0
Label 1
X000
M0
Label 1
Expression in each language
Structured ladder
Instance name
IN
PT
TP
Q
ET
M10
Label 2
ST
TP(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
Instance name
EN
TP_E
ENO
IN
PT
Q
ET
M10
Label 2
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;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
IN (
PT (
ENO s n
Q (
ET ( d1 d2
)
)
)
)
Execution condition
ON start input signal
ON duration data
Execution status
Output signal
ON duration current value
Description
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Time
Bit
Bit
Time
Data type
Explanation of function and operation
When a device specified in it ON for duration specified in s n
turns ON, this function block turns ON a device specified in
.
The elapsed time while a device specified in
A device specified in d1 d1
remains ON is set to a device specified in
turns OFF when the elapsed time reaches the set value.
d1 d2
.
, and keeps
Even if a device specified in device specified in s d1
turns OFF, this function block does not reset the elapsed time. When a
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.
2
3
4
5
6
A
217
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) s
turns ON, bit data stored in a device
[Structured ladder] g_bool1 IN
T#10s PT
TP_Instance
TP
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
EN
IN
TP_E_Instance
TP_E
ENO M10
Q g_bool2
PT ET g_time1
[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
FXCPU Structured Programming Manual
(Application Functions)
6.7
TON(_E)
6 Standard Function Blocks
6.7 TON(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
This function block turns ON after specified time.
1. Format
Function name
TON
TON_E
M0
Label 1
X000
M0
Label 1
Expression in each language
Structured ladder
Instance name
IN
PT
TON
Q
ET
M10
Label 2
ST
TON(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
Instance name
EN
TON_E
ENO
IN
PT
Q
ET
M10
Label 2
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;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
IN (
PT (
ENO s n
Q (
ET ( d1 d2
)
)
)
)
Execution condition
Input signal
ON start time data
Execution status
Output signal
ON start time current value
Description
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Time
Bit
Bit
Time
Data type
Explanation of function and operation
When a device specified in time specified in n
.
s
turns ON, this function block turns ON a device specified in d1
The delay elapsed time until a device specified in
When a device specified in resets the delay elapsed time.
s d1
turns ON is set to a device specified in d2
turns OFF, this function block turns OFF a device specified in
.
after the d1
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.
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.
2
3
4
5
6
A
219
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) s
turns ON, bit data stored in a device
[Structured ladder] g_bool1 IN
T#10s PT
TON_Instance
TON
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
IN
ENO M10
Q g_bool2
PT ET g_time1
[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
FXCPU Structured Programming Manual
(Application Functions)
6.8
TOF(_E)
6 Standard Function Blocks
6.8 TOF(_E)
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
When the input signal turns OFF, this function block turns OFF the output signal after the specified time.
1. Format
Function name
TOF
TOF_E
M0
Label 1
X000
M0
Label 1
Expression in each language
Structured ladder
Instance name
IN
PT
TOF
Q
ET
M10
Label 2
ST
TOF(IN,PT); *1
Example:
Instance name(IN:=M0,
PT:=Label 1);
M10:=Instance name.Q;
Label 2:=Instance name. ET;
Instance name
EN
TOF_E
ENO
IN
PT
Q
ET
M10
Label 2
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;
*1.
Refer to caution points.
2. Set data
Input variable
Output variable
Variable
EN
IN (
PT (
ENO s n
Q (
ET ( d1 d2
)
)
)
)
Execution condition
Input signal
OFF duration data
Execution status
Output signal
OFF duration current value
Description
In explanation of functions, I/O variables inside ( ) are described.
Bit
Bit
Time
Bit
Bit
Time
Data type
Explanation of function and operation
When a device specified in
When a device specified in s s
turns ON, this function block turns ON a device specified in d1
.
turns OFF from ON, this function block turns OFF a device specified in after the time specified in
When a device specified in resets the elapsed time.
n s
.
The elapsed time until a device specified in d1
turns OFF is set to a device specified in d2
.
turns ON again, this function block turns ON a device specified in d1 d1
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.
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.
2
3
4
5
6
A
221
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 specified in d1 s
turns ON, bit data stored in a device
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] g_bool1 IN
T#10s PT
TOF_Instance
TOF
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
IN
ENO M10
Q g_bool2
PT ET g_time1
[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
6 Standard Function Blocks
6.9 COUNTER_FB_M
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
Outline
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
Function name
COUNTER_FB_M
Expression in each language
Structured ladder ST
COUNTER_FB_M(Coil,Preset,
ValueIn); *1
Instance name
COUNTER_FB_M
Coil ValueOut
Preset
ValueIn
Status
Example:
Instance name
(Coil:=X000,Preset:=D0,
ValueIn:=D10);
D20:=Instance name
ValueOut;
M0:=Instance name
Status;
*1.
Refer to "Cautions".
2. Set data
Input variable
Output variable
Variable
Coil
Preset
ValueIn
ValueOut
Status
Execution condition
Counter set value
Counter initial value
Counter current value
Counter output contact
Description Data type
Bit
Word [signed]
Word [signed]
ANY16
Bit
Function and operation explanation
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.
timing chart [Structured ladder]
Var_M0
10
1
Instance name
COUNTER_FB_M
Coil ValueOut
Preset
ValueIn
Status
Var_D10
Var_M10
*1
*2
[ ST ]
Instance name (Coil:= Var_M0,Preset:=10,Valueln:=1);
Var_D10:=Instance name.ValueOut;
Var_M10:=Instance name.Status;
Var_M0
Value of Var_D10
Var_M10
1
ON
2
ON
3
ON
10
ON
*1.
Var_D10 is a global label and is defined as D10.
*2.
Var_M10 is a global label and is defined as M10.
2
3
4
5
6
A
223
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
6 Standard Function Blocks
6.10 TIMER_10_FB_M
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
1
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
Expression in each language
Structured ladder ST
TIMER_10_FB_M
Instance name
TIMER_10_FB_M
Coil ValueOut
Preset
ValueIn
Status
TIMER_10_FB_M(Coil,Preset,
ValueIn); *1
*1.
Refer to "Cautions".
2. Set data
Input variable
Output variable
Variable
Coil
Preset
ValueIn
ValueOut
Status
Execution condition
Timer set value
Initial timer value
Current timer value
Timer output contact
Description Data type
Bit
Word [signed]
Word [signed]
ANY16
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 × 10 ms". When it counts up to "Preset × 10 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]
Instance name
Var_M0
10
1
TIMER_10_FB_M
Coil
Preset
ValueIn
ValueOut Var_D10 *1
Status Var_M10 *2
[ 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.
timing chart
Var_M0
Value of Var_D10
Var_M10
1
ON
90ms
10
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.
2
3
4
5
6
A
225
FXCPU Structured Programming Manual
(Application Functions)
6.11
TIMER_CONT_FB_M
6 Standard Function Blocks
6.11 TIMER_CONT_FB_M
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(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
Expression in each language
Structured ladder ST
TIMER_
CONT_FB_M
Instance name
TIMER_CONT_FB_M
Coil ValueOut
Preset
ValueIn
Status
TIMER_CONT_FB_M(Coil,
Preset,ValueIn); *1
*1.
Refer to "Cautions".
2. Set data
Input variable
Output variable
Variable
Coil
Preset
ValueIn
ValueOut
Status
Execution condition
Timer set value
Initial timer value
Current timer value
Timer output contact
Description Data type
Bit
Word [signed]
Word [signed]
ANY16
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
Var_M0
200
0
TIMER_CONT_FB_M
Coil ValueOut
Preset
ValueIn
Status
Var_D10 *1
Var_M10 *2 timing chart
Var_M0
Value of Var_D10
0 1
ON
15 sec
150
ON
5 sec
151-200
[ 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
226
FXCPU Structured Programming Manual
(Application Functions)
6 Standard Function Blocks
6.11 TIMER_CONT_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 timer numbers are allocated automatically.
1
2
3
4
5
6
A
227
FXCPU Structured Programming Manual
(Application Functions)
6.12
TIMER_100_FB_M
6 Standard Function Blocks
6.12 TIMER_100_FB_M
FX 3U(C) FX 3G FX 2N(C) FX 1N(C) FX 1S FX U /FX 2C FX 0N FX 0(S)
228
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
Expression in each language
Structured ladder ST
TIMER_100_FB_M
Instance name
TIMER_100_FB_M
Coil ValueOut
Preset
ValueIn
Status
TIMER_100_FB_M(Coil,
Preset,ValueIn); *1
*1.
Refer to "Cautions".
2. Set data
Input variable
Output variable
Variable
Coil
Preset
ValueIn
ValueOut
Status
Execution condition
Timer set value
Initial timer value
Current timer value
Timer output contact
Description Data type
Bit
Word [signed]
Word [signed]
ANY16
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
TIMER_100_FB_M
Coil
10 Preset
ValueOut
Status
Var_D10
Var_M10
*1
*2
1 ValueIn
[ ST ]
Instance name
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.
timing chart
Var_M0
Value of Var_D10
Var_M10
1
ON
900ms
10
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.
FXCPU Structured Programming Manual
(Application Functions)
Appendix A: Correspondence between Devices and
1
Appendix A: Correspondence between Devices and
Addresses
The table below shows the correspondence between devices and addresses.
Input relay
Output relay
Auxiliary relay
Contact
Coil
Data register
Device
Intelligent function unit device
Extension register
Extension file register
Pointer
Interrupt pointer
Nesting
Index register
State
Current value
Contact
Coil
Current value
X
Y
M
TS
TC
TN
CS
CC
CN
D
G
R
ER
P
I
N
Z
V
S
Device
Xn
Yn
Mn
Tn
Tn
Tn
Cn
Cn
Cn
Dn
Ux\Gn
Rn
ERn
Pn
In
Nn
Zn
Vn
Sn
Notation
Address
%IXn
%QXn
%MX0.n
%MX3.n
%MX5.n
%MW3.n
%MD3.n
%MX4.n
%MX6.n
%MW4.n
%MD4.n
%MW0.n
%MD0.n
%MW14.x.n
%MD14.x.n
%MW2.n
%MD2.n
No correspondence
" "(NULL character)
No correspondence
No correspondence
%MW7.n
%MD7.n
%MW6.n
%MX2.n
Example of correspondence between device and address
X367
Y367
M499
TS191
Device Address
%IX247
%QX247
%MX0.499
%MX3.191
TC191
TN190
T190
CS99
CC99
CN98
C98
D198*
D198
U0\G09
U0\G09
R32766
R32766
P4095
Z6
Z6
V7
S4095
-
-
-
%MX5.191
%MW3.191
%MD3.190
%MX4.99
%MX6.99
%MW4.99
%MD4.98
%MW0.199
%MD0.198
%MW14.0.10
%MD14.0.9
%MW2.32767
%MD2.32766
-
No correspondence
-
-
%MW7.7
%MD7.6
%MW6.7
%MX2.4095
2
3
4
5
6
A
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.
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.
[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.
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.
[Gratis Warranty Range]
1) The range shall be limited to normal use within the usage state, usage methods and usage environment, etc., which follow the conditions and precautions, etc., given in the instruction manual, user's manual and caution labels on the product.
2) Even within the gratis warranty term, repairs shall be charged for in the following cases. 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.
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.
230
FXCPU Structured Programming Manual
(Application Functions) Revision History
Revision History
Date of preparation Revision
1/2009 A
7/2009 B
Description
First Edition.
• Equivalent circuits are deleted.
• Following instructions are not supported in FX 0 ,FX 0S and FX 0N 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)
MEMO
Revision History
232
FXCPU
Structured Programming Manual [Application Functions]
MODEL
MODEL CODE
HEAD OFFICE: TOKYO BUILDING, 2-7-3 MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
HIMEJI WORKS: 840, CHIYODA CHO, HIMEJI, JAPAN
FX-KP-OK-E
09R927
JY997D34801B
(MEE)
Effective Jul. 2009
Specifications are subject to change without notice.
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Related manuals
advertisement
Table of contents
- 1 Front Cover
- 3 Manual number
- 5 Table of Contents
- 9 Positioning of This Manual
- 12 Related Manuals
- 15 Generic Names and Abbreviations Used in Manuals
- 16 1. Outline
- 16 1.1 Outline of Structured Programs and Programming Languages
- 16 1.1.1 Outline of structured programs
- 17 1.1.2 Programming languages
- 17 1.2 PLC Series and Programming Software Version
- 18 1.3 Cautions on Creation of Fundamental Programs
- 18 1.3.1 I/O processing and response delay
- 19 1.3.2 Double output (double coil) operation and countermeasures
- 20 1.3.3 Circuits not available in structured ladder programs and countermeasures
- 20 1.3.4 Handling of general flags
- 23 1.3.5 Handling of operation error flag
- 24 2. Function List
- 24 2.1 Type Conversion Functions
- 26 2.2 Standard Functions Of One Numeric Variable
- 26 2.3 Standard Arithmetic Functions
- 27 2.4 Standard Bit Shift Functions
- 27 2.5 Standard Bitwise Boolean Functions
- 27 2.6 Standard Selection Functions
- 28 2.7 Standard Comparison Functions
- 28 2.8 Standard Character String Functions
- 28 2.9 Functions Of Time Data Types
- 29 2.10 Standard Function Blocks
- 30 3. Function Construction
- 30 3.1 Applied Function Expression and Execution Type
- 31 3.2 Labels
- 34 3.3 Device and Address
- 35 3.4 EN and ENO
- 36 4. How to Read Explanation of Functions
- 38 5. Applied Functions
- 38 5.1 Type Conversion Functions
- 38 5.1.1 BOOL_TO_INT(_E)
- 40 5.1.2 BOOL_TO_DINT(_E)
- 42 5.1.3 BOOL_TO_STR(_E)
- 44 5.1.4 BOOL_TO_WORD(_E)
- 46 5.1.5 BOOL_TO_DWORD(_E)
- 48 5.1.6 BOOL_TO_TIME(_E)
- 50 5.1.7 INT_TO_DINT(_E)
- 52 5.1.8 DINT_TO_INT(_E)
- 54 5.1.9 INT_TO_BOOL(_E)
- 56 5.1.10 DINT_TO_BOOL(_E)
- 58 5.1.11 INT_TO_REAL(_E)
- 60 5.1.12 DINT_TO_REAL(_E)
- 62 5.1.13 INT_TO_STR(_E)
- 64 5.1.14 DINT_TO_STR(_E)
- 66 5.1.15 INT_TO_WORD(_E)
- 68 5.1.16 DINT_TO_WORD(_E)
- 70 5.1.17 INT_TO_DWORD(_E)
- 72 5.1.18 DINT_TO_DWORD(_E)
- 74 5.1.19 INT_TO_BCD(_E)
- 76 5.1.20 DINT_TO_BCD(_E)
- 78 5.1.21 INT_TO_TIME(_E)
- 80 5.1.22 DINT_TO_TIME(_E)
- 82 5.1.23 REAL_TO_INT(_E)
- 84 5.1.24 REAL_TO_DINT(_E)
- 86 5.1.25 REAL_TO_STR(_E)
- 89 5.1.26 WORD_TO_BOOL(_E)
- 91 5.1.27 DWORD_TO_BOOL(_E)
- 93 5.1.28 WORD_TO_INT(_E)
- 95 5.1.29 WORD_TO_DINT(_E)
- 97 5.1.30 DWORD_TO_INT(_E)
- 99 5.1.31 DWORD_TO_DINT(_E)
- 101 5.1.32 WORD_TO_DWORD(_E)
- 103 5.1.33 DWORD_TO_WORD(_E)
- 105 5.1.34 WORD_TO_TIME(_E)
- 107 5.1.35 DWORD_TO_TIME(_E)
- 109 5.1.36 STR_TO_BOOL(_E)
- 111 5.1.37 STR_TO_INT(_E)
- 113 5.1.38 STR_TO_DINT(_E)
- 115 5.1.39 STR_TO_REAL(_E)
- 118 5.1.40 STR_TO_TIME(_E)
- 120 5.1.41 BCD_TO_INT(_E)
- 122 5.1.42 BCD_TO_DINT(_E)
- 124 5.1.43 TIME_TO_BOOL(_E)
- 126 5.1.44 TIME_TO_INT(_E)
- 128 5.1.45 TIME_TO_DINT(_E)
- 130 5.1.46 TIME_TO_STR(_E)
- 132 5.1.47 TIME_TO_WORD(_E)
- 134 5.1.48 TIME_TO_DWORD(_E)
- 136 5.2 Standard Functions Of One Numeric Variable
- 136 5.2.1 ABS(_E)
- 138 5.3 Standard Arithmetic Functions
- 138 5.3.1 ADD_E
- 140 5.3.2 SUB_E
- 142 5.3.3 MUL_E
- 144 5.3.4 DIV_E
- 146 5.3.5 MOD(_E)
- 148 5.3.6 EXPT(_E)
- 150 5.3.7 MOVE(_E)
- 152 5.4 Standard Bit Shift Functions
- 152 5.4.1 SHL(_E)
- 154 5.4.2 SHR(_E)
- 156 5.5 Standard Bitwise Boolean Functions
- 156 5.5.1 AND_E
- 158 5.5.2 OR_E
- 160 5.5.3 XOR_E
- 162 5.5.4 NOT(_E)
- 164 5.6 Standard Selection Functions
- 164 5.6.1 SEL(_E)
- 166 5.6.2 MAXIMUM(_E)
- 168 5.6.3 MINIMUM(_E)
- 170 5.6.4 LIMITATION(_E)
- 172 5.6.5 MUX(_E)
- 174 5.7 Standard Comparison Functions
- 174 5.7.1 GT_E
- 176 5.7.2 GE_E
- 177 5.7.3 EQ_E
- 178 5.7.4 LE_E
- 180 5.7.5 LT_E
- 181 5.7.6 NE_E
- 183 5.8 Standard Character String Functions
- 183 5.8.1 MID(_E)
- 186 5.8.2 CONCAT(_E)
- 189 5.8.3 INSERT(_E)
- 192 5.8.4 DELETE(_E)
- 194 5.8.5 REPLACE(_E)
- 197 5.8.6 FIND(_E)
- 200 5.9 Functions Of Time Data Types
- 200 5.9.1 ADD_TIME(_E)
- 202 5.9.2 SUB_TIME(_E)
- 204 5.9.3 MUL_TIME(_E)
- 206 5.9.4 DIV_TIME(_E)
- 208 6. Standard Function Blocks
- 208 6.1 R_TRIG(_E)
- 210 6.2 F_TRIG(_E)
- 212 6.3 CTU(_E)
- 214 6.4 CTD(_E)
- 216 6.5 CTUD(_E)
- 219 6.6 TP(_E)
- 221 6.7 TON(_E)
- 223 6.8 TOF(_E)
- 225 6.9 COUNTER_FB_M
- 227 6.10 TIMER_10_FB_M
- 228 6.11 TIMER_CONT_FB_M
- 230 6.12 TIMER_100_FB_M
- 231 Appendix A: Correspondence between Devices and Addresses
- 232 Warranty
- 233 Revision History
- 236 Back Cover