JY997D34801 G 5/2012
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 programmable controller 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.
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.
Table of Contents
Table of Contents
Positioning of This Manual....................................................................................................... 8 Related Manuals ...................................................................................................................... 11 Generic Names and Abbreviations Used in Manuals .......................................................... 13
1. Outline
14
1.2 PLC Series and Programming Software Version ..................................................................... 16 1.3 Cautions on Creation of Fundamental Programs .................................................................... 16
1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 I/O processing and response delay ............................................................................................... 16 Double output (double coil) operation and countermeasures........................................................ 17 Circuits not available in structured ladder programs and countermeasures.................................. 18 Handling of general flags............................................................................................................... 18 Handling of operation error flag ..................................................................................................... 21
2. Function/Operator List
22
2.1 Type Conversion Functions....................................................................................................... 22 2.2 Standard Functions Of One Numeric Variable ......................................................................... 24 2.3 Standard Arithmetic Functions.................................................................................................. 24 2.4 Standard Bit Shift Functions...................................................................................................... 24 2.5 Standard Bitwise Boolean Functions........................................................................................ 24 2.6 Standard Selection Functions ................................................................................................... 25 2.7 Standard Comparison Functions .............................................................................................. 25 2.8 Standard Character String Functions ....................................................................................... 25 2.9 Functions Of Time Data Types .................................................................................................. 26 2.10 Standard Function Blocks........................................................................................................ 26 2.11 Operator ..................................................................................................................................... 27
2.11.1 Arithmetic operations................................................................................................................... 27 2.11.2 Logical operations ....................................................................................................................... 27 2.11.3 Comparison operations ............................................................................................................... 27
3. Function Construction
3.1 3.2 3.3 3.4
28
Applied Function Expression and Execution Type ................................................................. 28 Labels........................................................................................................................................... 29 Device and Address.................................................................................................................... 32 EN and ENO ................................................................................................................................. 33
34
Table of Contents
36
BOOL_TO_INT(_E) / Bit data word [signed] data conversion ............................................ 38 BOOL_TO_DINT(_E) / Bit data double word [signed] data conversion............................. 40 BOOL_TO_STR(_E) / Bit data string data conversion ........................................................ 42 BOOL_TO_WORD(_E) / Bit data word [unsigned]/ bit string [16-bit] data conversion............................................................................................. 44 5.5 BOOL_TO_DWORD(_E) / Bit data double word [unsigned]/ bit string [32-bit] data conversion............................................................................................. 46 5.6 BOOL_TO_TIME(_E) / Bit data time data conversion.......................................................... 48 5.7 INT_TO_DINT(_E) / Word [signed] data double word [signed] data conversion .............. 50 5.8 DINT_TO_INT(_E) / Double word [signed] data word [signed] data conversion .............. 52 5.9 INT_TO_BOOL(_E) / Word [signed] data bit data conversion ............................................ 54 5.10 DINT_TO_BOOL(_E) / Double word [signed] data bit data conversion........................... 56 5.11 INT_TO_REAL(_E) / Word [signed] data float (single precision) data conversion......... 58 5.12 DINT_TO_REAL(_E) / Double word [signed] data float (single precision) data conversion................................................................................. 60 5.13 INT_TO_STR(_E) / Word [signed] data string data conversion........................................ 62 5.14 DINT_TO_STR(_E) / Double word [signed] data string data conversion ........................ 64 5.15 INT_TO_WORD(_E) / Word [signed] data word [unsigned]/ bit string [16-bit] data conversion........................................................................................... 66 5.16 DINT_TO_WORD(_E) / Double word [signed] data word [unsigned]/ bit string [16-bit] data conversion........................................................................................... 68 5.17 INT_TO_DWORD(_E) / word [signed] data double word [unsigned]/ bit string [32-bit] data conversion........................................................................................... 70 5.18 DINT_TO_DWORD(_E) / Double word [signed] data double word [unsigned]/ bit string [32-bit] data conversion........................................................................................... 72 5.19 INT_TO_BCD(_E) / Word [signed] data BCD data conversion ......................................... 74 5.20 DINT_TO_BCD(_E) / Double word [signed] data BCD data conversion .......................... 76 5.21 INT_TO_TIME(_E) / Word [signed] data time data conversion......................................... 78 5.22 DINT_TO_TIME(_E) / Double word [signed] data time data conversion.......................... 80 5.23 REAL_TO_INT(_E) / Float (single precision) data word [signed] data conversion ........ 82 5.24 REAL_TO_DINT(_E) / Float (single precision) data double word [signed] data conversion................................................................................... 84 5.25 REAL_TO_STR(_E) / Float (single precision) data string data conversion .................... 86 5.26 WORD_TO_BOOL(_E) / Word [unsigned] / bit string [16-bit] data bit data conversion................................................................................................................... 89 5.27 DWORD_TO_BOOL(_E) / Double word [unsigned]/bit string [32-bit] data bit data conversion................................................................................................................... 91 5.28 WORD_TO_INT(_E) / Word [unsigned]/bit string [16-bit] data word [signed] data conversion ............................................................................................... 93 5.29 WORD_TO_DINT(_E) / Word [unsigned]/bit string [16-bit] data double word [signed] (signed) data conversion.................................................................... 95 5.30 DWORD_TO_INT(_E) / Double word [unsigned]/bit string [32-bit] data Word [signed] data conversion................................................................................................ 97 5.31 DWORD_TO_DINT(_E) / Double word [unsigned]/bit string [32-bit] data double word [signed] data conversion.................................................................................... 99 5.32 WORD_TO_DWORD(_E) / Word [unsigned]/bit string [16-bit] data double word [unsigned]/bit string [32-bit data conversion]................................................ 101 5.33 DWORD_TO_WORD(_E) / Double word [unsigned]/bit string[32-bit] data word [unsigned]/bit string [16-bit] data conversion............................................................ 103 5.34 WORD_TO_TIME(_E) / Word [unsigned]/bit string [16-bit] data time data conversion.............................................................................................................. 105 5.35 DWORD_TO_TIME(_E) / Double word [unsigned]/bit string [32-bit] data time data conversion .......................................................................................................... 107
Table of Contents
STR_TO_BOOL(_E) / String data bit data conversion .................................................... 109 STR_TO_INT(_E) / String data word [signed] data conversion...................................... 111 STR_TO_DINT(_E) / String data double word [signed] data conversion ...................... 113 STR_TO_REAL(_E) / String data float (single precision) data conversion ................... 115 STR_TO_TIME(_E) / String data time data conversion ................................................... 118 BCD_TO_INT(_E) / BCD data word [signed] data conversion........................................ 120 BCD_TO_DINT(_E) / BCD data double word [signed] data conversion ........................ 122 TIME_TO_BOOL(_E) / Time data bit data conversion ..................................................... 124 TIME_TO_INT(_E) / Time data word [signed] data conversion ...................................... 126 TIME_TO_DINT(_E) / Time data double word [signed] data conversion ....................... 128 TIME_TO_STR(_E) / Time data string data conversion .................................................. 130 TIME_TO_WORD(_E) / Time data word [unsigned]/ bit string [16-bit] data conversion......................................................................................... 132 TIME_TO_DWORD(_E) / Time data double word [unsigned]/ bit string [32-bit] data conversion......................................................................................... 134 BITARR_TO_INT(_E) / Bit array Word [signed] type, word [unsigned]/bit String [16-bit] data conversion ........................................................... 136 BITARR_TO_DINT(_E) / Bit array Double word [signed] type, double word [unsigned]/bit string [32-bit] data conversion............................................... 138 INT_TO_BITARR(_E) / Word [signed] data, word [unsigned]/ bit string [16-bit] data bit array conversion ..................................................................... 140 DINT_TO_BITARR(_E) / Double word [signed] data, double word [unsigned]/bit string [32-bit] data bit array conversion ........................... 142 CPY_BITARR(_E) / Bit array copy ......................................................................................... 144 GET_BIT_OF_INT(_E) / Specified bit read of word [signed] data ....................................... 146 SET_BIT_OF_INT(_E) / Specified bit write of word [signed] data....................................... 148 CPY_BIT_OF_INT(_E) / Specified bit copy of word [signed] data ...................................... 150 GET_BOOL_ADDR / Acquisition of start data...................................................................... 152 GET_INT_ADDR / Acquisition of start data .......................................................................... 153 GET_WORD_ADDR / Acquisition of start data..................................................................... 154
155
158
ADD_E / Addition ...................................................................................................................... 159 SUB_E / Subtraction ................................................................................................................. 161 MUL_E / Multiplication.............................................................................................................. 163 DIV_E / Division......................................................................................................................... 165 MOD(_E) / Modulus operation.................................................................................................. 167 EXPT(_E) / Exponentiation ....................................................................................................... 169 MOVE(_E) / Move operation ..................................................................................................... 171
173
8.1 SHL(_E) / Left shift .................................................................................................................... 174 8.2 SHR(_E) / Right shift ................................................................................................................. 176
Table of Contents
178
AND_E / Logical product .......................................................................................................... 179 OR_E / Logical sum .................................................................................................................. 181 XOR_E / exclusive logical sum ................................................................................................ 183 NOT(_E) / logical negation ....................................................................................................... 185
187
SEL(_E) / Selection ................................................................................................................. 188 MAXIMUM(_E) / Maximum selection...................................................................................... 190 MINIMUM(_E) / Minimum selection........................................................................................ 192 LIMITATION(_E) / Upper/Lower limit control ........................................................................ 194 MUX(_E) / Multiplexer ............................................................................................................. 196
198
GT_E / Comparison................................................................................................................. 199 GE_E / Comparison................................................................................................................. 201 EQ_E / Comparison................................................................................................................. 203 LE_E / Comparison ................................................................................................................. 205 LT_E / Comparison ................................................................................................................. 207 NE_E / Comparison................................................................................................................. 209
211
MID(_E) / Extract mid string ................................................................................................... 212 CONCAT(_E) / String concatenation ..................................................................................... 215 INSERT(_E) / String insertion................................................................................................. 217 DELETE(_E) / String deletion ................................................................................................. 220 REPLACE(_E) / String replacement....................................................................................... 222 FIND(_E) / Searches a character string................................................................................. 225
228
ADD_TIME(_E) / Addition ....................................................................................................... 229 SUB_TIME(_E) / Subtraction .................................................................................................. 231 MUL_TIME(_E) / Multiplication............................................................................................... 233 DIV_TIME(_E) / Division.......................................................................................................... 235
237
R_TRIG(_E) / Rising edge detector........................................................................................ 238 F_TRIG(_E) / Falling edge detector ....................................................................................... 240 CTU(_E) / Up counter .............................................................................................................. 242 CTD(_E) / Down counter ......................................................................................................... 244 CTUD(_E) / Up/Down counter................................................................................................. 246 TP(_E) / Pulse timer ................................................................................................................ 248 TON(_E) / On delay timer........................................................................................................ 250 TOF(_E) / Off delay timer ........................................................................................................ 252
Table of Contents
14.9 COUNTER_FB_M / Counter function blocks ........................................................................ 254 14.10 TIMER_10_FB_M / Timer function blocks........................................................................... 256 14.11 TIMER_CONT_FB_M / Timer function blocks..................................................................... 257 14.12 TIMER_100_FB_M / Timer function blocks......................................................................... 259
15. Operator
260
15.1 ADD / Addition......................................................................................................................... 261 15.2 SUB / Subtraction.................................................................................................................... 262 15.3 MUL / Multiplication ................................................................................................................ 263 15.4 DIV / Division ........................................................................................................................... 264 15.5 MOD / Modulus operation....................................................................................................... 265 15.6 ** / Exponentiation .................................................................................................................. 266 15.7 AND / Logical product ............................................................................................................ 267 15.8 OR / Logical sum..................................................................................................................... 268 15.9 XOR / Exclusive logical sum .................................................................................................. 269 15.10 NOT / Logical negation ......................................................................................................... 271 15.11 GT / Comparison ................................................................................................................... 272 15.12 GE / Comparison ................................................................................................................... 273 15.13 EQ / Comparison ................................................................................................................... 274 15.14 LE / Comparison.................................................................................................................... 275 15.15 LT / Comparison.................................................................................................................... 276 15.16 NE / Comparison ................................................................................................................... 277
278
280
Appendix B-1 [By type] ............................................................................................................. 280 Appendix B-2 [In alphabetic order] ........................................................................................... 283
(Additional Manual)
This manual explains sequence instructions for structured programs provided by GX Works2.
(This manual)
FX Structured
Special unit/block
Structured
Structured
FX
FXCPU Structured Programming Manual [Basic & Applied Instruction] (Additional Manual)
This manual explains sequence instructions for structured programs provided by GX Works2.
Structured
(This manual)
FX
Structured
Structured
Structured
FX
FXCPU Structured Programming Manual [Basic & Applied Instruction] (Additional Manual)
This manual explains sequence instructions for structured programs provided by GX Works2.
Structured
(This manual)
FX
Structured
10
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 representative for acquiring required manuals.
FX3G/FX3GC/FX3U/FX3UC PLCs
Manual name PLC main unit I/O specifications, wiring and installation of the PLC main unit FX3U extracted from the FX3U Series Users Manual - Hardware Edition. For detailed explanation, refer to the FX3U Series Users Manual - Hardware Edition. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX3U PLC main unit. I/O specifications, wiring and installation of the PLC main unit FX3UC (D, DS, DSS) extracted from the FX3UC Series Users Manual - Hardware Edition. For detailed explanation, refer to the FX3UC Series Users Manual - Hardware Edition. I/O specifications, wiring and installation of the PLC main unit FX3UC-32MT-LT-2 extracted from the FX3UC Series Users Manual - Hardware Edition. For detailed explanation, refer to the FX3UC Series Users Manual - Hardware Edition. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX3UC PLC main unit. I/O specifications, wiring and installation of the PLC main unit FX3G extracted from the FX3G Series Users Manual - Hardware Edition. For detailed explanation, refer to the FX3G Series Users Manual - Hardware Edition. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX3G PLC main unit. I/O specifications, wiring and installation of the PLC main unit FX3GC extracted from the FX3GC Series User's Manual - Hardware Edition. For detailed explanation, refer to the FX3GC Series User's Manual - Hardware Edition. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX3GC PLC main unit. Manual number Supplied with product or Additional Manual Contents Model name code
JY997D18801
JY997D16501
Additional Manual
09R516
JY997D28601
JY997D31601
JY997D28701
Additional Manual
09R519
JY997D33401
JY997D31301
Additional Manual
09R521
JY997D45201
JY997D45401
Additional Manual
09R533
11
Manual name Programming FX3G/FX3U/FX3GC/FX3UC User's Manual- Analog Control Edition FX Series User's Manual -Data Communication Edition FX3G/FX3U/FX3GC/FX3UC Series User's Manual -Positioning Edition FX3U-CF-ADP User's Manual
Manual number
Contents
JY997D16701
Additional Manual
Detaileds about the analog special function block (FX3U-4AD, FX3U-4DA, FX3UC-4AD) and analog special adapter (FX3U-****-ADP). Details about simple N : N link, parallel link, computer link and no-protocol communication (RS instruction and FX2N-232IF). Details about the positioning function built in the FX3G/FX3U/FX3GC/FX3UC Series. Describes details of the FX3U-CF-ADP CF card special adapter.
09R619
FX1S/FX1N/FX1NC/FX2N/FX2NC PLCs
Manual name PLC main unit FX1S HARDWARE MANUAL JY992D83901 Additional Manual Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX1S PLC main unit. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX1N PLC main unit. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX2N PLC main unit. Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX1NC PLC main unit. (Japanese only) Details about the hardware including I/O specifications, wiring, installation and maintenance of the FX2NC PLC main unit. Details about simple N : N link, parallel link, computer link and no-protocol communication (RS instruction and FX2N-232IF). Manual number Supplied with product or Additional Manual Contents Model name code
JY992D89301
Additional Manual
JY992D66301
Additional Manual
09R508
JY992D92101
Additional Manual
09R505
FX2NC HARDWARE MANUAL Programming FX Series User's Manual -Data Communication Edition
JY992D76401
Additional Manual
09R509
JY997D16901
Additional Manual
09R715
JY992D55301
FX/FX2C HARDWARE MANUAL Programming FX Series User's Manual -Data Communication Edition
JY992D47401
JY997D16901
Additional Manual
09R715
Manuals of models whose production is finished Production is finished for FX0S/FX0/FX0N/FXU/FX2C PLCs.
12
13
1 Outline
1.1 Outline of Structured Programs and Programming Languages
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/L/F Structured Programming Manual (Fundamentals)
1.1
1.1.1
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.
14
1 Outline
1.1 Outline of Structured Programs and Programming Languages
1
Outline
Graphic languages
1. Structured ladder language
This graphic language is created based on the relay circuit design technology. A circuit always starts from the bus line located on the left side. The structured ladder language consists of contacts, coils, functions and function blocks. These components are connected with vertical lines and horizontal lines.
1 X000 Y000 2 X001 Y000
2
Function/ Operator List
3
Output Y000
Function Construction
X001 D0 EN s
MOV ENO d
D2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
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;
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
15
1 Outline
1.2 PLC Series and Programming Software Version
1.2
1.3
1.3.1
[Output processing] Output Result is transferred to devices Batch I/O method output latch memory. are driven.
(3)
(Refresh method)
OFF
This "input ON" can be received. "Input ON" cannot This "input OFF" cannot be received. be received. ON ON OFF Program processing Program processing Program processing Program processing Operation cycle
Time)
16
1 Outline
1.3 Cautions on Creation of Fundamental Programs
1
Outline
2
Function/ Operator List
3
Function Construction
Y003
Y004
Second
4
How to Read Explanation of Functions
Y003
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
A Or C D M100 M101
M100
M101
8
Applied Functions (Standard Bit Shift Functions)
Y000
9
Applied Functions (Standard Bitwise Boolean Functions)
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.
10
Applied Functions (Standard Selection Functions)
17
1 Outline
1.3 Cautions on Creation of Fundamental Programs
Or
1.3.4
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
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
Outline
2
Function/ Operator List
Good example
M8000 X010 1 M8029 Execution is completed. D0 10 EN s1 s2 EN s1 s2 DSW ENO d1 d2 MUL ENO d
Y010 D0
3
Function Construction
4
How to Read Explanation of Functions
X000
M0 S DPLSY EN ENO s1 d s2 M0 R
M0
M8029 works as a flag to indicate that execution of DPLSY is completed.
5
Applied Functions (Type Conversion Functions)
Y000
6
Applied Functions (Standard Functions Of One Numeric Variable)
Bad example
M8029 works as a flag to indicate that execution of DPLSY (on the lower side) is completed.
M0 R
EN s1 s2
DSW ENO d1 d2
7
Applied Functions (Standard Arithmetic Functions)
Y010 D0
8
Applied Functions (Standard Bit Shift Functions)
M0 1000 Number of M8029 works as a output pulses flag to indicate that execution of DPLSY (on the upper side) M8029 is completed. Execution is D0 completed. 10 M1 1000 Number of output pulses2
EN s1 s2
9
Applied Functions (Standard Bitwise Boolean Functions)
DPLSY EN ENO s1 d s2
10
Applied Functions (Standard Selection Functions)
19
1 Outline
1.3 Cautions on Creation of Fundamental Programs
2. Introduction of a method to use flags in any positions other than positions just under sequence instructions
If two or more sequence instructions are programmed, general flags turn ON or OFF when each corresponding instruction is executed. Accordingly, when using a general flag in any position other than a position just under a sequence instruction, set to ON or OFF another device (variable) just under the sequence instruction, and then use the contact of such device (variable) as the command contact.
M8000 X010 1 M8029 Execution is completed. M0 1000 Number of output pulses M8029 Execution is completed. EN s1 s2
DSW ENO d1 d2
Y010 D0
M100
Y000
Y030
20
FXCPU Structured Programming Manual [Application Functions] 1.3.5 Handling of operation error flag
1 Outline
1.3 Cautions on Creation of Fundamental Programs
1
Outline
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 FX0S/FX0/FX0N/FX1S/FX1N/FX1NC/ FXU/FX2C/FX2N/FX2NC/FX3G/FX3GC D8069*1 FX3U/FX3UC D8315, D8314
2
Function/ Operator List
*1.
When an error occurs in a step up to the step No. 32767 in the FX3U/FX3UC PLC, you can check the error occurrence step also in D8069 (16 bits).
3
Function Construction
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.
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
*2.
When an error occurs in a step up to the step No. 32767 in the FX3U/FX3UC PLC, you can check the error occurrence step also in D8068 (16 bits).
6
Applied Functions (Standard Functions Of One Numeric Variable)
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.
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
21
2 Function/Operator List
2.1 Type Conversion Functions
2.
Function/Operator List
This chapter introduces a list of functions and operators available in programming.
2.1
Function name
Function
Reference
FX0(S)
FX0N
FX1S
Converts bit data into word [signed] data. Converts bit data into double word [signed] data. Converts bit data into string 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
Converts bit data into word [unsigned]/bit string BOOL_TO_WORD(_E) [16-bit] data. BOOL_TO_DWORD (_E) BOOL_TO_TIME(_E) INT_TO_DINT(_E) DINT_TO_INT(_E) INT_TO_BOOL(_E) DINT_TO_BOOL(_E) INT_TO_REAL(_E) DINT_TO_REAL(_E) 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) DINT_TO_BCD(_E) INT_TO_TIME(_E) DINT_TO_TIME(_E) REAL_TO_INT(_E) REAL_TO_DINT(_E) REAL_TO_STR(_E) WORD_TO_BOOL(_E) Converts bit data into double word [unsigned]/bit string [32-bit] data. Converts bit data into time data. 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. Converts double word [signed] data into bit data. Converts word [signed] data into float (single precision) data. Converts double word [signed] data into float (single precision) data. 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. Converts word [signed] data into BCD data. Converts double word [signed] data into BCD data. Converts word [signed] data into time data. Converts double word [signed] data into time data. 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.
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
3 3 3 3 3 3 3
Section 5.4 Section 5.5 Section 5.6 Section 5.7 Section 5.8 Section 5.9 Section 5.10 Section 5.11 Section 5.12 Section 5.13 Section 5.14
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 3 3 3 3 3
3 3 3 3 3 3 3 3
Section 5.15 Section 5.16 Section 5.17 Section 5.18 Section 5.19 Section 5.20 Section 5.21 Section 5.22 Section 5.23 Section 5.24 Section 5.25
Section 5.26
*1.
22
2 Function/Operator List
2.1 Type Conversion Functions
1
Outline
FXU/FX2C FX3G(C) FX3U(C) FX2N(C) FX1N(C) Function name Function Reference FX0(S) FX0N FX1S
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) STR_TO_BOOL(_E) STR_TO_INT(_E) STR_TO_DINT(_E) STR_TO_REAL(_E) STR_TO_TIME(_E) BCD_TO_INT(_E) BCD_TO_DINT(_E) TIME_TO_BOOL(_E) TIME_TO_INT(_E) TIME_TO_DINT(_E) TIME_TO_STR(_E) TIME_TO_WORD(_E) TIME_TO_DWORD (_E) BITARR_TO_INT(_E)
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] data. Converts double word [unsigned]/bit string [32bit] data into word [unsigned]/bit string [16-bit] data. Converts word [unsigned]/bit string [16-bit] data into time data. Converts double word [unsigned]/bit string [32bit] data into time data. Converts string data into bit data. 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. Converts BCD data into word [signed] data. Converts BCD data into double word [signed] data. Converts time data into bit data. Converts time data into word [signed] data. Converts time data into double word [signed] data. Converts time data into string data. Converts time data into word [unsigned]/bit string [16-bit] data. Converts time data into double word [unsigned]/ bit string [32-bit] data. Converts specified number of bits of a bit array into word [signed] data or word [unsigned]/bit string [16-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 3 3 3 3
3 3 3 3 3
Section 5.27 Section 5.28 Section 5.29 Section 5.30 Section 5.31
2
Function/ Operator List
3
Function Construction
Section 5.32
Section 5.33
4
How to Read Explanation of Functions
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 5.34 Section 5.35 Section 5.36 Section 5.37 Section 5.38 Section 5.39 Section 5.40
5
Applied Functions (Type Conversion Functions)
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 5.41 Section 5.42 Section 5.43 Section 5.44 Section 5.45 Section 5.46
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
3 3
3 3
3 3
3 3
3 3
3 3
3 3
Section 5.49
8
Applied Functions (Standard Bit Shift Functions)
Converts specified number of bits of a bit array BITARR_TO_DINT(_E) into double word [signed] data or double word [unsigned]/bit string [32-bit] data. INT_TO_BITARR(_E) Outputs low-order "n" bits of word [signed] data or word [unsigned]/bit string [16-bit] data to a bit array.
Section 5.50
Section 5.51
9
Applied Functions (Standard Bitwise Boolean Functions)
Outputs low-order "n" bits of double word DINT_TO_BITARR(_E) [signed] data or double word [unsigned]/bit string [32-bit] data to a bit array. CPY_BITARR(_E) Copies specified number of bits of a bit array. Reads a value of a specified bit of word [signed] GET_BIT_OF_INT(_E) data. SET_BIT_OF_INT(_E) CPY_BIT_OF_INT(_E) Writes a value to a specified bit of word [signed] data. Copies a specified bit of word [signed] data to a specified bit of another word [signed] data.
3 3 3 3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3
Section 5.52 Section 5.53 Section 5.54 Section 5.55 Section 5.56
10
Applied Functions (Standard Selection Functions)
23
2 Function/Operator List
2.2 Standard Functions Of One Numeric Variable
Applicable PLC FXU/FX2C FX3G(C) FX3U(C) FX2N(C) FX1N(C) Function name Function Reference FX0(S) FX0N FX1S
Outputs start data as bit data. Outputs start data as word [signed] data. Outputs start data as word [unsigned]/bit string [16-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
2.2
Function name
Function
Reference
FX0(S)
FX0N
FX1S
ABS(_E)
Section 6.1
2.3
Function name
Function
Reference
FX0(S)
FX0N
FX1S
Adds data. (Number of pins variable) Subtracts data. Multiplies data. (Number of pins variable) 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
Section 7.1 Section 7.2 Section 7.3 Section 7.4 Section 7.5 Section 7.6 Section 7.7
2.4
Function name
Function
Reference
FX0(S)
FX0N
FX1S
SHL(_E) SHR(_E)
3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3
2.5
Function name
Function
Reference
FX0(S)
FX0N
FX1S
Obtains the logical product. (Number of pins variable) Obtains the logical sum. (Number of pins variable) Obtains the exclusive logical sum. (Number of pins variable) 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
24
2 Function/Operator List
2.6 Standard Selection Functions
2.6
1
Outline
Function name
Function
Reference
2
Function/ Operator List
FX0(S)
FX0N
FX1S
Selects data in accordance with the input condition. Searches the maximum value. (Number of pins variable) Searches the minimum value. (Number of pins variable) Judges whether data is located within the range between the upper limit value and the lower limit value. Selects data, and outputs it. (Number of pins variable)
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
Function Construction
LIMITATION(_E)
Section 10.4
MUX(_E)
Section 10.5
4
How to Read Explanation of Functions
Applicable PLC FXU/FX2C FX3G(C) FX3U(C) FX2N(C) FX1N(C)
2.7
Function name
Function
Reference
5
Applied Functions (Type Conversion Functions)
FX0(S)
FX0N
FX1S
Compares data with regard to "> (larger)". (Number of pins variable) Compares data with regard to " (larger or equal)". (Number of pins variable) Compares data with regard to "= (equal)". (Number of pins variable) Compares data with regard to " (smaller or equal)". (Number of pins variable) Compares data with regard to "< (smaller)". (Number of pins variable) 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
Section 11.1 Section 11.2 Section 11.3 Section 11.4 Section 11.5 Section 11.6
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
2.8
Function name
Function
Reference
8
Applied Functions (Standard Bit Shift Functions)
FX0(S)
FX0N
FX1S
Obtains a character string from a specified position. Connects character strings. (Number of pins variable) Inserts a character string. Deletes a character string. Replaces a character string. Searches a character string.
3 3 3 3 3 3
Section 12.1 Section 12.2 Section 12.3 Section 12.4 Section 12.5 Section 12.6
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
25
2 Function/Operator List
2.9 Functions Of Time Data Types
2.9
Function name
Function
Reference
FX0(S)
FX0N
FX1S
Adds time data. Subtracts time data. Multiplies time data. Divides time 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
2.10
Function name
Function
Reference
FX0(S)
FX0N
FX1S
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 TIMER_CONT_FB_M TIMER_100_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 Retentive timer drive 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 3 3
3 3
3 3
Section 14.1 Section 14.2 Section 14.3 Section 14.4 Section 14.5 Section 14.6 Section 14.7 Section 14.8
3 3
3 3
Section 14.12
26
2 Function/Operator List
2.11 Operator
2.11
Operator
1
Outline
2
Function/ Operator List
ST
+ * / **
Adds data. (Number of pins variable) Subtracts data. Multiplies data. (Number of pins variable) Divides data (, and outputs the quotient). Obtains the raised result.
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 15.1 Section 15.2 Section 15.3 Section 15.4 Section 15.5 Section 15.6
3
Function Construction
4
How to Read Explanation of Functions
ST
5
Applied Functions (Type Conversion Functions)
AND OR XOR -
Obtains the logical product. (Number of pins variable) Obtains the logical sum. (Number of pins variable) Obtains the exclusive logical sum. (Number of pins variable) 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
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
ST
GT GE EQ LE LT NE
Compares data with regard to "> (larger)". (Number of pins variable) Compares data with regard to " (larger or equal)". (Number of pins variable) Compares data with regard to "= (equal)". (Number of pins variable) Compares data with regard to " (smaller or equal)". (Number of pins variable) Compares data with regard to "< (smaller)". (Number of pins variable) 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
Section 15.11 Section 15.12 Section 15.13 Section 15.14 Section 15.15 Section 15.16
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
27
3 Function Construction
3.1 Applied Function Expression and Execution Type
3.
Function Construction
This chapter explains the construction of applied functions.
3.1
D0 K1
D10
_IN ( s ) : An argument whose contents do not change even if the function is executed is called "source", and expressed in this symbol. d *1 ( ) : An argument whose contents change when the function is executed is called "destination", and expressed in this symbol. K1 ( n ) : Arguments not regarded as source or destination are expressed in "m", "n", etc.
Decrement Pins
28
3 Function Construction
3.2 Labels
3.2
Labels
1
Outline
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.
2
Function/ Operator List
Label class
The label class indicates how each label can be used from which program component. The table below shows label classes.
Applicable program component Class VAR_GLOBAL Description Common label available in all program components 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 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 Program block 3 3 3 3 3 3 3 Function Function block 3 3 3 3 3 3 3
3
Function Construction
VAR_GLOBAL_CONSTANT Common constant available in all program components VAR VAR_CONSTANT VAR_INPUT VAR_OUTPUT VAR_IN_OUT
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
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_String1" is set for the function "BOOL_TO_STR_E".
X000 M0 BOOL_TO_STR_E EN ENO _BOOL
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
Var_String1
When using "Var_String1" as a global label Set the class, label name, data type and device (or address).
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
When using "Var_String1" as a local label Set the class, label name and data type.
10
Applied Functions (Standard Selection Functions)
29
3 Function Construction
3.2 Labels
Input a decimal number directly. Or add "K" before a decimal 123, K123 number. Add "16#" or "H" before a hexadecimal number. Input a real number directly. Or add "E" before a real number. 16#FF, HFF 2.34, E2.34
Surround a character string with single quotations (') or double 'ABC', "ABC" quotations (").
Data type
The label data type is basic or universal. The table below shows a list of basic data types.
Data type Bit Word [signed] Double Word [signed] Integer Double precision integer Description Boolean data Value range 0(FALSE), 1(TRUE) -32768 to 32767 -2147483648 to 2147483647 0 to 65535 0 to 4294967295 E 1.175495-38 to FLOAT (Single Precision) String Time Real number Character string Time value 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 32 bits 16 bits 32 bits Bit length
Word [unsigned]/Bit String 16-bit data [16-bit] Double Word [unsigned]/Bit 32-bit data String [32-bit]
30
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
Outline
2
Function/ Operator List
ANY_SIMPLE
Array
*1
Structure
*1
ANY_NUM
ANY_BIT Bit Word [unsigned]/ Bit String [16-bit] Double Word [unsigned]/ Bit String [32-bit]
Time
String
3
Function Construction
The "ANY" type on a higher layer contains types on the lower layer. The "ANY" type on the top layer contains all types.
4
How to Read Explanation of Functions
5
ANY16 ANY32
Applied Functions (Type Conversion Functions)
Word [signed]
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
*1 Refer to the following manual for details. Q/L/F Structured Programming Manual (Fundamentals)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
31
3 Function Construction
3.3 Device and Address
3.3
Device method
In this method, a device is described using the device name and device number.
X0 D 100
Device name
Device number
Address method
This method is defined in IEC61131-3, and used as shown in the table below.
Head 1st character: Position I Q % M Input Output Internal X W D L 2nd character: Size (Omitted) Bit Bit Word (16 bits) Double word (32 bits) Long Word (64 bits) 3rd and later characters: Classification Number
This number is provided for This decimal number detailed classification. corresponds to the device Period (.) is used to delimit number. the subsequent "Number". The characters for classification may be omitted.
%I
%M X 1 . 863
Size
Classification
Number
Memory area position The memory area position in which data is assigned is classified into "input", "output" or "internal". X(X Device method) : I(Input) Y(Y Device method) : Q(Output) Any other device : M(Internal) Size The principle of the description method corresponding to the device method (MELSEC description method) is as follows: Bit device : X(Bit) Word device : W(Word (16 bits)), D(Double word (32 bits)) Classification The 3rd and later characters indicate the device type which cannot be specified only by the position and size explained above. The classification is not required for devices "X" and "Y". Refer to the following for the device description method: 7.3 Appendix A
32
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
Outline
2
Function/ Operator List
3
Function Construction
X000
M1 VAR_D10
4
How to Read Explanation of Functions
In the above example, the function "BOOL_TO_STR_E" is executed only when X000 is "TRUE". When the function is executed normally, "TRUE" is output to M1.
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
33
4.
1) 2)
3)
4)
5)
6)
7)
* The above page is prepared for explanation, and is different from the actual page.
34
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.
1
Outline
2
Function/ Operator List
3
Function Construction
4) Indicates the input variable name and output variable name of the function as well as the contents and data type of each variable. Refer to the following for detailed data types: Q/L/F 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. In program examples of the structured ladder/FBD language, the structured ladder language is adopted as the representative.
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
35
5.
36
1
Reference Section 5.46 Section 5.47 Section 5.48 Section 5.49 Section 5.50 Section 5.51 Section 5.52 Section 5.53 Section 5.54 Section 5.55 Section 5.56 Section 5.57 Section 5.58 Section 5.59
Outline
Time data word [unsigned]/bit string [16-bit] data conversion Time data double word [unsigned]/bit string [32-bit] data conversion Bit array Word [signed] type, word [unsigned]/bit String [16-bit] data conversion Bit array Double word [signed] type, double word [unsigned]/bit string [32-bit] data conversion Word [signed] data, word [unsigned]/bit string [16-bit] data bit array conversion Double word [signed] data, double word [unsigned]/bit string [32-bit] data bit array conversion Bit array copy Specified bit read of word [signed] data Specified bit write of word [signed] data Specified bit copy of word [signed] data Acquisition of start data Acquisition of start data Acquisition of start data
2
Function/ Operator List
3
Function Construction
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
37
5.1
Outline
This function converts bit data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD 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);
BOOL_TO_INT
M0
BOOL_TO_INT _BOOL *1
D0
X000
BOOL_TO_INT_E
M0
D0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status Word [signed] data after conversion Description Bit Bit Bit Word [signed] Data type
Cautions
Use the function having "_E" in its name to connect a bus.
38
1
Outline
In this program, bit data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(BOOL_TO_INT)
[Structured ladder/FBD] [ST]
2
Function/ Operator List
g_bool1
BOOL_TO_INT _BOOL
g_int1 := BOOL_TO_INT(g_bool1);
g_int1
3
Function Construction
g_bool1 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
39
5.2
Outline
This function converts bit data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD 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);
BOOL_TO_DINT
M0
BOOL_TO_DINT _BOOL *1
Label
BOOL_TO_DINT_ E
X000 M0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status Double word [signed] data after conversion Description Bit Bit Bit Double Word [signed] 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.
40
1
Outline
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/FBD] [ST]
2
Function/ Operator List
g_bool1
BOOL_TO_DINT _BOOL
g_dint1 := BOOL_TO_DINT(g_bool1);
g_dint1
3
Function Construction
g_bool1 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
41
5.3
Outline
This function converts bit data into string data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BOOL_TO_STR(_BOOL); Example: Label:= BOOL_TO_STR(M0); BOOL_TO_STR_E(EN, _BOOL, Output label); Example: BOOL_TO_STR_E(X000,M0, Label);
BOOL_TO_STR
M0
BOOL_TO_STR _BOOL *1
Label
BOOL_TO_STR_ E
X000 M0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status String data after conversion Description Bit Bit Bit String Data type
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.
42
1
Outline
2
Function/ Operator List
g_bool1
BOOL_TO_STR _BOOL
g_string1 := BOOL_TO_STR(g_bool1);
g_string1
3
Function Construction
g_bool1 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
43
5.4
BOOL_TO_WORD(_E) / Bit data word [unsigned]/ bit string [16-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts bit data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BOOL_TO_WORD(_BOOL); Example: D0:= BOOL_TO_WORD(M0); BOOL_TO_WORD_E(EN, _BOOL, Output label); Example: BOOL_TO_WORD_E(X000, M0,D0);
BOOL_TO_WOR D
M0
BOOL_TO_WORD _BOOL *1
D0
BOOL_TO_WOR D_E
X000 M0
D0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status Word [unsigned]/bit string [16-bit] data after conversion Description Bit Bit Bit Word [unsigned]/ Bit String [16-bit] Data type
Cautions
Use the function having "_E" in its name to connect a bus.
44
1
Outline
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/FBD] [ST]
2
Function/ Operator List
g_bool1
BOOL_TO_WORD _BOOL
g_word1 := BOOL_TO_WORD(g_bool1);
g_word1
3
Function Construction
g_bool1 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
45
5.5
BOOL_TO_DWORD(_E) / Bit data double word [unsigned]/ bit string [32-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts bit data into double word [unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BOOL_TO_DWORD(_BOOL); Example: Label:= BOOL_TO_DWORD(M0);
BOOL_TO_DWO RD
M0
BOOL_TO_DWORD _BOOL *1
Label
BOOL_TO_DWO RD_E
X000 M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status Double word [unsigned]/bit string [32-bit] data after conversion Description Bit Bit Bit Double Word [unsigned]/ Bit string [32-bit] 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.
46
1
Outline
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/FBD]
2
Function/ Operator List
g_bool1
BOOL_TO_DWORD _BOOL
g_dword1
[ST]
g_dword1 := BOOL_TO_DWORD(g_bool1);
3
Function Construction
g_bool1 g_bool2
[ST]
g_bool3 g_dword1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
47
5.6
Outline
This function converts bit data into time data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BOOL_TO_TIME(_BOOL); Example: Label:= BOOL_TO_TIME(M0); BOOL_TO_TIME_E(EN,_BOOL, Output label); Example: BOOL_TO_TIME_E(X000,M0, Label);
BOOL_TO_TIME
M0
BOOL_TO_TIME _BOOL *1
Label
BOOL_TO_TIME_ E
X000 M0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BOOL ( s ) ENO *1 ( d ) Execution condition Conversion source bit data Execution status Time data after conversion Description Bit Bit Bit Time 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.
48
1
Outline
2
Function/ Operator List
g_bool1
BOOL_TO_TIME _BOOL
g_time1 := BOOL_TO_TIME(g_bool1);
g_time1
3
Function Construction
g_bool1 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
49
5.7
Outline
This function converts word [signed] data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_DINT(_INT); Example: Label:= INT_TO_DINT(D0); INT_TO_DINT_E(EN,_INT, Output label); Example: INT_TO_DINT_E(X000,D0, Label);
INT_TO_DINT
D0
INT_TO_DINT _INT *1
Label
X000
INT_TO_DINT_E
D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Double word [signed] data after conversion Description Bit Word [signed] Bit Double Word [signed] 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.
50
1
Outline
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/FBD] [ST]
2
Function/ Operator List
g_int1=5923
INT_TO_DINT _INT
g_dint1 := INT_TO_DINT(g_int1);
g_dint1=5923
3
Function Construction
g_bool1 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
51
5.8
Outline
This function converts double word [signed] data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_INT(_DINT); Example: D10:= DINT_TO_INT(Label); DINT_TO_INT_E(EN,_DINT, Output label); Example: DINT_TO_INT_E(X000, Label, D10);
DINT_TO_INT
Label
DINT_TO_INT _DINT *1
D10
X000
DINT_TO_INT_E
Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Word [signed] data after conversion Description Bit Double Word [signed] Bit Word [signed] 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.
52
1
Outline
In this program, double word [signed] data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DINT_TO_INT)
[Structured ladder/FBD] [ST]
2
Function/ Operator List
g_dint1=5923
DINT_TO_INT _DINT
g_int1 := DINT_TO_INT(g_dint1);
g_int1=5923
3
Function Construction
g_bool1 g_dint1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
53
5.9
Outline
This function converts word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_BOOL(_INT); Example: M0:= INT_TO_BOOL(D0); INT_TO_BOOL_E(EN,_INT, Output label); Example: INT_TO_BOOL_E(X000,D0,M0);
INT_TO_BOOL
D0 X000
M0
INT_TO_BOOL_E
D0
M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Bit data after conversion Description Bit Word [signed] Bit Bit Data type
Cautions
Use the function having "_E" in its name to connect a bus.
54
1
Outline
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)
[Structured ladder/FBD] [ST]
2
Function/ Operator List
g_int1=5923
INT_TO_BOOL _INT
g_bool1 := INT_TO_BOOL(g_int1);
g_bool1
3
Function Construction
g_bool1 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
55
5.10
Outline
This function converts double word [signed] data into bit data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_BOOL(_DINT); Example: M0:= DINT_TO_BOOL(Label); DINT_TO_BOOL_E(EN,_DINT, Output label); Example: DINT_TO_BOOL_E(X000, Label, M0);
DINT_TO_BOOL
Label
DINT_TO_BOOL _DINT *1
M0
DINT_TO_BOOL_ E
X000 Label
M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Bit data after conversion Description Bit Double Word [signed] Bit Bit 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.
56
1
Outline
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)
[Structured ladder/FBD]
2
Function/ Operator List
g_dint1=0
[ST]
DINT_TO_BOOL _DINT
g_bool1
g_bool1 := DINT_TO_BOOL(g_dint1);
3
Function Construction
g_bool1 g_dint1
[ST]
g_bool3 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
57
5.11
Outline
This function converts word [signed] data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_REAL(a_Int); Example: Label:= INT_TO_REAL(D0); INT_TO_REAL_E(EN,a_Int, Output label); Example: INT_TO_REAL_E(X000,D0,Label);
INT_TO_REAL
D0 X000
Label
INT_TO_REAL_E
D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN a_Int ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Float (single precision) data after conversion Description Bit Word [signed] Bit FLOAT (Single Precision) 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. 3) The function is provided in the FX3G Series Ver.1.10 or later. 4) The number of significant figures of FLOAT (Single Precision) data is approximately 7 since the data is processed in 32-bit single precision. Accordingly, the converted data includes an error (rounding error) if an integer value is outside the range of -16777216 to 16777215.
58
1
Outline
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/FBD] [ST]
2
Function/ Operator List
g_int1=5923
INT_TO_REAL a_Int
g_real1 := INT_TO_REAL(g_int1);
g_real1=5923.0
3
Function Construction
g_bool1 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
59
5.12
DINT_TO_REAL(_E) / Double word [signed] data float (single precision) data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts double word [signed] data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_REAL(a_Dint); Example: Label 2 Label 2:= DINT_TO_REAL(Label 1); DINT_TO_REAL_E(EN,a_Dint, Output label); Example: DINT_TO_REAL_E(X000, Label 1, Label 2);
DINT_TO_REAL
Label 1
DINT_TO_REAL a_Dint *1
DINT_TO_REAL_ E
X000 Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN a_Dint ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Float (single precision) data after conversion Description Bit Double Word [signed] Bit FLOAT (Single Precision) 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. 3) The function is provided in the FX3G Series Ver.1.10 or later.
60
1
Outline
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/FBD]
2
Function/ Operator List
g_dint1=65000
[ST]
DINT_TO_REAL a_Dint
g_real1=65000.0
g_real1 := DINT_TO_REAL(g_dint1);
3
Function Construction
g_bool1 g_dint1
[ST]
g_bool3 g_real1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
61
5.13
Outline
This function converts word [signed] data into string data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_STR(_INT); Example: Label:= INT_TO_STR(D0); INT_TO_STR_E(EN,_INT, Output label); Example: INT_TO_STR_E(X000, D0, Label);
INT_TO_STR
D0 X000
Label
INT_TO_STR_E
D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status String data after conversion Description Bit Word [signed] Bit String Data type
High-order byte Low-order byte ASCII code for ten-thousands place Sign data String ASCII code for hundreds place ASCII code for thousands place ASCII code for ones place ASCII code for tens place 0000H 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
High-order byte 20H (space) 31H (1) 33H (3) 0000H Low-order byte 2DH (-) 20H (space) 32H (2) String 1st word 2nd word 3rd word 4th word
4) "00H" is automatically stored at the end (4th word) of the character string.
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling string data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling string data. Use global labels when specifying labels.
62
1
Outline
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
2
Function/ Operator List
Program example
In this program, word [signed] data stored in a device specified in s data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(INT_TO_STR)
[Structured ladder/FBD] [ST]
3
Function Construction
g_int1=-12345
INT_TO_STR _INT
g_string1 := INT_TO_STR(g_int1);
g_string='-12345'
4
How to Read Explanation of Functions
g_bool1 g_int1
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
63
5.14
Outline
This function converts double word [signed] data into string data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_STR(_DINT); Example: Label 2 Label 2:= DINT_TO_STR(Label 1); DINT_TO_STR_E(EN,_DINT, Output label); Example: Label 2 DINT_TO_STR_E(X000, Label 1, Label 2);
DINT_TO_STR
Label 1
DINT_TO_STR _DINT *1
X000
DINT_TO_STR_E
Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status String data after conversion Description Bit Double Word [signed] Bit String Data type
High-order byte Low-order byte ASCII code for billions place Sign data String ASCII code for ten-millions place ASCII code for hundred-millions place ASCII code for hundred-thousands place ASCII code for millions place ASCII code for thousands place ASCII code for ten-thousands place ASCII code for tens place ASCII code for hundreds place 00H ASCII code for ones place Automatically stored at the end of the character string
1st word 2nd word 3rd word 4th word 5th word 6th word
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
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
-123456
Double word [signed] data
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.
64
1
Outline
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
Function/ Operator List
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
3
Function Construction
Program example
In this program, double word [signed] data stored in a device specified in s and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DINT_TO_STR)
[Structured ladder/FBD]
4
How to Read Explanation of Functions
g_dint1=-12345678
[ST]
DINT_TO_STR _DINT
g_string1='-12345678'
g_string1 := DINT_TO_STR(g_dint1);
5
Applied Functions (Type Conversion Functions)
g_bool1 g_dint1
[ST]
g_bool3 g_string1
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
65
5.15
INT_TO_WORD(_E) / Word [signed] data word [unsigned]/ bit string [16-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts word [signed] data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_WORD(_INT); Example: D10:= INT_TO_WORD(D0); INT_TO_WORD_E(EN,_INT, Output label); Example: INT_TO_WORD_E(X000,D0,D10);
INT_TO_WORD
D0 X000 D0
D10
INT_TO_WORD_ E
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Word [unsigned]/Bit String [16-bit] data after conversion Description Bit Word [signed] Bit Word [unsigned]/ Bit String [16-bit] Data type
Cautions
Use the function having "_E" in its name to connect a bus.
66
1
Outline
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/FBD]
2
Function/ Operator List
g_int1=5923
[ST]
INT_TO_WORD _INT
g_word1=16#1723
g_word1 := INT_TO_WORD(g_int1);
3
Function Construction
g_bool1 g_int1
[ST]
g_bool3 g_word1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
67
5.16
DINT_TO_WORD(_E) / Double word [signed] data word [unsigned]/ bit string [16-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts double word [signed] data into word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_WORD(_DINT); Example: D10:= DINT_TO_WORD(Label); DINT_TO_WORD_E(EN,_DINT, Output label); Example: DINT_TO_WORD_E(X000, Label, D10);
DINT_TO_WORD
Label
DINT_TO_WORD _DINT *1
D10
DINT_TO_WORD _E
X000 Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Word [unsigned]/bit string [16-bit] data after conversion Description Bit Double Word [signed] Bit Word [unsigned]/ Bit String [16-bit] Data type
12345678 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0 614E 0 11 0 0 0 01 01 0 0 1 11 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.
68
1
Outline
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/FBD]
2
Function/ Operator List
g_dint1=12345678
[ST]
DINT_TO_WORD _DINT
g_word1=16#614E
g_word1 := DINT_TO_WORD(g_dint1);
3
Function Construction
g_bool1 g_dint1
[ST]
g_bool3 g_word1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
69
5.17
INT_TO_DWORD(_E) / word [signed] data double word [unsigned]/ bit string [32-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts word [signed] data into double word [unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_DWORD(_INT); Example: Label:= INT_TO_DWORD(D0); INT_TO_DWORD_E(EN,_INT, Output label); Example: INT_TO_DWORD_E(X000,D0, Label);
INT_TO_DWORD
D0
INT_TO_DWORD _INT *1
Label
INT_TO_DWORD _E
X000 D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Double word [unsigned]/bit string [32-bit] data after conversion Description Bit Word [signed] Bit Double Word [unsigned]/ Bit string [32-bit] 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.
70
1
Outline
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/FBD]
2
Function/ Operator List
g_int1=10
[ST]
INT_TO_DWORD _INT
g_dword1=16#0000000A
g_dword1 := INT_TO_DWORD(g_int1);
3
Function Construction
g_bool1 g_int1
[ST]
g_bool3 g_dword1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
71
5.18
DINT_TO_DWORD(_E) / Double word [signed] data double word [unsigned]/bit string [32-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts double word [signed] data into double word [unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_DWORD(_DINT); Example: Label 2 Label 2:= DINT_TO_DWORD(Label 1); DINT_TO_DWORD_E(EN,_DINT, Output label); Example: Label 2 DINT_TO_DWORD_E(X000, Label 1, Label 2);
DINT_TO_DWOR D
Label 1
DINT_TO_DWORD _DINT *1
DINT_TO_DWOR D_E
X000 Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Double word [unsigned]/bit string [32-bit] data after conversion Description Bit Double Word [signed] Bit Double Word [unsigned]/ Bit string [32-bit] 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.
72
1
Outline
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/FBD]
2
Function/ Operator List
g_dint1=74565
[ST]
DINT_TO_DWORD _DINT
g_dword1=16#00012345
g_dword1 := DINT_TO_DWORD(g_dint1);
3
Function Construction
g_bool1 g_dint1
[ST]
g_bool3 g_dword1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
73
5.19
Outline
This function converts word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_BCD(_INT); Example: D10:= INT_TO_BCD(D0); INT_TO_BCD_E(EN,_INT, Output label); Example: INT_TO_BCD_E(X000,D0,D10);
INT_TO_BCD
D0 X000
D10
INT_TO_BCD_E
D0
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status BCD data after conversion Description Bit Word [signed] Bit Word [unsigned]/ Bit String [16-bit] Data type
9999
9999H
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
74
1
Outline
In this program, word [signed] data stored in a device specified in s data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(INT_TO_BCD)
[Structured ladder/FBD]
2
Function/ Operator List
g_int1=5923
[ST]
INT_TO_BCD _INT
g_word=16#5923
g_word1 := INT_TO_BCD(g_int1);
3
Function Construction
g_bool1 g_int1
[ST]
g_bool3 g_word1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
75
5.20
Outline
This function converts double word [signed] data into BCD data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_BCD(_DINT); Example: Label 2 Label 2:= DINT_TO_BCD(Label 1); DINT_TO_BCD_E(EN,_DINT, Output label); Example: DINT_TO_BCD_E(X000, Label 1, Label 2);
DINT_TO_BCD
Label 1
DINT_TO_BCD _DINT *1
X000
DINT_TO_BCD_E
Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status BCD data after conversion Description Bit Double Word [signed] Bit ANY_BIT Data type
104
103
102
99999999H
Ten-millions Millions HundredTen- Thousands Hundreds place place thousands thousands place place place 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.
76
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
101
231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20
1
Outline
An operation error occurs when the value stored in a device specified in "99,999,999".
Program example
In this program, double word [signed] data stored in a device specified in s and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DINT_TO_BCD)
[Structured ladder/FBD]
2
Function/ Operator List
g_dint1=20000
[ST]
DINT_TO_BCD _DINT
3
g_dword1=16#00020000
Function Construction
g_dword1 := DINT_TO_BCD(g_dint1);
4
How to Read Explanation of Functions
g_bool1 g_dint1
[ST]
g_bool3 g_dword1
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
77
5.21
Outline
This function converts word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_TIME(_INT); Example: Label:= INT_TO_TIME(D0); INT_TO_TIME_E(EN,_INT, Output label); Example: INT_TO_TIME_E(X000,D0,Label);
INT_TO_TIME
D0 X000
Label
INT_TO_TIME_E
D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _INT ( s ) ENO *1 ( d ) Execution condition Conversion source word [signed] data Execution status Time data after conversion Description Bit Word [signed] Bit Time 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.
78
1
Outline
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)
[Structured ladder/FBD] [ST]
2
Function/ Operator List
g_int1
INT_TO_TIME _INT
g_time1 := INT_TO_TIME(g_int1);
g_time1
3
Function Construction
g_bool1 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
79
5.22
Outline
This function converts double word [signed] data into time data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_TIME(_DINT); Example: Label 2 Label 2:= DINT_TO_TIME(Label 1); DINT_TO_TIME_E(EN,_DINT, Output label); Example: DINT_TO_TIME_E(X000, Label 1, Label 2);
DINT_TO_TIME
Label 1
DINT_TO_TIME _DINT *1
DINT_TO_TIME_ E
X000 Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DINT ( s ) ENO *1 ( d ) Execution condition Conversion source double word [signed] data Execution status Time data after conversion Description Bit Double Word [signed] Bit Time 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.
80
1
Outline
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)
[Structured ladder/FBD] [ST]
2
Function/ Operator List
g_dint1
DINT_TO_TIME _DINT
g_time1 := DINT_TO_TIME(g_dint1);
g_time1
3
Function Construction
g_bool1 g_dint1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
81
5.23
Outline
This function converts float (single precision) data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST REAL_TO_INT(a_real); Example: D10:= REAL_TO_INT(Label); REAL_TO_INT_E(EN,a_real, Output label); Example: REAL_TO_INT_E(X000, Label, D10);
REAL_TO_INT
Label
REAL_TO_INT a_real *1
D10
X000
REAL_TO_INT_E
Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN a_real ENO *1 ( d ) ( s ) Execution condition Conversion source float (single precision) data Execution status Word [signed] data after conversion Description Bit FLOAT (Single Precision) Bit Word [signed] 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. 3) The function is provided in the FX3G Series Ver.1.10 or later. 4) In the data obtained by conversion, the portion after the decimal point of the float (single precision) data (source data) is rounded off. 5) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
82
1
Outline
In this program, float (single precision) data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(REAL_TO_INT)
[Structured ladder/FBD]
2
Function/ Operator List
g_real1=5923.5
[ST]
REAL_TO_INT a_real
g_int1=5923
g_int1 := REAL_TO_INT(g_real1);
3
Function Construction
g_bool1 g_real1
[ST]
g_bool3 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
83
5.24
REAL_TO_DINT(_E) / Float (single precision) data double word [signed] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts float (single precision) data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST REAL_TO_DINT(a_real); Example: Label 2:= REAL_TO_DINT(Label 1); REAL_TO_DINT_E(EN,a_real, Output label); Example: REAL_TO_DINT_E(X000, Label 1, Label 2);
REAL_TO_DINT
Label 1
REAL_TO_DINT a_real *1
Label 2
REAL_TO_DINT_ E
X000 Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN a_real ENO *1 ( d ) ( s ) Execution condition Conversion source float (single precision) data Execution status Double word [signed] data after conversion Description Bit FLOAT (Single Precision) Bit Double Word [signed] 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. 3) The function is provided in the FX3G Series Ver.1.10 or later. 4) In the data obtained by conversion, the portion after the decimal point of the float (single precision) data (source data) is rounded off. 5) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
84
1
Outline
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/FBD]
2
Function/ Operator List
g_real1=65000.5
[ST]
REAL_TO_DINT a_real
g_dint1=65000
g_dint1 := REAL_TO_DINT(g_real1);
3
Function Construction
g_bool1 g_real1
[ST]
g_bool3 g_dint1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
85
5.25
Outline
This function converts float (single precision) data into string data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST REAL_TO_STR(_REAL); Example: Label 2:= REAL_TO_STR(Label 1); REAL_TO_STR_E(EN,_REAL, Output label); Example: REAL_TO_STR_E(X000, Label 1, Label 2);
REAL_TO_STR
Label 1
REAL_TO_STR _REAL *1
Label 2
X000
REAL_TO_STR_E
Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _REAL ( s ) ENO *1 ( d ) Execution condition Conversion source float (single precision) data Execution status String data after conversion Description Bit FLOAT (Single Precision) Bit String Data type
into string
86
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) -12.3456 Float (single precision) data Decimal part (5 digits) Exponent part (2 digits)
Outline
2
Function/ Operator List
3
Function Construction
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) 7 -12.345678 Float (single precision) data - 1 . 2 3 4 5 6 7 8 E + 0 1 Number of digits of decimal part (5) These digits are rounded.
4
How to Read Explanation of Functions
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 Float (single precision) data - 1 . 2 3 4 0 0 E + 0 1 "30H (0)" is stored. Number of digits of decimal part (5)
5
Applied Functions (Type Conversion Functions)
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) Number of digits of exponent part (2) -12.3456 Float (single precision) data - 1 . 2 3 4 5 6 E + 0 1 "30H (0)" is stored.
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
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. 3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
87
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error code. 1) When the value stored in a device specified in s is outside the following range: 0, 2-126 (Value of device specified in s ) 2128 (Error code: K6706) 2) When the range of a device which will store the character string obtained by conversion (device specified in d ) exceeds the range of the corresponding device (Error code: K6706) 3) When the conversion result exceeds the specified total number of digits (Error code: K6706)
Program example
In this program, float (single precision) data stored in a device specified in s and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(REAL_TO_STR)
[Structured ladder/FBD]
g_real1=-12.34567
[ST]
REAL_TO_STR _REAL
g_string1="-1.23457E+01"
g_string1 := REAL_TO_STR(g_real1);
g_bool1 g_real1
[ST]
g_bool3 g_string1
88
5.26
WORD_TO_BOOL(_E) / Word [unsigned] / bit string [16-bit] data bit data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST WORD_TO_BOOL(_WORD); Example: M0:= WORD_TO_BOOL(D0); WORD_TO_BOOL_E(EN, _WORD, Output label); Example: WORD_TO_BOOL_E(X000,D0, M0);
3
Function Construction
WORD_TO_BOO L
D0
WORD_TO_BOOL _WORD *1
M0
4
How to Read Explanation of Functions
WORD_TO_BOO L_E
X000 D0
M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _WORD ( s ) ENO *1 ( d ) Execution condition Conversion source word [unsigned]/bit String [16-bit] data Execution status Bit data after conversion Description Bit Word [unsigned]/ Bit String [16-bit] Bit Bit Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
Cautions
Use the function having "_E" in its name to connect a bus.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
89
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(WORD_TO_BOOL)
[Structured ladder/FBD]
g_word1=16#0001
[ST]
WORD_TO_BOOL _WORD
g_bool1
g_bool1 := WORD_TO_BOOL(g_word1);
g_bool1 g_word1
[ST]
g_bool3 g_bool2
90
5.27
DWORD_TO_BOOL(_E) / Double word [unsigned]/bit string [32-bit] data bit data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST DWORD_TO_BOOL(_DWORD); Example: M0:= DWORD_TO_BOOL(Label); DWORD_TO_BOOL_E(EN, _DWORD, Output label); Example: DWORD_TO_BOOL_E(X000, Label, M0);
3
Function Construction
DWORD_TO_BO OL
Label
DWORD_TO_BOOL _DWORD *1
M0
4
How to Read Explanation of Functions
DWORD_TO_BO OL_E
X000 Label
M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DWORD ( s ) ENO *1 ( d ) Execution condition Conversion source double word [unsigned]/bit string [32-bit] data Execution status Bit data after conversion Description Bit Double Word [unsigned]/ Bit string [32-bit] Bit Bit Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
91
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in into bit data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DWORD_TO_BOOL)
[Structured ladder/FBD]
is converted
g_dword1=16#00000001
[ST]
DWORD_TO_BOOL _DWORD
g_bool1
g_bool1 := DWORD_TO_BOOL(g_dword1);
g_bool1 g_dword1
[ST]
g_bool3 g_bool2
92
5.28
WORD_TO_INT(_E) / Word [unsigned]/bit string [16-bit] data word [signed] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST WORD_TO_INT(_WORD); Example: D10:= WORD_TO_INT(D0); WORD_TO_INT_E(EN,_WORD, Output label); Example: WORD_TO_INT_E(X000,D0, D10);
3
Function Construction
WORD_TO_INT
D0
WORD_TO_INT _WORD *1
D10
4
How to Read Explanation of Functions
WORD_TO_INT_ E
X000 D0
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _WORD ( s ) ENO *1 ( d ) Execution condition Conversion source word [unsigned]/bit string [16-bit] data Execution status Word [signed] data after conversion Description Bit Word [unsigned]/ Bit String [16-bit] Bit Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into word
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
Cautions
Use the function having "_E" in its name to connect a bus.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
93
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(WORD_TO_INT)
[Structured ladder/FBD]
g_word1=16#000A
[ST]
WORD_TO_INT _WORD
g_int1=10
g_int1 := WORD_TO_INT(g_word1);
g_bool1 g_word1
[ST]
g_bool3 g_int1
94
5.29
WORD_TO_DINT(_E) / Word [unsigned]/bit string [16-bit] data double word [signed] (signed) data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST WORD_TO_DINT(_WORD); Example: Label:= WORD_TO_DINT(D0); WORD_TO_DINT_E(EN,_WORD, Output label); Example: WORD_TO_DINT_E(X000,D0, Label);
3
Function Construction
WORD_TO_DINT
D0
WORD_TO_DINT _WORD *1
Label
4
How to Read Explanation of Functions
WORD_TO_DINT _E
X000 D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _WORD ( s ) ENO *1 ( d ) Execution condition Conversion source word [unsigned]/bit string [16-bit] data Execution status Double word [signed] data after conversion Description Bit Word [unsigned]/ Bit String [16-bit] Bit Double Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into double
7
Applied Functions (Standard Arithmetic Functions)
0 1 0 1 01 1 0 0 1 1 1 1 0 00 Data conversion 0 0 0 0 0 0 0 0 00 00 0 0 00 01 01 0 1 1 0 01 1 1 1 0 0 0 Each of high-order 16 bits becomes "0" after data conversion.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean 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.
10
Applied Functions (Standard Selection Functions)
95
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/FBD]
g_word1=16#1234
[ST]
WORD_TO_DINT _WORD
g_dint1=4660
g_dint1 := WORD_TO_DINT(g_word1);
g_bool1 g_word1
[ST]
g_bool3 g_dint1
96
5.30
DWORD_TO_INT(_E) / Double word [unsigned]/bit string [32-bit] data Word [signed] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST DWORD_TO_INT(_DWORD); Example: D10:= DWORD_TO_INT(Label); DWORD_TO_INT_E(EN, _DWORD, Output label); Example: DWORD_TO_INT_E(X000,Label, D10);
3
Function Construction
DWORD_TO_INT
Label
DWORD_TO_INT _DWORD *1
D10
4
How to Read Explanation of Functions
DWORD_TO_INT _E
X000 Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DWORD ( s ) ENO *1 ( d ) Execution condition Conversion source double word [unsigned]/bit string [32-bit] data Execution status Word [signed] data after conversion Description Bit Double Word [unsigned]/ Bit string [32-bit] Bit Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into
7
Applied Functions (Standard Arithmetic Functions)
0 0 00 0 0 0 01 0 11 11 0 0 0 11 0 0 0 0 1 0 1 0 0 11 1 0 01 1 00 0 0 10 1 0 0 1 1 1 0
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean 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.
10
Applied Functions (Standard Selection Functions)
97
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DWORD_TO_INT)
[Structured ladder/FBD]
g_dword1=16#00012345
[ST]
DWORD_TO_INT _DWORD
g_int1=9029
g_int1 := DWORD_TO_INT(g_dword1);
g_bool1 g_dword1
[ST]
g_bool3 g_int1
98
5.31
DWORD_TO_DINT(_E) / Double word [unsigned]/bit string [32-bit] data double word [signed] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST DWORD_TO_DINT(_DWORD); Example: Label 2 Label 2:= DWORD_TO_DINT(Label 1); DWORD_TO_DINT_E(EN, _DWORD, Output label); Example: Label 2 DWORD_TO_DINT_E(X000, Label 1, Label 2);
3
Function Construction
DWORD_TO_DIN T
Label 1
DWORD_TO_DINT _DWORD *1
4
How to Read Explanation of Functions
DWORD_TO_DIN T_E
X000 Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DWORD ( s ) ENO *1 ( d ) Execution condition Conversion source double word [unsigned]/bit string [32-bit] data Execution status Double word [signed] data after conversion Description Bit Double Word [unsigned]/ Bit string [32-bit] Bit Double Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
99
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/FBD]
g_dword1=16#00012345
[ST]
DWORD_TO_DINT _DWORD
g_dint1=74565
g_dint1 := DWORD_TO_DINT(g_dword1);
g_bool1 g_dword1
[ST]
g_bool3 g_dint1
100
5.32
WORD_TO_DWORD(_E) / Word [unsigned]/bit string [16-bit] data double word [unsigned]/bit string [32-bit data conversion]
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST WORD_TO_DWORD(_WORD); Example: Label:= WORD_TO_DWORD(D0);
3
Function Construction
WORD_TO_DWO RD
D0
WORD_TO_DWORD _WORD *1
Label
WORD_TO_DWO RD_E
X000 D0
4
How to Read Explanation of Functions
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _WORD ( s ) ENO *1 ( d ) Execution condition Conversion source word [unsigned]/bit string [16-bit] data Execution status Double word[unsigned]/bit string[32-bit] data after conversion Description Bit Word [unsigned]/ Bit String [16-bit] Bit Double Word [unsigned]/ Bit string [32-bit] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
101
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/FBD]
g_word1=16#1234
[ST]
WORD_TO_DWORD _WORD
g_dword1=16#00001234
g_dword1 := WORD_TO_DWORD(g_word1);
g_bool1 g_word1
[ST]
g_bool3 g_dword1
102
5.33
DWORD_TO_WORD(_E) / Double word [unsigned]/bit string[32-bit] data word [unsigned]/bit string [16-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST DWORD_TO_WORD(_DWORD); Example: D10:= DWORD_TO_WORD(Label); DWORD_TO_WORD_E(EN, _DWORD, Output label); Example: DWORD_TO_WORD_E(X000, Label, D10);
3
Function Construction
DWORD_TO_WO RD
Label
DWORD_TO_WORD _DWORD *1
D10
4
How to Read Explanation of Functions
DWORD_TO_WO RD_E
X000 Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DWORD ( s ) ENO *1 ( d ) Execution condition Conversion source double word [unsigned]/bit string [32-bit] data Execution status Word [unsigned]/bit string [16-bit] data after conversion Description Bit Double Word [unsigned] /Bit string [32-bit] Bit Word [unsigned]/ Bit String [16-bit] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
12345678H 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 5678H 0 1 01 0 1 1 0 0 1 1 1 1 0 00
9
Applied Functions (Standard Bitwise Boolean 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.
10
Applied Functions (Standard Selection Functions)
103
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/FBD]
g_dword1=16#12345678
[ST]
DWORD_TO_WORD _DWORD
g_word1=16#5678
g_word1 := DWORD_TO_WORD(g_dword1);
g_bool1 g_dword1
[ST]
g_bool3 g_word1
104
5.34
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST WORD_TO_TIME(_WORD); Example: Label:= WORD_TO_TIME(D0); WORD_TO_TIME_E(EN,_WORD, Output label); Example: WORD_TO_TIME_E(X000,D0, Label);
3
Function Construction
WORD_TO_TIME
D0
WORD_TO_TIME _WORD *1
Label
4
How to Read Explanation of Functions
WORD_TO_TIME _E
X000 D0
Label
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _WORD ( s ) ENO *1 ( d ) Execution condition Conversion source word [unsigned]/bit string [16-bit] data Execution status Time data after conversion Description Bit Word [unsigned]/ Bit String[ 16-bit] Bit Time Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into time
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
105
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in time data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(WORD_TO_TIME)
[Structured ladder/FBD]
is converted into
g_word1
[ST]
WORD_TO_TIME _WORD
g_time1
g_time1 := WORD_TO_TIME(g_word1);
g_bool1 g_word1
[ST]
g_bool3 g_time1
106
5.35
DWORD_TO_TIME(_E) / Double word [unsigned]/bit string [32-bit] data time data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
2
Function/ Operator List
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 Expression in each language Structured ladder/FBD ST DWORD_TO_TIME(_DWORD); Example: Label 2 Label 2:= DWORD_TO_TIME(Label 1); DWORD_TO_TIME_E(EN,_ DWORD, Output label); Example: Label 2 DWORD_TO_TIME_E(X000, Label 1, Label 2);
3
Function Construction
DWORD_TO_TIM E
Label 1
DWORD_TO_TIME _DWORD *1
4
How to Read Explanation of Functions
DWORD_TO_TIM E_E
X000 Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _DWORD ( s ) ENO *1 ( d ) Execution condition Conversion source double word [unsigned]/bit string [32-bit] data Execution status Time data after conversion Description Bit Double Word [unsigned]/ Bit string [32-bit] Bit Time Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
into
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
107
In this program, double word [unsigned]/bit string [32-bit] data stored in a device specified in into time data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(DWORD_TO_TIME)
[Structured ladder/FBD]
is converted
g_dword1
[ST]
DWORD_TO_TIME _DWORD
g_time1
g_time1 := DWORD_TO_TIME(g_dword1);
g_bool1 g_dword1
[ST]
g_bool3 g_time1
108
5.36
1
Outline
Outline
This function converts string data into bit data, and outputs the data obtained by conversion.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST STR_TO_BOOL(_STRING); Example: M0:= STR_TO_BOOL(Label); STR_TO_BOOL_E(EN,_STRING, Output label); Example: STR_TO_BOOL_E(X000, Label, M0);
3
Function Construction
STR_TO_BOOL
Label
STR_TO_BOOL _STRING *1
M0
STR_TO_BOOL_ E
X000 Label
M0
4
How to Read Explanation of Functions
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _STRING ( s ) ENO *1 ( d ) Execution condition Conversion source string data Execution status Bit data after conversion Description Bit String Bit Bit Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic 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 string data. Use global labels when specifying labels.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
109
g_string1
[ST]
STR_TO_BOOL _STRING
g_bool1
g_bool1 := STR_TO_BOOL(g_string1);
g_bool1 g_string1
[ST]
g_bool3 g_bool2
110
5.37
1
Outline
Outline
This function converts string data into word [signed] data, and outputs the data obtained by conversion.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST STR_TO_INT(_STRING); Example: D10:= STR_TO_INT(Label); STR_TO_INT_E(EN,_STRING, Output label); Example: STR_TO_INT_E(X000, Label, D10);
3
Function Construction
STR_TO_INT
Label
STR_TO_INT _STRING *1
D10
X000
STR_TO_INT_E
Label
D10
4
How to Read Explanation of Functions
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _STRING ( s ) ENO *1 ( d ) Execution condition Conversion source string data Execution status Word [signed] data after conversion Description Bit String Bit Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
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.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
111
1) When the sign data (low-order byte) of the 1st word stored in a device specified in "20H (space)" or "2DH (-)" (Error code: K6706) 2) When the ASCII code for each place (digit) stored in "20H (space)" or "00H (NULL)" (Error code: K6706) 3) When the value stored in -32768 to +32767 (Error code: K6706) 4) When any of devices (Error code: K6706)
s s s
to
to
to
Program example
In this program, string data stored in a device specified in s is converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(STR_TO_INT)
[Structured ladder/FBD]
g_string1="-12345"
[ST]
STR_TO_INT _STRING
g_int1=-12345
g_int1 := STR_TO_INT(g_string1);
g_bool1 g_string1
[ST]
g_bool3 g_int1
112
5.38
1
Outline
2
Function/ Operator List
Outline
This function converts string data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST STR_TO_DINT(_STRING); Example: Label 2 Label 2:= STR_TO_DINT(Label 1); STR_TO_DINT_E(EN,_STRING, Output label); Example: Label 2 STR_TO_DINT_E(X000, Label 1, Label 2);
3
Function Construction
STR_TO_DINT
Label 1
STR_TO_DINT _STRING *1
4
How to Read Explanation of Functions
X000
STR_TO_DINT_E
Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _STRING ( s ) ENO *1 ( d ) Execution condition Conversion source string data Execution status Double word [signed] data after conversion Description Bit String Bit Double Word [signed] Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift 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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
113
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
3) When the value stored in s to s +5 is outside the following range: -2,147,483,648 to +2,147,483,647 (Error code: K6706) 4) When any of devices (Error code: K6706)
s
to
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/FBD]
g_string1="_ _65000"
[ST]
STR_TO_DINT _STRING
g_dint1=65000
g_dint1 := STR_TO_DINT(g_string1);
g_bool1 g_string1
[ST]
g_bool3 g_dint1
114
5.39
1
Outline
2
Function/ Operator List
Outline
This function converts string data into float (single precision) data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST STR_TO_REAL(_STRING); Example: Label 2 Label 2:= STR_TO_REAL(Label 1); STR_TO_REAL_E(EN,_STRING, Output label); Example: Label 2 STR_TO_REAL_E(X000, Label 1, Label 2);
3
Function Construction
STR_TO_REAL
Label 1
STR_TO_REAL _STRING *1
4
How to Read Explanation of Functions
X000
STR_TO_REAL_E
Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _STRING ( s ) ENO *1 ( d ) Execution condition Conversion source string data Execution status Float (single precision) data after conversion Description Bit String Bit FLOAT (Single Precision) Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
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) 0000H - 1 . 3 5 0 3 4 Float (single precision) data Low-order byte 2DH (-) 2EH (.) 35H (5) 33H (3)
9
Applied Functions (Standard Bitwise Boolean Functions)
-1.35034
10
Applied Functions (Standard Selection Functions)
115
Low-order byte 2DH (-) 2EH (3) 35H (5) 33H (3) 45H (E) 31H (1)
- 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 Discarded -1.35034 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 Ignored -1.35034 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 Ignored -1.35034E-2 Float (single precision) data
8) When "20H (space)" is contained in character string, "20H (space)" is ignored during conversion. 9) Up to 24 characters can be input as string data. Each of "20H (space)" and "30H (0)" contained in string is counted as 1 character respectively.
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling string data and 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling string data and 32-bit data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
116
1
Outline
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
2
Function/ Operator List
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
3
Function Construction
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/FBD]
4
How to Read Explanation of Functions
g_string1
[ST]
STR_TO_REAL _STRING
g_real1
5
Applied Functions (Type Conversion Functions)
g_real1 := STR_TO_REAL(g_string1);
g_bool1 g_string1
[ST]
6
Applied Functions (Standard Functions Of One Numeric Variable)
g_bool3 g_real1
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
117
5.40
Outline
This function converts string data into time data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST STR_TO_TIME(_STRING); Example: Label 2:= STR_TO_TIME(Label 1); STR_TO_TIME_E(EN,_STRING, Output label); Example: STR_TO_TIME_E(X000, Label 1, Label 2);
STR_TO_TIME
Label 1
STR_TO_TIME _STRING *1
Label 2
X000
STR_TO_TIME_E
Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _STRING ( s ) ENO *1 ( d ) Execution condition Conversion source string data Execution status Time data after conversion Description Bit String Bit Time Data type
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.
118
1
Outline
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
2) When the ASCII code for each digit of character string data specified in "39H (9)", "20H (space)" or "00H (NULL)" (Error code: K6706) 3) When the numeric value specified in -2,147,483,648 to +2,147,483,647 (Error code: K6706)
s
2
Function/ Operator List
3
Function Construction
Program example
In this program, string data stored in a device specified in s obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(STR_TO_TIME)
[Structured ladder/FBD]
4
How to Read Explanation of Functions
g_string1
[ST]
STR_TO_TIME _STRING
g_time1
g_time1 := STR_TO_TIME(g_string1);
5
Applied Functions (Type Conversion Functions)
g_bool1 g_string1
[ST]
g_bool3 g_time1
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
119
5.41
Outline
This function converts BCD data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BCD_TO_INT(_BCD); Example: D10:= BCD_TO_INT(D0); BCD_TO_INT_E(EN,_BCD, Output label); Example: BCD_TO_INT_E(X000,D0,D10);
BCD_TO_INT
D0 X000
D10
BCD_TO_INT_E
D0
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BCD ( s ) ENO *1 ( d ) Execution condition Conversion source BCD data Execution status Word [signed] data after conversion Description Bit Word [unsigned]/ Bit String [16-bit] Bit Word [signed] Data type
9999H
9999
Cautions
Use the function having "_E" in its name to connect a bus.
Error
When the source data is not BCD (decimal number), M8067 (operation error) turns ON.
120
1
Outline
2
Function/ Operator List
g_word1=16#1234
[ST]
BCD_TO_INT _BCD
g_int1=1234
g_int1 := BCD_TO_INT(g_word1);
3
Function Construction
g_bool1 g_word1
[ST]
g_bool3 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
121
5.42
Outline
This function converts BCD data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BCD_TO_DINT(_BCD); Example: Label 2:= BCD_TO_DINT(Label 1); BCD_TO_DINT_E(EN,_BCD, Output label); Example: BCD_TO_DINT_E(X000, Label 1, Label 2);
BCD_TO_DINT
Label 1
BCD_TO_DINT _BCD *1
Label 2
X000
BCD_TO_DINT_E
Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _BCD ( s ) ENO *1 ( d ) Execution condition Conversion source BCD data Execution status Double word [signed] data after conversion Description Bit ANY_BIT Bit Double Word [signed] Data type
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 HundredTen- Thousands Hundreds Tens place thousands thousands place place place place place Conversion into DINT data Ones place
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.
122
231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
1
Outline
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/FBD]
2
Function/ Operator List
g_word1=16#0000
[ST]
BCD_TO_DINT _BCD
g_dint1=0
g_dint1 := BCD_TO_DINT(g_word1);
3
Function Construction
g_bool1 g_word1
[ST]
g_bool3 g_dint1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
123
5.43
Outline
This function converts time data into bit data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST TIME_TO_BOOL(_TIME); Example: M0:= TIME_TO_BOOL(Label); TIME_TO_BOOL_E(EN,_TIME, Output label); Example: TIME_TO_BOOL_E(X000, Label, M0);
TIME_TO_BOOL
Label
TIME_TO_BOOL _TIME *1
M0
TIME_TO_BOOL_ E
X000 Label
M0
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status Bit data after conversion Description Bit Time Bit Bit 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.
124
1
Outline
2
Function/ Operator List
g_time1
[ST]
TIME_TO_BOOL _TIME
g_bool1
g_bool1 := TIME_TO_BOOL(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_bool2
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
125
5.44
Outline
This function converts time data into word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST TIME_TO_INT(_TIME); Example: D10:= TIME_TO_INT(Label); TIME_TO_INT_E(EN,_TIME, Output label); Example: TIME_TO_INT_E(X000, Label, D10);
TIME_TO_INT
Label
TIME_TO_INT _TIME *1
D10
X000
TIME_TO_INT_E
Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status Word [signed] data after conversion Description Bit Time Bit Word [signed] 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.
126
1
Outline
2
Function/ Operator List
g_time1
[ST]
TIME_TO_INT _TIME
g_int1
g_int1 := TIME_TO_INT(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_int1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
127
5.45
Outline
This function converts time data into double word [signed] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST TIME_TO_DINT(_TIME); Example: Label 2:= TIME_TO_DINT(Label 1); TIME_TO_DINT_E(EN,_TIME, Output label); Example: TIME_TO_DINT_E(X000,Label 1, Label 2);
TIME_TO_DINT
Label 1
TIME_TO_DINT _TIME *1
Label 2
TIME_TO_DINT_ E
X000 Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status Double word [signed] data after conversion Description Bit Time Bit Double Word [signed] 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.
128
1
Outline
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/FBD]
2
Function/ Operator List
g_time1
[ST]
TIME_TO_DINT _TIME
g_dint1
g_dint1 := TIME_TO_DINT(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_dint1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
129
5.46
Outline
This function converts time data into string data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST TIME_TO_STR(_TIME); Example: Label 2 Label 2:= TIME_TO_STR(Label 1); TIME_TO_STR_E(EN,_TIME, Output label); Example: TIME_TO_STR_E(X000, Label 1, Label 2);
TIME_TO_STR
Label 1
TIME_TO_STR _TIME *1
X000
TIME_TO_STR_E
Label 1
Label 2
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status String data after conversion Description Bit Time Bit String 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.
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
130
1
Outline
2
Function/ Operator List
g_time1
[ST]
TIME_TO_STR _TIME
g_string1
g_string1 := TIME_TO_STR(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_string1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
131
5.47
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 Expression in each language Structured ladder/FBD ST TIME_TO_WORD(_TIME); Example: D10:= TIME_TO_WORD(Label); TIME_TO_WORD_E(EN,_TIME, Output label); Example: TIME_TO_WORD_E(X000, Label, D10);
TIME_TO_WORD
Label
TIME_TO_WORD _TIME *1
D10
TIME_TO_WORD _E
X000 Label
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status Word [unsigned]/bit string [16-bit] data after conversion Description Bit Time Bit Word [unsigned]/ Bit String [16-bit] 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.
132
1
Outline
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/FBD]
2
Function/ Operator List
g_time1
[ST]
TIME_TO_WORD _TIME
g_word1
g_word1 := TIME_TO_WORD(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_word1
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
133
5.48
TIME_TO_DWORD(_E) / Time data double word [unsigned]/ bit string [32-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts time data into double word [unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST TIME_TO_DWORD(_TIME); Example: Label 2 Label 2:= TIME_TO_DWORD(Label 1); TIME_TO_DWORD_E(EN,_TIME, Output label); Example: Label 2 TIME_TO_DWORD_E(X000, Label 1, Label 2);
TIME_TO_DWOR D
Label 1
TIME_TO_DWORD _TIME *1
TIME_TO_DWOR D_E
X000 Label 1
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _TIME ( s ) ENO *1 ( d ) Execution condition Conversion source time data Execution status Double word [unsigned]/bit string [32-bit] data after conversion Description Bit Time Bit Double Word [unsigned]/ Bit string [32-bit] 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.
134
1
Outline
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/FBD]
2
Function/ Operator List
g_time1
[ST]
TIME_TO_DWORD _TIME
g_dword1
g_dword1 := TIME_TO_DWORD(g_time1);
3
Function Construction
g_bool1 g_time1
[ST]
g_bool3 g_dword1
4
How to Read Explanation of Functions
g_dword1 := TIME_TO_DWORD(g_time1);
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
135
5.49
BITARR_TO_INT(_E) / Bit array Word [signed] type, word [unsigned]/ bit String [16-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts specified number of bits of a bit array into word [signed] data or word [unsigned]/bit string [16-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BITARR_TO_INT(BitArr, n); Example: D10:= BITARR_TO_INT Label 1[*2], K4); BITARR_TO_INT_E(EN, BitArr, n, Output label); Example: BITARR_TO_INT_E(X000, Label 1[*2], K4, D10);
BITARR_TO_INT
BITARR_TO_INT
BitArr n BITARR_TO_INT_E EN
*1
D10
BITARR_TO_INT_E
ENO *1 D10
Label 1[*2] K4
BitArr n
*1. *2.
2. Set data
Variable EN Input variable BitArr ( s )
n
Description Execution condition Start bit of conversion source bit array elements Number of specified bits Execution status ( d ) Bit Bit
Data type
Output variable
ENO *1
Word [signed] data or word [unsigned]/bit [16-bit] data after ANY16 conversion
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
136
1
Outline
In this program, 8 bits starting from the 0th element of a bit array stored in a device specified in s are converted into word [signed] data, and the data obtained by conversion is output to a device specified in d . 1) Function without EN/ENO(BITARR_TO_INT)
[Structured ladder/FBD]
2
Function/ Operator List
BITARR_TO_INT
g_bool4[0]
K8
[ST]
BitArr n
g_int1
3
Function Construction
g_bool1 g_bool4[0]
BITARR_TO_INT_E
EN BitArr ENO g_bool2 g_int1
4
How to Read Explanation of Functions
K8
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
137
5.50
BITARR_TO_DINT(_E) / Bit array Double word [signed] type, double word [unsigned]/bit string [32-bit] data conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function converts specified number of bits of a bit array into double word [signed] data or double word [unsigned]/bit string [32-bit] data, and outputs the data obtained by conversion.
1. Format
Function name Expression in each language Structured ladder/FBD ST BITARR_TO_DINT(BitArr, n); Example: Label 2:=BITARR_TO_DINT Label 1[*2], K4); BITARR_TO_DINT_E(EN, BitArr, n, Output label); Example: BITARR_TO_DINT_E(X000, Label 1[*2], K4, Label 2);
BITARR_TO_DINT
BITARR_TO_DINT
BitArr n
*1
Label 2
BITARR_TO_DINT_E
Label 1[*2] K4
*1. *2.
2. Set data
Variable EN Input variable BitArr ( s )
n
Description Execution condition Start bit of conversion source bit array elements Number of specified bits Execution status ( d ) Bit Bit
Data type
Output variable
ENO *1
Double word [signed] data or double word [unsigned]/bit string [32ANY32 bit] data after conversion
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
138
1
Outline
In this program, 8 bits starting from the 0th element of a bit array stored in a device specified in s are 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(BITARR_TO_DINT)
[Structured ladder/FBD]
2
Function/ Operator List
BITARR_TO_DINT
g_bool4[0]
K8
[ST]
BitArr n
g_dint1
3
Function Construction
4
How to Read Explanation of Functions
g_bool1 g_bool4[0]
BITARR_TO_DINT_E
EN BitArr ENO g_bool2 g_dint1
K8
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
139
5.51
INT_TO_BITARR(_E) / Word [signed] data, word [unsigned]/ bit string [16-bit] data bit array conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function outputs low-order "n" bits of word [signed] data or word [unsigned]/bit string [16-bit] data to a bit array.
1. Format
Function name Expression in each language Structured ladder/FBD ST INT_TO_BITARR(s, n); Example: Label 2[*1]:= INT_TO_BITARR(D10, K4); INT_TO_BITARR_E (EN, s, n, BitArr); Example: INT_TO_BITARR_E(X000, D10, K4, Label 2[*1]);
INT_TO_BITARR
INT_TO_BITARR
D10 K4 X000
s n
BitArr
Label 2[*1]
INT_TO_BITARR_E
D10 K4
*1.
2. Set data
Variable EN Input variable
s n
Description Execution condition Bit Conversion source word [signed] data or word [unsigned]/bit string ANY16 [16-bit] data Number of specified bits Execution status Start bit of bit array elements after conversion
Data type
Output variable
ENO BitArr ( d )
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
140
1
Outline
In this program, low-order 4 bits of word [signed] data stored in a device specified in device specified in d . 1) Function without EN/ENO(INT_TO_BITARR)
[Structured ladder/FBD]
are output to a
2
Function/ Operator List
INT_TO_BITARR
g_int1
K4
[ST]
s n
BitArr
g_bool4[0]
3
Function Construction
g_bool1 g_int1
INT_TO_BITARR_E
EN s ENO BitArr g_bool2 g_bool4[0]
4
How to Read Explanation of Functions
K4
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
141
5.52
DINT_TO_BITARR(_E) / Double word [signed] data, double word [unsigned]/bit string [32-bit] data bit array conversion
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function outputs low-order "n" bits of double word [signed] data or double word [unsigned]/bit string [32bit] data to a bit array.
1. Format
Function name Expression in each language Structured ladder/FBD ST DINT_TO_BITARR(s, n); Example: Label 2[*1]:= DINT_TO_BITARR (Label 1, K4) DINT_TO_BITARR_E(EN, s, n, BitArr); Example: DINT_TO_BITARR_E(X000, Label 1, K4, Label 2[*1]);
DINT_TO_BITARR
DINT_TO_BITARR
Label 1 K4 X000
s n
BitArr
Label 2[*1]
DINT_TO_BITARR_E
Label 1 K4
*1.
2. Set data
Variable EN Input variable
s n
Description Execution condition Bit Conversion source double word [signed] data or double word ANY32 [unsigned]/bit string [32-bit] data Number of specified bits Execution status Start bit of bit array elements after conversion
Data type
Output variable
ENO BitArr ( d )
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
142
1
Outline
In this program, low-order 4 bits of double word [signed] data stored in a device specified in a device specified in d . 1) Function without EN/ENO(DINT_TO_BITARR)
[Structured ladder/FBD]
are output to
2
Function/ Operator List
DINT_TO_BITARR
g_dint1
K4
[ST]
s n
BitArr
g_bool4[0]
3
Function Construction
g_bool1 g_dint1
DINT_TO_BITARR_E
EN s ENO BitArr g_bool2 g_bool4[0]
4
How to Read Explanation of Functions
K4
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
143
5.53
Outline
This function copies specified number of bits of a bit array.
1. Format
Function name Expression in each language Structured ladder/FBD ST CPY_BITARR(BitArrIn, n); Example: Label 2[*1] Label 2[*1]:= CPY_BITARR (Label 1[*1], K4); CPY_BITARR_E(EN, BitArrIn, n, BitArrOut); Example: Label 2[*1] CPY_BITARR_E(X000, Label 1[*1], K4, Label 2[*1]);
CPY_BITARR
CPY_BITARR
BitArrIn n
BitArrOut
CPY_BITARR_E
Label 1[*1] K4
*1.
2. Set data
Variable EN Input variable Output variable BitArrIn
n
Description Execution condition ( s ) Start bit of copy source bit array elements Number of specified bits Execution status Start bit of copy destination bit array elements Bit Bit
Data type
ENO BitArrOut ( d )
to a device specified in
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels.
144
1
Outline
In this program, 12 bits starting from the "num1"th element of a bit array stored in a device specified in are output to the "num2"th element and later of a bit array stored in a device specified in d . 1) Function without EN/ENO(CPY_BITARR)
[Structured ladder/FBD]
2
Function/ Operator List
CPY_BITARR
g_bool4[num1]
K12
[ST]
BitArrIn n
BitArrOut
g_bool5[num2]
3
Function Construction
g_bool1 g_bool4[num1]
CPY_BITARR_E
EN BitArrIn ENO BitArrOut g_bool2 g_bool5[num2]
4
How to Read Explanation of Functions
K12
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
145
5.54
Outline
This function reads a value of a specified bit of word [signed] data.
1. Format
Function name Expression in each language Structured ladder/FBD ST GET_BIT_OF_INT(s, n); Example: M10:= GET_BIT_OF_INT (D10, K2); GET_BIT_OF_INT_E(EN, s, n, *1); Example: GET_BIT_OF_INT_E(X000, D10, K2, M10);
GET_BIT_OF_INT
GET_BIT_OF_INT
D10 K2 X000
s n
*1
M10
GET_BIT_OF_INT_E
D10 K2
*1.
Output variable
2. Set data
Variable EN Input variable Output variable
s n
Description Execution condition Read source word [signed] data Specified bit position Execution status ( d ) Read destination bit Bit
ENO *1
Cautions
1) Use the function having "_E" in its name to connect a bus.
146
1
Outline
2
Function/ Operator List
GET_BIT_OF_INT
g_int1
K5
[ST]
s n
g_bool3
3
Function Construction
g_bool1 g_int1
GET_BIT_OF_INT_E
EN s ENO g_bool2 g_bool3
4
How to Read Explanation of Functions
K5
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
147
5.55
Outline
This function writes a value to a specified bit of word [signed] data.
1. Format
Function name Expression in each language Structured ladder/FBD ST SET_BIT_OF_INT(s, n); Example: D10:= SET_BIT_OF_INT (M0, K4); SET_BIT_OF_INT_E(EN, s, n, *1); Example: SET_BIT_OF_INT_E(X000, M0, K4, D10);
SET_BIT_OF_INT
SET_BIT_OF_INT
M0 K4 X000
s n
*1
D10
SET_BIT_OF_INT_E
*1.
Output variable
2. Set data
Variable EN Input variable Output variable
s n
Description Execution condition Write source bit data Specified bit position Execution status ( d ) Write destination word [signed] data Bit Bit
Data type
ENO *1
Cautions
1) Use the function having "_E" in its name to connect a bus.
148
1
Outline
SET_BIT_OF_INT
g_bool1
2
Function/ Operator List
K3
[ST]
s n
g_int3
3
Function Construction
g_bool2 g_bool1
SET_BIT_OF_INT_E
EN s ENO g_bool3 g_int3
4
How to Read Explanation of Functions
K3
[ST]
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
149
5.56
Outline
This function copies a specified bit of word [signed] data to a specified bit of another word [signed] data.
1. Format
Function name Expression in each language Structured ladder/FBD ST CPY_BIT_OF_INT(s, n1, n2); Example: D10:= CPY_BIT_OF_INT (D0, K1, K4);
CPY_BIT_OF_INT
CPY_BIT_OF_INT
D0 K1 K4 X000
s n1 n2
*1
D10
CPY_BIT_OF_INT_E
CPY_BIT_OF_INT_E(EN, s, n1, n2, *1); Example: CPY_BIT_OF_INT_E(X000, D0, K1, K4, D10);
*1.
Output variable
2. Set data
Variable EN Input variable
s n1 n2
Description Execution condition Copy source word [signed] data Specified bit position (copy source) Specified bit position (copy destination) Execution status ( d ) Copy destination word [signed] data Bit
Data type Word [signed] Word [signed] Word [signed] Bit Word [signed]
Output variable
ENO *1
Cautions
1) Use the function having "_E" in its name to connect a bus.
150
1
Outline
In this program, the value of the 5th bit of a device specified in specified in d . 1) Function without EN/ENO(CPY_BIT_OF_INT)
[Structured ladder/FBD]
2
Function/ Operator List
CPY_BIT_OF_INT
g_int1
K5 K3
[ST]
s n1 n2
g_int3
3
Function Construction
4
How to Read Explanation of Functions
g_bool2 g_int1
CPY_BIT_OF_INT_E
EN s ENO g_bool3 g_int3
K5 K3
[ST]
n1 n2
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
151
5.57
Outline
This function outputs the start data as bit data.
1. Format
Function name Expression in each language Structured ladder/FBD ST GET_BOOL_ADDR(s); Example: M10:= GET_BOOL_ADDR (Label);
GET_BOOL_ADDR
*1.
Output variable
2. Set data
Variable Input variable Output variable *1
s
Data type
Cautions
When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
Program example
In this program, MOV instruction is executed using the start bit of bit array data stored in a device specified in s .
[Structured ladder/FBD]
152
5.58
1
Outline
Outline
This function outputs the start data as word [signed] data.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST GET_INT_ADDR(s); Example: D10:= GET_INT_ADDR (Label);
3
Function Construction
GET_INT_ADDR
*1.
Output variable
2. Set data
Variable Input variable Output variable *1
s
4
How to Read Explanation of Functions
Description Input data ANY Word [signed] Data type
( d )
Output data
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
Word [signed], Double Word [signed], Word [unsigned]/Bit String [16-bit], FLOAT (Single Precision), String, Time, Array of Word [signed], Array of double word [signed], Array of word [unsigned]/bit string [16-bit], Word [signed] Array of double word [unsigned]/bit string [32-bit], Array of real number, Array of time type
Cautions
1) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 2) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
Program example
In this program, low-order 16-bit data of double word [signed] data specified in data to buffer memories.
[Structured ladder/FBD]
9
Applied Functions (Standard Bitwise Boolean Functions)
GET_INT_ADDR g_dint1 s
g_bool1 k0 k27 k1
EN s n1 n2 n3
TO ENO
10
Applied Functions (Standard Selection Functions)
[ST]
153
5.59
Outline
This function outputs the start data as word [unsigned]/bit string [16-bit] data.
1. Format
Function name Expression in each language Structured ladder/FBD ST GET_WORD_ADDR(s); Example: D10:= GET_WORD_ADDR (Label);
GET_WORD_ADDR
*1.
Output variable
2. Set data
Variable Input variable Output variable *1
s
Data type
.
Input data type
Word [signed], Double Word [signed], Word [unsigned]/Bit String [16-bit], FLOAT (Single Precision), String, Time, Array of Word [signed], Word [unsigned]/ Array of double word [signed], Array of word [unsigned]/bit string [16-bit], Bit String [16-bit] Array of double word [unsigned]/bit string [32-bit], Array of real number, Array of time type
Cautions
1) When handling 32-bit data and array data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data and array data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 2) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
Program example
In this program, low-order 16-bit data of double word [signed] data specified in [unsigned]/bit string [16-bit] data to buffer memories.
[Structured ladder/FBD]
is written as word
GET_WORD_ADDR g_dint1 s
g_bool1 k0 k27 k1
EN s n1 n2 n3
TO ENO
[ST]
154
10
Outline
Function Construction
Function
Function name
6.
ABS(_E)
Absolute value
Section 6.1
Reference
155
6.1
Outline
This function obtains the absolute value, and outputs it.
1. Format
Function name Expression in each language Structured ladder/FBD ST ABS(_IN); Example: D10:= ABS(D0); ABS_E(EN,_IN,Output label); Example: ABS_E(X000,D0,D10);
ABS
ABS_E
D0
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _IN ( s ) ENO *1 ( d ) Execution condition Description Bit Data type
Data whose absolute value is to be obtained, or word device which ANY_NUM stores such data Execution status Word device which will store the operation result Bit ANY_NUM
B= A
2) When the data type stored in a device specified in s is word [signed] and the stored data is "-32768", this function outputs "-32768" to a device specified in d . (The maximum absolute value handled by this function is "32,767".) When the data type stored in a device specified in s is double word [signed] and the stored data is "2147483648", this function outputs "-2147483648" to a device specified in d . (The maximum absolute value handled by this function is "2147483647".)
156
1
Outline
1) Use the function having "_E" in its name to connect a bus. 2) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
2
Function/ Operator List
Program example
In this program, the absolute value is obtained for word [signed] data stored in a device specified in s , and the operation result is output to a device specified in d using the data type same as the data stored in a device specified in s . 1) Function without EN/ENO(ABS)
[Structured ladder/FBD]
3
Function Construction
ABS g_int1=-5923
[ST]
_IN
g_int2=5923
4
How to Read Explanation of Functions
g_int2 := ABS(g_int1);
5
Applied Functions (Type Conversion Functions)
g_bool1 g_int1
[ST]
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
157
7.
158
7.1
ADD_E / Addition
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
Outline
This function performs addition using two values (A + B = C), and outputs the operation result.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST ADD_E(EN,_IN,_IN,Output label); Example: ADD_E(X000,D0,D10,D20);
3
Function Construction
X000
ADD_E
D0 D10
D20
*1.
Output variable
4
How to Read Explanation of Functions
Description Execution condition Data for addition or word device which stores such data Execution status Bit ANY_NUM Bit ANY_NUM Data type
2. Set data
Variable Input variable Output variable EN _IN ( s1 to s28 ) ENO *1 ( d )
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
5678
s2 (Word d
7
Applied Functions (Standard Arithmetic Functions)
[signed] data)
[signed] data)
s
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
159
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 Name Zero 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
M8021
Borrow
M8022
Carry
-2,147,483,648
-1 , 0 , 1 Zero flag
2,147,483,647 ,
0, 1, 2
Borrow flag
Carry flag
3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
Program example
In this program, addition is performed using double word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_bool3:=ADD_E(g_bool1,g_dint1,g_dint2,g_dint3);
160
7.2
SUB_E / Subtraction
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
Outline
This function performs subtraction using two values (A - B = C), and outputs the operation result.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST SUB_E(EN,_IN1,_IN2,Output label); Example: SUB_E(X000,D0,D10,D20);
3
Function Construction
X000
SUB_E
D0 D10
D20
*1.
Output variable
4
How to Read Explanation of Functions
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 Bit ANY_NUM ANY_NUM Bit ANY_NUM Data type
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d )
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
6789
s2 (Word [signed] data)
5556
d (Word [signed] data)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
161
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 Name Zero 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
M8021
Borrow
M8022
Carry
-2,147,483,648
-1 , 0 , 1 Zero flag
2,147,483,647 ,
0, 1, 2
Borrow flag
Carry flag
3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
Program example
In this program, subtraction is performed using word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_bool3:=SUB_E(g_bool1,g_int1,g_int2,g_int3);
162
7.3
MUL_E / Multiplication
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
Outline
This function performs multiplication using two or more values (A B = C), and outputs the operation result.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST MUL_E(EN,_IN,_IN,Output label); Example: MUL_E(X000,D0,D10,D20);
3
Function Construction
X000
MUL_E
D0 D10
D20
*1.
Output variable
4
How to Read Explanation of Functions
Description Execution condition Data for multiplication or word device which stores such data Execution status Bit ANY_NUM Bit ANY_NUM Data type
2. Set data
Variable Input variable Output variable EN _IN ( s1 to s28 ) ENO *1 ( d )
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (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. 3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
163
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/FBD]
g_bool3:=MUL_E(g_bool1,g_dint1,g_dint2,g_dint3);
164
7.4
DIV_E / Division
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
Outline
This function performs division using two values (A / B = C remainder), and outputs the quotient.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST DIV_E(EN,_IN1,_IN2,Output label); Example: DIV_E(X000,D0,D10,D20);
3
Function Construction
X000
DIV_E
D0 D10
D20
*1.
Output variable
4
How to Read Explanation of Functions
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 Bit ANY_NUM ANY_NUM Bit ANY_NUM Data type
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d )
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
2
s2 (Word [signed] data)
(Quotient) 2
d (Word [signed] data)
7
Applied Functions (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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
Error
1) An operation error occurs when the divisor stored in a device specified in s2 is "0", and the function is not executed. 2) An operation error occurs when the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit operation).
10
Applied Functions (Standard Selection Functions)
165
In this program, division is performed using double word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
[Structured ladder/FBD]
g_bool3:=DIV_E(g_bool1,g_dint1,g_dint2,g_dint3);
166
7.5
1
Outline
Outline
This function performs division using two values (A / B = C remainder), and outputs the remainder.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST _IN1 MOD _IN2; *2 Example: Label 3:= Label 1 MOD Label 2; MOD_E(EN,_IN1,_IN2,Output label; *2 Example: MOD_E(X000,Label 1, Label 2,Label 3);
3
Function Construction
MOD
Label 3
MOD_E
4
How to Read Explanation of Functions
Label 1 Label 2
Label 3
*1. *2.
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit ANY_INT ANY_INT Bit ANY_INT Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
2
s2 (Word [signed] data)
(Remainder) 1
d (Word [signed] data)
8
Applied Functions (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. 3) Note that the "MOD" description method is different from other function description methods in the ST language.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
167
1) An operation error occurs when the divisor stored in a device specified in s2 is "0", and the function is not executed. 2) An operation error occurs when the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit operation).
Program example
In this program, division is performed using double word [signed] data stored in devices specified in s1 and s2 , and the remainder is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 . 1) Function without EN/ENO(MOD)
[Structured ladder/FBD]
_IN1 _IN2
g_dint3=742
168
7.6
EXPT(_E) / Exponentiation
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
1
Outline
Outline
This function obtains raised result, and outputs it.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST EXPT(In1,In2); Example: Label 2:= EXPT(Label 1,D10); EXPT_E(EN,In1,In2,Output label); Example: EXPT_E(X000,Label 1,D10, Label 2);
3
Function Construction
EXPT
EXPT
In1 In2
*1
Label 2
EXPT_E
Label 1 D10
4
How to Read Explanation of Functions
Label 2
*1.
Output variable
2. Set data
Variable EN Input variable Output variable In1 In2 ENO *1 ( d ) ( s1 ) ( s2 ) 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 Description Bit FLOAT (Single Precision) ANY_NUM Bit FLOAT (Single Precision) Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
16.0
d Float (single precision) data
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
169
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error code. 1) When the value stored in a device specified in s1 is negative (Error code: K6706) 2) When the value stored in a device specified in s1 is "0" (Error code: K6706) 3) When the operation result is outside the following range: (Error code: K6706) 2-126Operation result<2128
Program example
In this program, the value stored in a device specified in s1 is raised to the power of the value stored in a device specified in s2 , and the operation result is output to a device specified in d using the data type of data stored in a device specified in s1 . 1) Function without EN/ENO(EXPT)
[Structured ladder/FBD]
In1 In2
g_real2
g_real2:=EXPT(g_real1,g_int1);
EN In1 In2
EXPT_E ENO
g_bool3 g_real2
g_bool3:=EXPT_E(g_bool1,g_real1,g_int1,g_real2);
170
7.7
1
Outline
Outline
This function transfers data stored in a device to another device.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST MOVE(_IN); Example: D10:= MOVE(D0); MOVE_E(EN,_IN,Output label); Example: MOVE_E(X000,D0,D10);
3
Function Construction
MOVE
D0
MOVE _IN *1
D10
X000
MOVE_E
D0
4
How to Read Explanation of Functions
D10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _IN ( s ) ENO *1 ( d ) Execution condition Transfer source data, or word device which stores such data Execution status Transfer destination word device Description Bit ANY Bit ANY Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
to a device specified in
12
d
7
Applied Functions (Standard Arithmetic 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. 3) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
171
In this program, word [signed] data stored in a device specified in d . 1) Function without EN/ENO(MOVE)
[Structured ladder/FBD]
MOVE g_int1
[ST]
_IN
g_int2
g_int2:=MOVE(g_int1);
g_bool1 g_int1
[ST]
EN _IN
MOVE_E ENO
g_bool3 g_int2
g_bool3:=MOVE_E(g_bool1,g_int1,g_int2);
172
10
Outline
Function Construction
Section 8.1
Function
Function name
Left shift
8.
SHR(_E)
SHL(_E)
Right shift
Section 8.2
Reference
173
8.1
Outline
This function shifts data of specified bit length leftward by the specified number of bits.
1. Format
Function name Expression in each language Structured ladder/FBD ST SHL(_IN,_N); Example: D10:= SHL(D0,K1); SHL_E(EN,_IN,_N,Output label); Example: SHL_E(X000,D0,K1,D10);
SHL
SHL
D0 K1 X000
_IN _N
*1
D10
SHL_E
D0 K1
D10
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN ( s ) _N ( n ) ENO *1 ( d ) 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 Description Bit ANY_BIT ANY_BIT Bit ANY_BIT Data type
F00H
d (Word [unsigned]/ bit string [16-bit] data)
270FH
F00H
174
1
Outline
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
Function/ Operator List
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is shifted leftward by "n" bits, and the obtained data is output to a device specified in d using the data type of data stored in a device specified in s . 1) Function without EN/ENO(SHL)
[Structured ladder/FBD]
3
Function Construction
_IN _N
g_word2=16#0F00
4
How to Read Explanation of Functions
g_word2:=SHL(g_word1,g_const_word1);
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
g_bool3:=SHL_E(g_bool1,g_word1,g_const_word1,g_word2);
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
175
8.2
Outline
This function shifts data of specified bit length rightward by the specified number of bits.
1. Format
Function name Expression in each language Structured ladder/FBD ST SHR(_IN,_K); Example: D10:= SHR(D0,K1); SHR_E(EN,_IN,_N,Output label); Example: SHR_E(X000,D0,K1,D10);
SHR
SHR
D0 K1 X000
_IN _K
*1
D10
SHR_E
D0 K1
D10
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN ( s ) Execution condition Word device which stores data to be shifted rightward Number of shifted bits Execution status ( d ) Word device which will store data obtained by shift Description Bit ANY_BIT ANY_BIT Bit ANY_BIT Data type
_K,_N ( n ) ENO *1
27H
d (Word [unsigned]/ bit string [16-bit] data)
270FH
27H
176
1
Outline
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
Function/ Operator List
Program example
In this program, word [unsigned]/bit string [16-bit] data stored in a device specified in s is shifted rightward by "n" bits, and the obtained data is output to a device specified in d using the data type of data stored in a device specified in s . 1) Function without EN/ENO(SHR)
[Structured ladder/FBD]
3
Function Construction
_IN _K
g_word2=16#03BB
4
How to Read Explanation of Functions
g_word2:=SHR(g_word1,g_const_word1);
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
g_bool3:=SHR_E(g_bool1,g_word1,g_const_word1,g_word2);
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
177
9.
178
9.1
1
Outline
Outline
This function obtains the logical product of two or more bits, and outputs it.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST AND_E(EN,_IN,_IN,Output label); Example: AND_E(X000,M0,M10,M20);
3
Function Construction
X000
AND_E
M0 M10
M20
*1.
Output variable
4
How to Read Explanation of Functions
Description Execution condition Bit ANY_BIT Bit ANY_BIT Data type
2. Variable
Variable Input variable Output variable EN
_IN ( s1 to s28 ) Device used to obtain the logical product ENO *1 ( d ) Execution status Device which will store the operation result
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
Logical product
s2
0
s
8
Applied Functions (Standard Bit Shift Functions)
2)
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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
179
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/FBD]
g_bool3:=AND_E(g_bool1,g_word1,g_word2,g_word3);
180
9.2
1
Outline
Outline
This function obtains the logical sum of two or more bits, and outputs it.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST OR_E(EN,_IN,_IN,Output label); Example: OR_E(X000,M0,M10,M20);
3
Function Construction
X000
OR_E
M0 M10
M20
*1.
Output variable
4
How to Read Explanation of Functions
Description Execution condition Bit ANY_BIT Bit ANY_BIT Data type
2. Set data
Variable Input variable Output variable EN
_IN ( s1 to s28 ) Device used to obtain the logical sum ENO *1 ( d ) Execution status Device which will store the operation result
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
Logical sum
s2
7
Applied Functions (Standard Arithmetic Functions)
1
s
8
Applied Functions (Standard Bit Shift 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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
181
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/FBD]
g_bool3:=OR_E(g_bool1,g_word1,g_word2,g_word3);
182
9.3
1
Outline
Outline
This function obtains the exclusive logical sum of two or more bits, and outputs it.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST XOR_E(EN,_IN,_IN,Output label); Example: XOR_E(X000,M0,M10,M20);
3
Function Construction
X000
XOR_E
M0 M10
M20
*1.
Output variable
4
How to Read Explanation of Functions
Description Execution condition Bit ANY_BIT Bit ANY_BIT Data type
2. .Set data
Variable Input variable Output variable EN _IN ( s1 ENO *1 ( d )
to s28 ) Device used to obtain the exclusive logical sum Execution status Device which will store the operation result
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
0
s
8
Applied Functions (Standard Bit Shift Functions)
2)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
183
3) If there are 3 or more s , the exclusive logical sum is obtained using the "exclusive logical sum of s1 and s2 " and s3 . If there is s4 , the exclusive logical sum is obtained using the "exclusive logical sum of "exclusive logical sum of s1 and s2 " and " s3 "" and s4 . In this way, the exclusive logical sum is obtained the s6 required number of times for all input labels s5 Example: When the data type is bit
When the number of "_IN" is 3
s1
FALSE XOR
TRUE XOR
s3
s2
TRUE
TRUE
TRUE
TRUE
Result TRUE
Result FALSE
Result TRUE
After that, the exclusive logical sum is obtained the required number of Result FALSE times.
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.
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 d using the data type of data stored in devices specified in s1 and s2 .
[Structured ladder/FBD]
g_bool3:=XOR_E(g_bool1,g_word1,g_word2,g_word3);
184
9.4
1
Outline
Outline
This function obtains the logical negation of bits, and outputs it.
2
Function/ Operator List
1. Format
Function name Expression in each language Structured ladder/FBD ST NOT(_IN); Example: M10:= NOT(M0); NOT_E(EN,_IN,Output label); Example: NOT_E(X000,M0,M10);
3
Function Construction
NOT
X000
NOT_E
M0
4
How to Read Explanation of Functions
M10
*1.
Output variable
2. Set data
Variable Input variable Output variable EN _IN ( s ) ENO *1 ( d ) Execution condition Device used to obtain the logical negation Execution status Device which will store the operation result Description Bit ANY_BIT Bit ANY_BIT Data type
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
Logical negation
d
8
Applied Functions (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.
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
185
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/FBD]
NOT g_word1
[ST]
_IN
g_word2
g_word2:= NOT(g_word1);
g_bool1 g_word1
[ST]
g_bool3:=NOT_E(g_bool1,g_word1,g_word2);
186
1
Outline
2
Function/ Operator List
3
Function Construction
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
187
10.1
SEL(_E) / Selection
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function selects either one between two data in accordance with the input condition, and outputs the selection result.
1. Format
Function name Expression in each language Structured ladder/FBD ST SEL(_G,_IN0,_IN1); Example: D20:= SEL(M0,D0,D10);
SEL
M0 D0 D10 X000
D20
SEL_E
M0 D0 D10
D20
*1.
Output variable
2. Set data
Variable EN Input variable _G ( s1 ) 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 ( d ) Word device which will store the selection result Description Bit Bit ANY ANY Bit ANY Data type
_IN0 ( s2 ) _IN1 ( s3 )
Output variable
ENO *1
188
1
Outline
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
2
Function/ Operator List
Program example
In this program, either one between the values stored in devices specified in s2 and s3 is output in accordance with the value stored in a device specified in s1 to a device specified in d using the data type of data stored in devices specified in s2 and s3 . 1) Function without EN/ENO(SEL)
[Structured ladder/FBD]
3
Function Construction
4
How to Read Explanation of Functions
_G _IN0 _IN1
g_word3
5
Applied Functions (Type Conversion Functions)
g_word3:=SEL(g_bool1,g_word1,g_word2);
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
g_bool3:=SEL_E(g_bool1,g_bool2,g_word1,g_word2,g_word3);
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
189
10.2
Outline
This function searches the maximum value among data, and outputs the maximum value.
1. Format
Function name Expression in each language Structured ladder/FBD ST MAXIMUM(_IN,_IN); Example: D20:= MAXIMUM(D0,D10);
MAXIMUM
D0 D10
D20
X000
MAXIMUM_E
D0 D10
D20
*1.
Output variable
2. Set data
Variable Input variable Output variable EN Execution condition Description Bit ANY_SIMPLE Bit ANY_SIMPLE Data type
_IN ( s1 to s28 ) Compared data, or word device which stores such data ENO *1 ( d ) Execution status Word device which will store the maximum value
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
190
1
Outline
In this program, the maximum value among word [signed] data stored in devices specified in s1 and s2 is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 . 1) Function without EN/ENO(MAXIMUM)
[Structured ladder/FBD]
2
Function/ Operator List
_IN _IN
g_int3=5678
g_int3:=MAXIMUM(g_int1,g_int2);
3
Function Construction
g_bool3 g_int3
4
How to Read Explanation of Functions
g_bool3:=MAXIMUM_E(g_bool1,g_int1,g_int2,g_int3);
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
191
10.3
Outline
This function searches the minimum value among data, and outputs the minimum value.
1. Format
Function name Expression in each language Structured ladder/FBD ST MINIMUM(_IN,_IN); Example: D20:= MINIMUM(D0,D10);
MINIMUM
D0 D10
D20
X000
MINIMUM_E
D0 D10
D20
*1.
Output variable
2. Set data
Variable Input variable Output variable EN Execution condition Description Bit ANY_SIMPLE Bit ANY_SIMPLE Data type
_IN ( s1 to s28 ) Compared data, or word device which stores such data ENO *1 ( d ) Execution status Word device which will store the minimum value
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
192
1
Outline
In this program, the minimum value among word [signed] data stored in devices specified in s1 and s2 is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 . 1) Function without EN/ENO(MINIMUM)
[Structured ladder/FBD]
2
Function/ Operator List
_IN _IN
g_int3=1234
g_int3:=MINIMUM(g_int1,g_int2);
3
Function Construction
g_bool3 g_int3
4
How to Read Explanation of Functions
g_bool3:=MINIMUM_E(g_bool1,g_int1,g_int2,g_int3);
5
Applied Functions (Type Conversion Functions)
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
193
10.4
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 Expression in each language Structured ladder/FBD ST LIMITATION(_MN,_IN,_MX); Example: D30:= LIMITATION(D0,D10,D20); LIMITATION_E(EN,_MN,_IN,_MX, Output label); Example: LIMITATION_E(X000,D0,D10,D20, D30);
LIMITATION
D30
LIMITATION_E
D0 D10 D20
D30
*1.
Output variable
2. Set data
Variable EN Input variable _MN ( s1 ) _IN ( s2 ) _MX ( s3 ) Output variable ENO *1 ( d ) 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 Description Bit ANY_SIMPLE ANY_SIMPLE ANY_SIMPLE Bit ANY_SIMPLE Data type
s1
3) In the case of "Contents of a device specified in s1 Contents of a device specified in s2 Contents of a device specified in s3 ", this function outputs the contents of a device specified in s2 to a device specified in d . Example: When the data type is word [signed]
Output value -100 Word [signed] data 120 Word [signed] data 100 Word [signed] data LIMITATION _MN _IN _MX Minimum input value 100 Word [signed] data
194
1
Outline
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
2
Function/ Operator List
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 s1 > Contents of a device specified in s3 (Lower limit data) (Upper limit data)
3
Function Construction
Program example
In this program, data whose type is same as the data stored in devices specified in s1 , s2 and s3 is output to a device specified in d in accordance with ANY_SIMPLE type data stored in devices specified in s1 , s2 and s3 . 1) Function without EN/ENO(LIMITATION)
[Structured ladder/FBD]
4
How to Read Explanation of Functions
5
Applied Functions (Type Conversion Functions)
g_int4=1300
6
Applied Functions (Standard Functions Of One Numeric Variable)
g_int4:=LIMITATION(g_int1,g_int2,g_int3);
7
Applied Functions (Standard Arithmetic Functions)
g_bool3 g_int4
8
Applied Functions (Standard Bit Shift Functions)
g_bool3:=LIMITATION_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
195
10.5
MUX(_E) / Multiplexer
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function selects data, and outputs the selected data.
1. Format
Function name Expression in each language Structured ladder/FBD ST MUX(_K,_IN,_IN); Example: D30:= MUX(D0,D10,D20);
MUX
MUX
_K _IN _IN
*1
D30
MUX_E
D0 D10 D20
D30
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _K ( n ) Execution condition Selection data, or word device which stores such data Description Bit Word [signed] ANY Bit ANY Data type
_IN ( s1 to s28 ) Selectable data, or word device which stores such data ENO *1 Execution status Word device which will store the selected data
2) When a value input to n is outside the pin number range for s1 to s28 , 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 for
s
196
1
Outline
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
2
Function/ Operator List
Program example
In this example, either one among values stored in devices specified in s1 and s2 is output to a device specified in d in accordance with the value specified in n using the data type of data stored in devices specified in s1 and s2 . 1) Function without EN/ENO(MUL)
[Structured ladder/FBD]
3
Function Construction
4
How to Read Explanation of Functions
_K _IN _IN
g_int4=5678
5
Applied Functions (Type Conversion Functions)
g_int4:=MUX(g_int1,g_int2,g_int3);
6
Applied Functions (Standard Functions Of One Numeric Variable)
7
Applied Functions (Standard Arithmetic Functions)
g_bool3:=MUX_E(g_bool1,g_int1,g_int2,g_int3,g_int4);
8
Applied Functions (Standard Bit Shift Functions)
9
Applied Functions (Standard Bitwise Boolean Functions)
10
Applied Functions (Standard Selection Functions)
197
198
11.1
GT_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to "> (larger)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST GT_E(EN,_IN,_IN,Output label); Example: GT_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
GT_E
D0 D10
EN _IN _IN
GT_E ENO *1
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Bit ANY_SIMPLE Bit Bit Data type
2. Set data
Variable Input variable Output variable EN
_IN ( s1 to s28 ) Compared data, or word device which stores such data ENO *1 ( d ) Execution status Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
199
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=GT_E(g_bool1,g_int1,g_int2,g_bool2);
200
11.2
GE_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to " (larger or equal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST GE_E(EN,_IN,_IN,Output label); Example: GE_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
GE_E
D0 D10
EN _IN _IN
GE_E ENO *1
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Execution status Bit ANY_SIMPLE Bit Bit Data type
2. Set data
Variable Input variable Output variable EN ENO *1 ( d )
_IN ( s1 to s28 ) Compared data, or word device which stores such data Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
201
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=GE_E(g_bool1,g_int1,g_int2,g_bool2);
202
11.3
EQ_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to "= (equal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST EQ_E(EN,_IN,_IN,Output label); Example: EQ_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
EQ_E
D0 D10
EN _IN _IN
EQ_E ENO *1
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Execution status Bit ANY_SIMPLE Bit Bit Data type
2. Set data
Variable Input variable Output variable EN ENO *1 ( d )
_IN ( s1 to s28 ) Compared data, or word device which stores such data Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
203
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=EQ_E(g_bool1,g_int1,g_int2,g_bool2);
204
11.4
LE_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to " (smaller or equal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST LE_E(EN,_IN,_IN,Output label); Example: LE_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
LE_E
D0 D10
EN _IN _IN
LE_E ENO *1
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Execution status Bit ANY_SIMPLE Bit Bit Data type
2. Set data
Variable Input variable Output variable EN ENO *1 ( d )
_IN ( s1 to s28 ) Compared data, or word device which stores such data Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
205
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=LE_E(g_bool1,g_int1,g_int2,g_bool2);
206
11.5
LT_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to "< (smaller)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST LT_E(EN,_IN,_IN,Output label); Example: LT_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
LT_E
D0 D10
EN _IN _IN
LT_E ENO *1
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Execution status Bit ANY_SIMPLE Bit Bit Data type
2. Set data
Variable Input variable Output variable EN ENO *1 ( d )
_IN ( s1 to s28 ) Compared data, or word device which stores such data Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
207
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=LT_E(g_bool1,g_int1,g_int2,g_bool2);
208
11.6
NE_E / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function compares data with regard to " (unequal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST NE_E(EN,_IN1,_IN2,Output label); Example: NE_E(X000,D0,D10,M0);
13
Applied Functions (Functions Of Time Data Types)
X000
NE_E
D0 D10
M0
*1.
Output variable
14
Standard Function Blocks
Description Execution condition Compared data, or word device which stores such data Compared data, or word device which stores such data Execution status Bit ANY_SIMPLE ANY_SIMPLE Bit Bit Data type
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d )
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
209
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
[ST]
g_bool3:=NE_E(g_bool1,g_int1,g_int2,g_bool2);
210
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
211
12.1
Outline
This function obtains a character string from a specified position.
1. Format
Function name Expression in each language Structured ladder/FBD ST MID(_IN,_L ,_P); Example: Label 2:= MID(Label 1,D10,D20);
MID
MID
_IN _L _P
*1
Label 2
MID_E
Label 2
*1.
Output variable
2. Set data
Variable EN Input variable _IN ( s ) _L _P Output variable ENO *1 ( d ) ( n1 ) ( n2 ) Execution condition Head word device which stores a character string Word device which stores the number of characters to be obtained Description Bit String Word [signed] Data type
Word device which stores the head character position of a character Word [signed] string to be obtained Execution status Head word device which will store the obtained character string Bit String
212
FXCPU Structured Programming Manual [Application Functions] Explanation of function and operation
11
Applied Functions (Standard Comparison Functions)
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" High-order byte Low-order byte 1st word 2nd word 3rd word 4th word 5th word 6th word 42H(B) 44H(D) 46H(F) 32H(2) 34H(4) 00H 41H(A) 43H(C) 45H(E) 31H(1) 33H(3) 35H(5) Number of characters to be extracted n1 = 5 Head character position of a character string to be extracted n2 = 5th character "EF123" High-order byte Low-order byte 46H(F) 32H(2) 00H 45H(E) 31H(1) 33H(3) 1st word 2nd word 3rd word
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first in units of byte in the range starting from the specified device. 3) When the number of characters to be extracted specified in n1 is "0", this function does not execute processing. 4) When the number of characters to be extracted specified in n1 is "-1", this function outputs the final character of a character string specified in s to devices specified in d .
15
Operator
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.
A
Correspondence between Devices and Addresses
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
B
Function/ Operator List
2) When the head character position specified in n2 exceeds the number of characters of a character string stored in devices specified in s (Error code: K6706) 3) When the number of characters specified in n1 exceeds the range of devices specified in (Error code: K6706)
d
4) When the number of devices after the device number specified in d is smaller than the number of devices required for storing an extracted character string (In this case, "00H" cannot be stored after all character strings and the final character.) (Error code: K6706) 5) When the value specified in n2 is negative (Error code: K6706) 6) When the value specified in n1 is "-2" or less (Error code: K6706) 7) When the value specified in n1 devices specified in s (Error code: K6706) exceeds the number of characters of a character string stored in
213
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/FBD]
_IN _L _P
g_string2="EF123"
g_string2:=MID(g_string1,g_int1,g_int2);
g_bool3:=MID_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
214
12.2
11
Applied Functions (Standard Comparison Functions)
Outline
This function connects character strings.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST CONCAT(_IN,_IN); Example: Label 3:= CONCAT(Label 1,Label 2);
13
Applied Functions (Functions Of Time Data Types)
CONCAT
CONCAT
Label 1 Label 2
_IN _IN
*1
Label 3
X000
CONCAT_E
Label 1 Label 2
Label 3
14
Standard Function Blocks
*1.
Output variable
15
Operator
Description Execution condition Bit Head word device which stores the data (character string) to be String connected, or directly specified character string Execution status Bit Head word device which will store the connected data (character String string) Data type
2. Set data
Variable Input variable Output variable EN _IN ( s1 to s28 ) ENO *1 ( d )
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) For direct specification, up to 32 characters can be specified (input). When word devices are specified in s , this restriction (up to 32 characters) is not applicable.
215
4) When both a character string stored in devices specified in this function stores "0000H" in devices specified in d . 5) The number of pins for
s
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 d is smaller than the number of devices required for storing the character string obtained by connection (In this case, "00H" cannot be stored after all character strings and final character.) (Error code: K6706) 2) When devices which store character strings specified in s which will store the character string obtained by connection (Error code: K6706) overlap device numbers specified in
d
3) When "00H" does not exist in the corresponding device range after devices specified in (Error code: K6706)
Program example
In this program, a character string stored in devices specified in s2 is connected after a character string stored in devices specified in s1 , and the character string obtained by connection is output to devices specified in d . 1) Function without EN/ENO(CONCAT)
[Structured ladder/FBD]
_IN _IN
g_string3="ABCDEF12345"
g_string3:=CONCAT(g_string1,g_string2);
g_bool3 g_string3
g_bool3:=CONCAT_E(g_bool1,g_string1,g_string2,g_string3);
216
12.3
11
Applied Functions (Standard Comparison Functions)
Outline
This function inserts a character string.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST INSERT(_IN1,_IN2,_P); Example: Label 3:= INSERT(Label 1,Label 2,D20);
13
Applied Functions (Functions Of Time Data Types)
INSERT
INSERT
_IN1 _IN2 _P
*1
Label 3
INSERT_E
Label 3
14
Standard Function Blocks
*1.
Output variable
15
Operator
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 Word device which stores a character position to get insertion Execution status Bit String String Word [signed] Bit Data type
2. Set data
Variable EN Input variable _IN1 ( s1 ) _IN2 ( s2 ) _P Output variable ENO *1 ( d ) ( n )
A
Correspondence between Devices and Addresses
Head word device which will store a character string obtained by String insertion
B
Function/ Operator List
217
FXCPU Structured Programming Manual [Application Functions] Explanation of function and operation
1) This function inserts a character string stored in devices specified in s2 into an arbitrary position (counted from the head) of a character string stored in devices specified in s1 , and outputs the character string obtained by insertion to devices specified in d . The value specified in n specifies the position from which the character string stored in devices specified in s2 is inserted. After inserting a character string stored in devices specified in s2 into a character string stored in devices specified in s1 , this function ignores "00H" which indicates the end of a character string stored in devices specified in s2 . Example: When "4" is specified in n
Input value to s1 "ABCDE" High-order byte Low-order byte 1st word 2nd word 3rd word 42H(B) 44H(D) 00H 41H(A) 43H(C) 45H(E) Insertion start position n = 4th character Output value "ABC123456DE" High-order byte Low-order byte 42H(B) 31H(1) 33H(3) 35H(5) Input value to s2 "123456" High-order byte Low-order byte 1st word 2nd word 3rd word 4th word 32H(2) 34H(4) 36H(6) 0000H 31H(1) 33H(3) 35H(5) 44H(D) 00H 41H(A) 43H(C) 32H(2) 34H(4) 36H(6) 45H(E) 1st word 2nd word 3rd word 4th word 5th word 6th 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.
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling character string data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling character string data. Use global labels when specifying labels.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error code. 1) When the number of devices after the device number specified in devices required for storing the output data obtained by insertion (Error code: K6706)
d
2) When devices which store character strings specified in s1 and s2 overlap device numbers specified in d which will store the character string obtained by connection (Error code: K6706) 3) When "00H" does not exist in the corresponding device range after devices specified in s1 and s2 (Error code: K6706) 4) When the number of characters of a character string stored in devices specified in s2 is 32768 or more (Error code: K6706) 5) When the value specified in (Error code: K6706)
n
is negative
218
11
Applied Functions (Standard Comparison Functions)
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/FBD]
12
Applied Functions (Standard Character String Functions)
_IN1 _IN2 _P
g_string3="AB12345CDEF"
13
Applied Functions (Functions Of Time Data Types)
g_string3:=INSERT(g_string1,g_string2,g_int1);
14
Standard Function Blocks
g_bool3 g_string3
15
Operator
g_bool3:=INSERT_E(g_bool1,g_string1,g_string2,g_int1,g_string3);
A
Correspondence between Devices and Addresses
B
Function/ Operator List
219
12.4
Outline
This function deletes a character string.
1. Format
Function name Expression in each language Structured ladder/FBD ST DELETE(_IN,_L ,_P); Example: Label 2:= DELETE(Label 1,D10,D20); DELETE_E(EN,_IN,_L ,_P, Output label); Example: DELETE_E(X000, Label 1, D10, D20, Label 2);
DELETE
DELETE
_IN _L _P
*1
Label 2
DELETE_E
Label 2
*1.
Output variable
2. Set data
Variable EN Input variable _IN ( s ) _L _P Output variable ENO *1 ( d ) ( n1 ) ( n2 ) Execution condition Head word device which stores a character string to get deletion Number of characters to be deleted Head position to get deletion Execution status Description Bit String Word [signed] Word [signed] Bit Data type
Head word device which will store a character string remaining after String deletion
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.
220
11
Applied Functions (Standard Comparison Functions)
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.
12
Applied Functions (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 device specified in (Error code: K6706) 2) When the number of characters of a character string stored in devices specified in (Error code: K6706)
s s
13
Applied Functions (Functions Of Time Data Types)
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 n2 is negative (Error code: K6706)
14
Standard Function Blocks
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/FBD]
15
Operator
A
Correspondence between Devices and Addresses
_IN _L _P
g_string2="AB12345"
g_string2:=DELETE(g_string1,g_int1,g_int2);
B
Function/ Operator List
g_bool3 g_string2
g_bool3:=DELETE_E(g_bool1,g_string1,g_int1,g_int2,g_string2);
221
12.5
Outline
This function replaces a character string.
1. Format
Function name Expression in each language Structured ladder/FBD ST REPLACE(_IN1,_IN2,_L ,_P); Example: Label 3:= REPLACE(Label 1,Label 2, D20,D30);
REPLACE
Label 3
REPLACE_E
Label 3
*1.
Output variable
2. Set data
Variable EN _IN1 ( s1 ) Input variable _IN2 ( s2 ) _L _P Output variable ENO *1 ( d ) ( n1 ) ( n2 ) Execution condition Head word device which stores a character string to be replaced Head word device which stores a replacement character string Word device which stores the number of characters to be replaced Description Bit String String Word [signed] Data type
Word device which stores the head character position to be Word [signed] replaced in a character string to be replaced Execution status Bit Head word device which will store a character string obtained by String replacement
222
FXCPU Structured Programming Manual [Application Functions] Explanation of function and operation
11
Applied Functions (Standard Comparison Functions)
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
Input value to s1 "ABCDEFGH123" High-order byte Low-order byte 1st word 2nd word 3rd word 4th word 5th word 6th word 42H(B) 44H(D) 46H(F) 48H(H) 32H(2) 00H 41H(A) 43H(C) 45H(E) 47H(G) 31H(1) 33H(3) Number of characters to be replaced n1 = 5 Replacement start position n2 = 5th character Output value "ABCD1234523" High-order byte Low-order byte 42H(B) 44H(D) 32H(2) 34H(4) 32H(2) 00H 41H(A) 43H(C) 31H(1) 33H(3) 35H(5) 33H(3) 1st word 2nd word 3rd word 4th word 5th word 6th word
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
Input value to s2 "123456" High-order byte Low-order byte 1st word 2nd word 3rd word 4th word 32H(2) 34H(4) 36H(6) 0000H 31H(1) 33H(3) 35H(5)
15
Operator
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 s1 , excessive characters are not output to devices specified in d . 4) When "-1" is specified in n1 , the number of characters of a character string stored in devices specified in s2 is regarded as the value specified in n1 .
A
Correspondence between Devices and Addresses
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.
B
Function/ Operator List
223
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
and
(Error code: K6706) 2) When the value specified in n1 devices specified in s2 (Error code: K6706) exceeds the number of characters of a character string stored in
3) When the value specified in n2 is negative (Error code: K6706) 4) When the value specified in n1 is "-2" or less (Error code: K6706) 5) When the value specified in n2 devices specified in s1 (Error code: K6706) exceeds the number of characters of a character string stored in
Program example
In this program, specified number of characters starting from an arbitrary position of a character string stored in devices specified in s1 are replaced with a character string stored in devices specified in s2 , and the character string obtained by replacement is output to devices specified in d . 1) Function without EN/ENO(REPLACE)
[Structured ladder/FBD]
_IN1 _IN2 _L _P
g_string3="AB012345"
g_string3:=REPLACE(g_string1,g_string2,g_int1,g_int2);
g_bool3 g_string3
g_bool3:=REPLACE_E(g_bool1,g_string1,g_string2,g_int1,g_int2,g_string3);
224
12.6
11
Applied Functions (Standard Comparison Functions)
Outline
This function searches a character string.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST FIND(_IN1,_IN2); Example: D20:= FIND(Label 1,Label 2); FIND_E(EN,_IN1,_IN2,Output label); Example: FIND_E(X000,Label 1,Label 2, D20);
13
Applied Functions (Functions Of Time Data Types)
FIND
Label 1 Label 2
D20
X000
FIND_E
Label 1 Label 2
14
Standard Function Blocks
D20
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit String String Bit Word [signed] Data type
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
225
FXCPU Structured Programming Manual [Application Functions] Explanation of function and operation
1) This function searches a character string stored in devices specified in s2 from the beginning of a character string stored in devices specified in s1 , and outputs the search result to devices specified in d . This function outputs the head character position of the searched character string detected first as the search result. 2) A character string (data) stored in devices specified in s indicates the data until "00H" is detected first in units of byte in the range starting from the specified device. 3) If a character string stored in devices specified in s2 cannot be detected in a character string stored in devices specified in s1 , this function outputs "0".
Input value to s1 "ABCD1234567" High-order byte Low-order byte 1st word 2nd word 3rd word 4th word 5th word 6th word 42H(B) 44H(D) 32H(2) 34H(4) 36H(6) 00H 41H(A) 43H(C) 31H(1) 33H(3) 35H(5) 37H(7) Search of character string Output value 5 Word [signed]
Input value to s2 "1234" High-order byte Low-order byte 1st word 2nd word 3rd word 32H(2) 34H(4) 0000H 31H(1) 33H(3)
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling character string data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling character string data. Use global labels when specifying labels.
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error code. 1) When "00H (NULL)" does not exist in the corresponding device range specified in s1 (Error code: K6706) 2) When "00H (NULL)" does not exist in the corresponding device range specified in s2 (Error code: K6706)
226
11
Applied Functions (Standard Comparison Functions)
In this program, a character string stored in devices specified in s2 is searched from the beginning of a character string stored in devices specified in s1 , and the search result is output to devices specified in d . 1) Function without EN/ENO(FIND)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
_IN1 _IN2
g_int1=5
13
Applied Functions (Functions Of Time Data Types)
g_int1:=FIND(g_string1,g_string2);
14
FIND_E EN _IN1 _IN2 ENO g_bool3 g_int1
Standard Function Blocks
g_bool3:=FIND_E(g_bool1,g_string1,g_string2,g_int1);
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
227
228
13.1
ADD_TIME(_E) / Addition
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function adds time data.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST ADD_TIME(_IN1,_IN2); Example: Label 3:= ADD_TIME(Label 1,Label 2); ADD_TIME_E(EN,_IN1,_IN2, Output label); Example: ADD_TIME_E(X000,Label 1, Label 2,Label 3);
13
Applied Functions (Functions Of Time Data Types)
ADD_TIME
Label 1 Label 2
Label 3
X000
ADD_TIME_E
Label 1 Label 2
14
Standard Function Blocks
Label 3
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit Time Time Bit Time Data type
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
229
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 Name Zero 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
M8021
Borrow
M8022
Carry
-2,147,483,648
-1 , 0 , 1 Zero flag
2,147,483,647 ,
0, 1, 2
Borrow flag
Carry flag
Program example
In this program, addition ( s1 + s2 ) is performed using time data stored in devices specified in s1 and s2 , and the operation result expressed as time data is output to devices specified in d . 1) Function without EN/ENO(ADD_TIME)
[Structured ladder/FBD]
g_time1 g_time2
[ST]
g_time3
g_time3:=ADD_TIME(g_time1,g_time2);
g_bool3 g_time3
g_bool3:=ADD_TIME_E(g_bool1,g_time1,g_time2,g_time3);
230
13.2
SUB_TIME(_E) / Subtraction
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function performs subtraction of time data.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST SUB_TIME(_IN1,_IN2); Example: Label 3:= SUB_TIME(Label 1,Label 2); SUB_TIME_E(EN,_IN1,_IN2, Output label); Example: SUB_TIME_E(X000,Label 1, Label 2,Label 3);
13
Applied Functions (Functions Of Time Data Types)
SUB_TIME
Label 1 Label 2
Label 3
X000
SUB_TIME_E
Label 1 Label 2
14
Standard Function Blocks
Label 3
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit Time Time Bit Time Data type
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
231
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 Name Zero 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
M8021
Borrow
M8022
Carry
Zero flag -2 , -1 , 0 , -32,768 Borrow flag Zero flag -2 , -1 , 0 , -2,147,483,648 The most significant bit of data is "1".
-1 , 0 , 1 Zero flag
2,147,483,647 ,
0, 1, 2
Borrow flag
Carry flag
Program example
In this program, subtraction ( s1 - s2 ) is performed using time data stored in devices specified in s1 and s2 , and the operation result expressed as time data is output to devices specified in d . 1) Function without EN/ENO(SUB_TIME)
[Structured ladder/FBD]
g_time1 g_time2
[ST]
g_time3
g_time3:=SUB_TIME(g_time1,g_time2);
g_bool3 g_time3
g_bool3:=SUB_TIME_E(g_bool1,g_time1,g_time2,g_time3);
232
13.3
MUL_TIME(_E) / Multiplication
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function performs multiplication of time data.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST MUL_TIME(_IN1,_IN2); Example: Label 3:= MUL_TIME(Label 1,Label 2); MUL_TIME_E(EN,_IN1,_IN2, Output label); Example: MUL_TIME_E(X000,Label 1, Label 2,Label 3);
13
Applied Functions (Functions Of Time Data Types)
MUL_TIME
Label 1 Label 2
Label 3
X000
MUL_TIME_E
Label 1 Label 2
14
Standard Function Blocks
Label 3
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit Time ANY_NUM Bit Time Data type
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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.) 4) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
233
In this program, multiplication ( s1 s2 ) is performed using time data stored in devices specified in s1 and s2 , and the operation result expressed as time data is output to devices specified in d . 1) Function without EN/ENO(MUL_TIME)
[Structured ladder/FBD]
g_time1 g_int1
[ST]
g_time2
g_time2:=MUL_TIME(g_time1,g_int1);
g_bool3 g_time2
g_bool3:=MUL_TIME_E(g_bool1,g_time1,g_int1,g_time2);
234
13.4
DIV_TIME(_E) / Division
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This function performs division using time data.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST DIV_TIME(_IN1,_IN2); Example: Label 3:= DIV_TIME(Label 1,Label 2); DIV_TIME_E(EN,_IN1,_IN2, Output label); Example: DIV_TIME_E(X000,Label 1, Label 2,Label 3);
13
Applied Functions (Functions Of Time Data Types)
DIV_TIME
Label 1 Label 2
Label 3
X000
DIV_TIME_E
Label 1 Label 2
14
Standard Function Blocks
Label 3
*1.
Output variable
2. Set data
Variable EN Input variable Output variable _IN1 ( s1 ) _IN2 ( s2 ) ENO *1 ( d ) 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 Description Bit Time ANY_NUM Bit Time Data type
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
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) When the FLOAT (Single Precision) data to s is set from the programming tool, a rounding error may be generated. Refer to the MELSEC-Q/L/F Structured Programming Manual (Fundamentals) for cautions on setting the input value from the programming tool.
Error
1) An operation error occurs when the divisor stored in devices specified in s2 is "0", and the function is not executed. 2) An operation error occurs when the operation result exceeds "2,147,483,647".
235
In this program, division ( s1 / s2 ) is performed using time data stored in devices specified in s1 and s2 , and the operation result expressed as time data is output to devices specified in d . 1) Function without EN/ENO(DIV_TIME)
[Structured ladder/FBD]
g_time1 g_int1
[ST]
g_time2
g_time2:=DIV_TIME(g_time1,g_int1);
g_bool3 g_time2
g_bool3:=DIV_TIME_E(g_bool1,g_time1,g_int1,g_time2);
236
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
237
14.1
Outline
This function block detects the rising edge of a signal, and outputs pulse signal.
1. Format
Function name Expression in each language Structured ladder/FBD ST R_TRIG(_CLK,Q); Example: Instance name(_CLK:=M0, Q:=M10); R_TRIG_E(EN,_CLK,Q,ENO); Example: Instance name(EN:=X000, _CLK:=M0,Q:=M10);
Instance name
R_TRIG
M0
R_TRIG Q _CLK
M10
Instance name
R_TRIG_E
X000 M0
M10
2. Set data
Variable Input variable Output variable EN _CLK ENO Q ( d ) ( s ) Execution condition Input signal whose rising edge is to be detected Execution status Output signal Description Bit Bit Bit Bit Data type
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
Error
1) When an output number is specified in d and the specified output number does not exist due to indexing, M8316 (I/O inexistence error) turns ON. (Applicable to the FX3U and FX3UC PLCs only) 2) When a device (M, T or C) other than I/O number is specified in d and the specified device number does not exist due to indexing, an operation error (Error code: 6706) occurs.
238
11
Applied Functions (Standard Comparison Functions)
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)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
R_TRIG_Instance g_bool1
[ST]
R_TRIG _CLK
g_bool2
R_TRIG_Instance(_CLK:=g_bool1,Q:=g_bool2);
13
Applied Functions (Functions Of Time Data Types)
X000 g_bool1
[ST]
Y010 g_bool2
14
Standard Function Blocks
R_TRIG_E_Instance(EN:=X000,_CLK:=g_bool1,Q:=g_bool2,ENO:=Y010);
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
239
14.2
Outline
This function block detects the falling edge of a signal, and outputs pulse signal.
1. Format
Function name Expression in each language Structured ladder/FBD ST F_TRIG(_CLK,Q); Example: Instance name(_CLK:=M0, Q:=M10); F_TRIG_E(EN,_CLK,Q,ENO); Example: Instance name(EN:=X000, _CLK:=M0,Q:=M10);
Instance name
F_TRIG
M0
F_TRIG _CLK Q
M10
Instance name
F_TRIG_E
X000 M0
M10
2. Set data
Variable Input variable Output variable EN _CLK ENO Q ( d ) ( s ) Execution condition Input signal whose falling edge is to be detected Execution status Output signal Description Bit Bit Bit Bit Data type
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
Error
1) When an output number is specified in d and the specified output number does not exist due to indexing, M8316 (I/O inexistence error) turns ON. (Applicable to the FX3U and FX3UC PLCs only) 2) When a device (M, T or C) other than I/O number is specified in d and the specified device number does not exist due to indexing, an operation error (Error code: 6706) occurs.
240
11
Applied Functions (Standard Comparison Functions)
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)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
F_TRIG_Instance g_bool1
[ST]
F_TRIG _CLK
g_bool2
F_TRIG_Instance(_CLK:=g_bool1,Q:=g_bool2);
13
Applied Functions (Functions Of Time Data Types)
X000 g_bool1
[ST]
Y010 g_bool2
14
Standard Function Blocks
F_TRIG_E_Instance(EN:=X000,_CLK:=g_bool1,Q:=g_bool2,ENO:=Y010);
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
241
14.3
CTU(_E) / Up counter
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This function block counts up the number of times of rising of a signal.
1. Format
Function name Expression in each language Structured ladder/FBD ST CTU(CU,RESET,PV,Q,CV); Example: Instance name(CU:=M0, RESET:=M10,PV:=D0,Q:=M20, CV:=D10);
Instance name
CTU
CTU
M0 M10 D0
CU RESET PV
Q CV
M20 D10
Instance name
X000
CTU_E
M0 M10 D0
M20 D10
2. Set data
Variable EN Input variable CU ( s1 ) Execution condition Count source signal Reset input signal Counter set value Execution status ( d1 ) ( d2 ) Count-up output signal Number of times of rising Description Bit Bit Bit Word [signed] Bit Bit Word [signed] Data type
RESET ( s2 ) PV ENO ( n )
Output variable
Q CV
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
242
11
Applied Functions (Standard Comparison Functions)
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is counted, and the count value is output to a device specified in d2 . 1) Function without EN/ENO(CTU)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
CU RESET PV
Q CV
g_bool3 g_int2
13
Applied Functions (Functions Of Time Data Types)
CTU_Instance(CU:=g_bool1,RESET:=g_bool2,PV:=g_int1,Q:=g_bool3,CV:=g_int2);
14
Standard Function Blocks
15
Operator
CTU_E_Instance(EN:=M10,CU:=g_bool1,RESET:=g_bool2,PV:=g_int1,Q:=g_bool3,CV:=g_int2,ENO:=M11);
A
Correspondence between Devices and Addresses
B
Function/ Operator List
243
14.4
Outline
This function block counts down the number of times of rising of a signal.
1. Format
Function name Expression in each language Structured ladder/FBD ST CTD(CD,LOAD,PV,Q,CV); Example: Instance name(CD:=M0, LOAD:=M10,PV:=D0,Q:=M20, CV:=D10);
Instance name
CTD
CTD
M0 M10 D0
CD LOAD PV
Q CV
M20 D10
Instance name
X000
CTD_E
M0 M10 D0
M20 D10
2. Set data
Variable EN Input variable CD LOAD PV ENO Output variable Q CV ( d1 ) ( d2 ) ( s1 ) ( s2 ) ( n ) Execution condition Count source signal Reset input signal Counter set value Execution status Description Bit Bit Bit Word [signed] Bit Data type
Output signal (which turns ON when the current counter value Bit becomes "0" or less) Number of times of rising Word [signed]
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
244
11
Applied Functions (Standard Comparison Functions)
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is counted, and a device specified in d1 turns ON when the value stored in a device specified in d2 becomes "0". 1) Function without EN/ENO(CTD)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
CD LOAD PV
Q CV
g_bool3 g_int2
13
Applied Functions (Functions Of Time Data Types)
CTD_Instance(CD:=g_bool1,LOAD:=g_bool2,PV:=g_int1,Q:=g_bool3,CV:=g_int2);
14
Standard Function Blocks
15
Operator
CTD_E_Instance(EN:=M10,CD:=g_bool1,LOAD:=g_bool2,PV:=g_int1,Q:=g_bool3,CV:=g_int2,ENO:=M11);
A
Correspondence between Devices and Addresses
B
Function/ Operator List
245
14.5
Outline
This function block counts up/down the number of times of rising of a signal.
1. Format
Function name Expression in each language Structured ladder/FBD ST CTUD(CU,CD,RESET,LOAD,PV, QU,QD,CV); Example: Instance name(CU:=M0, CD:=M10,RESET:=M20, LOAD:=M30,PV:=D0,QU:=M40, QD:=M50,CV:=D10);
Instance name
CTUD
CTUD
CU QU CD QD RESET CV LOAD PV
Instance name
X000
CTUD_E
2. Set data
Variable EN CU Input variable CD ( s1 ) ( s2 ) Execution condition Count up signal Count down signal Reset input signal Resetting signal Counter set value Execution status ( d1 ) ( d2 ) ( d3 ) Count-up output signal Description Bit Bit Bit Bit Bit Word [signed] Bit Bit Data type
Output variable
Output signal (which turns ON when the current counter value Bit becomes "0" or less) Count value data Word [signed]
246
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
Program example
In this program, the number of times the bit data stored in a device specified in s1 turns ON from OFF is counted up (added by "1"). When the value stored in a device specified in d3 reaches the value specified in n , a device specified in d1 turns ON. At the same time, the number of times the bit data stored in a device specified in s2 turns ON from OFF is counted down (subtracted by "1"). When the value stored in a device specified in d3 becomes "0", a device specified in d2 turns ON. 1) Function without EN/ENO(CTUD)
[Structured ladder/FBD]
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
CU CD RESET LOAD PV
QU QD CV
15
Operator
CTUD_Instance(CU:=g_bool1,CD:=g_bool2,RESET:=g_bool3,LOAD:=g_bool4,PV:=g_int1,QU:=g_bool5, QD:=g_bool6,CV:=g_int2);
A
Correspondence between Devices and Addresses
B
Function/ Operator List
CTUD_E_Instance(EN:=M0,CU:=g_bool1,CD:=g_bool2,RESET:=g_bool3,LOAD:=g_bool4,PV:=g_int1, QU:=g_bool5,QD:=g_bool6,CV:=g_int2,ENO:=M10);
247
14.6
Outline
This function block keeps ON a signal for specified duration.
1. Format
Function name Expression in each language Structured ladder/FBD ST TP(IN,PT,Q,ET); Example: Instance name(IN:=M0, PT:=Label 1,Q:=M10, ET:=Label 2); TP_E(EN,IN,PT,Q,ET,ENO); Example: Instance name(EN:=X000, IN:=M0,PT:=Label 1,Q:=M10, ET:=Label 2);
Instance name
TP
Instance name
X000
TP_E
M0 Label 1
TP_E EN ENO Q IN PT ET
M10 Label 2
2. Set data
Variable EN Input variable IN ENO Output variable Q ( d1 ) ( s ) Execution condition ON start input signal ON duration data Execution status Output signal ON duration current value Description Bit Bit Time Bit Bit Time Data type
PT ( n )
ET ( d2 )
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 3) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
248
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
IN PT
Q ET
g_bool2 g_time1
13
Applied Functions (Functions Of Time Data Types)
TP_Instance(IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1);
M0 g_bool1 T#10s
[ST]
14
Standard Function Blocks
TP_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1,ENO:=M10);
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
249
14.7
Outline
This function block turns ON after specified time.
1. Format
Function name Expression in each language Structured ladder/FBD ST TON(IN,PT,Q,ET); Example: Instance name(IN:=M0, PT:=Label 1,Q:=M10, ET:=Label 2); TON_E(EN,IN,PT,Q,ET,ENO); Example: Instance name(EN:=X000, IN:=M0,PT:=Label 1,Q:=M10, ET:=Label 2);
Instance name
TON
Instance name
X000
TON_E
M0 Label 1
TON_E EN ENO Q IN PT ET
M10 Label 2
2. Set data
Variable EN Input variable IN ENO Output variable Q ( d1 ) ( s ) Execution condition Input signal ON start time data Execution status Output signal ON start time current value Description Bit Bit Time Bit Bit Time Data type
PT ( n )
ET ( d2 )
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 3) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
250
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
IN PT
Q ET
g_bool2 g_time1
13
Applied Functions (Functions Of Time Data Types)
TON_Instance(IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1);
M0 g_bool1 T#10s
[ST]
14
Standard Function Blocks
TON_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1,ENO:=M10);
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
251
14.8
Outline
When the input signal turns OFF, this function block turns OFF the output signal after the specified time.
1. Format
Function name Expression in each language Structured ladder/FBD ST TOF(IN,PT,Q,ET); Example: Instance name(IN:=M0, PT:=Label 1,Q:=M10, ET:=Label 2); TOF_E(EN,IN,PT,Q,ET,ENO); Example: Instance name(EN:=X000, IN:=M0,PT:=Label 1,Q:=M10, ET:=Label 2);
Instance name
TOF
Instance name
X000
TOF_E
M0 Label 1
TOF_E EN ENO Q IN PT ET
M10 Label 2
2. Set data
Variable EN Input variable IN ENO Output variable Q ( d1 ) ( s ) Execution condition Input signal OFF duration data Execution status Output signal OFF duration current value Description Bit Bit Time Bit Bit Time Data type
PT ( n )
ET ( d2 )
Cautions
1) Use the function having "_E" in its name to connect a bus. 2) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different from simple projects. Use labels when handling 32-bit data. You can specify 32-bit counters directly, however, because they are 32-bit devices. Use global labels when specifying labels. 3) Expression of function blocks in each language Set the instance when using a function block. Describe the instance name when programming a function block.
252
11
Applied Functions (Standard Comparison Functions)
In this program, when bit data stored in a device specified in s turns ON, bit data stored in a device specified in d1 turns ON. When bit data stored in a device specified in s turns OFF, bit data stored in a device specified in d1 turns OFF 10 seconds later. 1) Function without EN/ENO(TOF)
[Structured ladder/FBD]
12
Applied Functions (Standard Character String Functions)
IN PT
Q ET
g_bool2 g_time1
13
Applied Functions (Functions Of Time Data Types)
TOF_Instance(IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1);
14
Standard Function Blocks
M0 g_bool1 T#10s
[ST]
15
Operator
TOF_E_Instance(EN:=M0,IN:=g_bool1,PT:=T#10s,Q:=g_bool2,ET:=g_time1,ENO:=M10);
A
Correspondence between Devices and Addresses
B
Function/ Operator List
253
14.9
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 Expression in each language Structured ladder/FBD ST
COUNTER_FB_M
COUNTER_FB_M(Coil,Preset,Val ueIn,ValueOut,Status);
2. Set data
Variable Input variable Output variable Coil Preset ValueIn ValueOut Status Execution condition Counter set value Counter initial value Counter current value Counter output contact Description Bit Word [signed] Word [signed] ANY16 Bit Data type
Value of Var_D10
10
Var_M10
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.
254
2) When resetting the current value of the counter, reset input variable coil.
11
Applied Functions (Standard Comparison Functions)
[Structured ladder/FBD]
COUNTER_FB_M_Instance COUNTER_FB_M Var_D10 Coil ValueOut Var_M0 10 1 M15 EN Preset ValueIn RST ENO d COUNTER_FB_M_Instance.Coil Status Var_M10
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
[ST]
COUNTER_FB_M_Instance(Coil:= Var_M0,Preset:=10,ValueIn:=1, ValueOut:=Var_D10,Status:=Var_M10); RST(M15,COUNTER_FB_M_Instance.Coil);
Cautions
1) Expression in each language of function block 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.
14
Standard Function Blocks
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
255
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/FBD ST
TIMER_10_FB_M
TIMER_10_FB_M(Coil,Preset, ValueIn,ValueOut,Status);
2. Set data
Variable Input variable Output variable Coil Preset ValueIn ValueOut Status Execution condition Timer set value Initial timer value Current timer value Timer output contact Description Bit Word [signed] Word [signed] ANY16 Bit Data type
Var_M10
*1. *2.
Var_D10 is a global label and is defined as D10. Var_M10 is a global label and is defined as M10.
Cautions
1) Expression in each language of function block 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.
256
11
Applied Functions (Standard Comparison Functions)
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.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST
13
Applied Functions (Functions Of Time Data Types)
TIMER_ CONT_FB_M
TIMER_CONT_FB_M(Coil, Preset,ValueIn,ValueOut,Status);
14
Standard Function Blocks
Description Data type Bit Word [signed] Word [signed] ANY16 Bit
2. Set data
Variable Input variable Output variable Coil Preset ValueIn ValueOut Status Execution condition Timer set value Initial timer value Current timer value Timer output contact
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
Var_M10
ON
*1. *2.
Var_D10 is a global label and is defined as D10. Var_M10 is a global label and is defined as M10.
257
3) When resetting the current value of the retentive timer, reset input variable coil.
[Structured ladder/FBD]
TIMER_CONT_FB_M_Instance TIMER_CONT_FB_M Var_D10 Coil ValueOut Var_M0 10 1 M15 EN Preset ValueIn RST ENO d TIMER_CONT_FB_M_Instance.Coil Status Var_M10
[ST]
TIMER_CONT_FB_M_Instance(Coil:= Var_M0,Preset:=10,ValueIn:=1, ValueOut:=Var_D10,Status:=Var_M10); RST(M15,TIMER_CONT_FB_M_Instance.Coil);
Cautions
1) Expression in each language of function block 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.
258
11
Applied Functions (Standard Comparison Functions)
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.
12
Applied Functions (Standard Character String Functions)
1. Format
Function name Expression in each language Structured ladder/FBD ST
13
Applied Functions (Functions Of Time Data Types)
TIMER_100_FB_M
TIMER_100_FB_M(Coil,Preset, ValueIn,ValueOut,Status);
14
Standard Function Blocks
Description Data type Bit Word [signed] Word [signed] ANY16 Bit
2. Set data
Variable Input variable Output variable Coil Preset ValueIn ValueOut Status Execution condition Timer set value Initial timer value Current timer value Timer output contact
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
Var_M10
*1. *2.
Var_D10 is a global label and is defined as D10. Var_M10 is a global label and is defined as M10.
Cautions
1) Expression in each language of function block 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.
259
15 Operator
15. Operator
Function name ADD SUB MUL DIV MOD ** AND OR XOR NOT GT GE EQ LE LT NE Addition Subtraction Multiplication Division Modulus operation Exponentiation Logical product Logical sum Exclusive logical sum Logical negation Comparison Comparison Comparison Comparison Comparison Comparison Function Reference Section 15.1 Section 15.2 Section 15.3 Section 15.4 Section 15.5 Section 15.6 Section 15.7 Section 15.8 Section 15.9 Section 15.10 Section 15.11 Section 15.12 Section 15.13 Section 15.14 Section 15.15 Section 15.16
260
15 Operator
15.1 ADD / Addition
15.1
ADD / Addition
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This operator performs addition using two values (A + B = C), and outputs the operation result.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1+s2; Example: D20:=D0+D10;
13
Applied Functions (Functions Of Time Data Types)
ADD
ADD
D0 D10
s1 s2
D20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Data for addition or word device which stores such data Word device which will store the operation result
to s28
15
Operator
A
Correspondence between Devices and Addresses
5678
s2 (Word [signed] data) s
6912
d (Word [signed] data)
B
Function/ Operator List
Cautions
Refer to Section 7.1.
Program example
In this program, addition is performed using double word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_dint1 g_dint2
[ST]
ADD
g_dint3
g_dint3:=(g_dint1)+(g_dint2);
261
15 Operator
15.2 SUB / Subtraction
15.2
SUB / Subtraction
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator performs subtraction using two values (A - B = C), and outputs the operation result.
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1-s2; Example: D20:=D0-D10;
SUB
SUB
D0 D10
s1 s2
D20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 s2 d
Description Data to be subtracted or word device which stores such data Data for subtraction or word device which stores such data Word device which will store the operation result
6789
s2 (Word [signed] data)
5556
d (Word [signed] data)
Cautions
Refer to Section 7.2.
Program example
In this program, subtraction is performed using word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
SUB
g_int3
g_int3:=(g_int1)-(g_int2);
262
15 Operator
15.3 MUL / Multiplication
15.3
MUL / Multiplication
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This operator performs multiplication using two or more values (A B = C), and outputs the operation result.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1*s2; Example: D20:=D0*D10;
13
Applied Functions (Functions Of Time Data Types)
MUL
MUL
D0 D10
s1 s2
D20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Data for multiplication or word device which stores such data Word device which will store the operation result
to s28
15
Operator
A
Correspondence between Devices and Addresses
15
s2 (Word [signed] data) s
1500
d (Word [signed] data)
B
Function/ Operator List
Cautions
Refer to Section 7.3.
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/FBD]
g_dint1 g_dint2
[ST]
MUL
g_dint3
g_dint3:=(g_dint1) * (g_dint2);
263
15 Operator
15.4 DIV / Division
15.4
DIV / Division
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator performs division using two values (A / B = C remainder), and outputs the quotient.
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1/s2; Example: D20:=D0/D10;
DIV
DIV
D0 D10
s1 s2
D20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 s2 d
Description Data to be divided, or word device which stores such data Data for division (divisor), or word device which stores such data Word device which will store the operation result
2
s2 (Word [signed] data)
(Quotient) 2
d (Word [signed] data)
Cautions
Refer to Section 7.4.
Error
Refer to Section 7.4.
Program example
In this program, division is performed using double word [signed] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
[Structured ladder/FBD]
g_dint1 g_dint2
[ST]
DIV
g_dint3
g_dint3:=(g_dint1) /(g_dint2);
264
15 Operator
15.5 MOD / Modulus operation
15.5
11
Applied Functions (Standard Comparison Functions)
Outline
This operator performs division using two values (A / B = C remainder), and outputs the remainder.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1 MOD s2 ; The MOD operator is not available in Structured ladder/ Example: FBD language. d:=s1 MOD s2 ;
13
Applied Functions (Functions Of Time Data Types)
MOD
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 s2 d
Description Data to be divided, or word device which stores such data Data for division (divisor), or word device which stores such data Word device which will store the operation result ANY_INT ANY_INT ANY_INT
Data type
14
Standard Function Blocks
15
Operator
2
s2 (Word [signed] data)
(Remainder) 1
d (Word [signed] data)
A
Correspondence between Devices and Addresses
Cautions
Refer to Section 7.5.
B
Function/ Operator List
Error
Refer to Section 7.5.
Program examples
In this program, division is performed using double word [signed] data stored in devices specified in s1 and s2 , and the remainder is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
[ST]
265
15 Operator
15.6 ** / Exponentiation
15.6
** / Exponentiation
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator obtains raised result, and outputs it.
1. Format
Operator name Expression in each language Structured ladder/FBD s1 **s2; The "**" operator is not available in Structured ladder/ Example: FBD language. d:=s1 **s2; ST
**
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 s2 d
Description Data to be raised, or word device which stores such data Power data, or word device which stores such data Word device which will store the operation result
16.0
d Float (single precision) data
Cautions Cautions
Refer to Section 7.6.
Error
Refer to Section 7.6.
Program examples
In this program, the value stored in a device specified in s1 is raised to the power of the value stored in a device specified in s2 , and the operation result is output to a device specified in d using the data type of data stored in a device specified in s1 .
[ST]
g_real2:=EXPT(g_real1,g_int1);
266
15 Operator
15.7 AND / Logical product
15.7
11
Applied Functions (Standard Comparison Functions)
Outline
This operator obtains the logical product of two or more bits, and outputs it.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1 AND s2; Example: M20:=M0 AND M10;
13
Applied Functions (Functions Of Time Data Types)
AND
AND
M0 M10
s1 s2
M20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Device used to obtain the logical product Device which will store the operation result ANY_BIT ANY_BIT Data type to s28
15
Operator
A
Correspondence between Devices and Addresses
Logical product
s2
B
Function/ Operator List
0
s
2)
Cautions
Refer to Section 9.1.
Program examples
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/FBD]
g_word1 g_word2
[ST]
AND
g_word3
267
15 Operator
15.8 OR / Logical sum
15.8
OR / Logical sum
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator obtains the logical sum of two or more bits, and outputs it.
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1 OR s2; Example: M20:=M0 OR M10;
OR
OR
M0 M10
s1 s2
M20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
Description Device used to obtain the logical sum Device which will store the operation result ANY_BIT ANY_BIT
Data type
to s28
Logical sum
s2
1
s
Cautions
Refer to Section 9.2.
Program examples
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/FBD]
g_word1 g_word2
[ST]
OR
g_word3
g_word3:=(g_word1) OR (g_word2);
268
15 Operator
15.9 XOR / Exclusive logical sum
15.9
11
Applied Functions (Standard Comparison Functions)
Outline
This operator obtains the logical sum of two or more bits, and outputs it.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1 XOR s2; Example: M20:=M0 XOR M10;
13
Applied Functions (Functions Of Time Data Types)
XOR
XOR
M0 M10
s1 s2
M20
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Device used to obtain the exclusive logical sum Device which will store the operation result ANY_BIT ANY_BIT
Data type
to s28
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
0
s
2)
3) If there are 3 or more s , the exclusive logical sum is obtained using the "exclusive logical sum of s1 and s2 " and s3 . If there is s4 , the exclusive logical sum is obtained using the "exclusive logical sum of "exclusive logical sum of s1 and s2 " and " s3 "" and s4 . In this way, the exclusive logical sum is obtained the s6 required number of times for all input labels s5 Example: When the data type is bit
When the number of "_IN" is 3
s1
FALSE XOR
TRUE XOR
s3
s2
TRUE
TRUE
TRUE
TRUE
Result TRUE
Result FALSE
Result TRUE
After that, the exclusive logical sum is obtained the required number of Result FALSE times.
269
15 Operator
15.9 XOR / Exclusive logical sum
Program examples
In this program, the exclusive logical sum is obtained using each bit of word [unsigned]/bit string [16-bit] data stored in devices specified in s1 and s2 , and the operation result is output to a device specified in d using the data type of data stored in devices specified in s1 and s2 .
[Structured ladder/FBD]
g_word1 g_word2
[ST]
XOR
g_word3
270
15 Operator
15.10 NOT / Logical negation
11
Applied Functions (Standard Comparison Functions)
Outline
This operator obtains the logical negation of bits, and outputs it.
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD NOT s1; The NOT operator is not available in Structured ladder/ Example: FBD language. d:=NOT(s); ST
13
Applied Functions (Functions Of Time Data Types)
NOT
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s d
Description Device used to obtain the logical negation Device which will store the operation result ANY_BIT ANY_BIT
Data type
14
Standard Function Blocks
15
Operator
A
Correspondence between Devices and Addresses
Logical negation
d
Cautions
Refer to Section 9.4.
B
Function/ Operator List
Program examples
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 .
[ST]
g_word2:= NOT(g_word1);
271
15 Operator
15.11 GT / Comparison
15.11 GT / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator compares data with regard to "> (larger)".
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1>s2; Example: M0:=D0>D10;
GT
GT
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
Description Compared data, or word device which stores such data Device which will store the comparison result ANY_BIT Bit
Data type
to s28
Cautions
Refer to Section 11.1.
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
GT
g_bool2
g_bool2:=(g_int1)>(g_int2);
272
15 Operator
15.12 GE / Comparison
15.12 GE / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This operator compares data with regard to " (larger or equal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1>=s2; Example: M0:=D0>=D10;
13
Applied Functions (Functions Of Time Data Types)
GE
GE
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Compared data, or word device which stores such data Device which will store the comparison result
to s28
15
Operator
A
Correspondence between Devices and Addresses
Cautions
Refer to Section 11.2.
B
Function/ Operator List
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
GE
g_bool2
g_bool2:=(g_int1)>=(g_int2);
273
15 Operator
15.13 EQ / Comparison
15.13 EQ / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator compares data with regard to "= (equal)".
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1=s2; Example: M0:=D0=D10;
EQ
EQ
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
Description Compared data, or word device which stores such data Device which will store the comparison result
to s28
Cautions
Refer to Section 11.3.
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
EQ
g_bool2
g_bool2:=(g_int1)=(g_int2);
274
15 Operator
15.14 LE / Comparison
15.14 LE / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This operator compares data with regard to " (smaller or equal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1<=s2; Example: M0:=D0<=D10;
13
Applied Functions (Functions Of Time Data Types)
LE
LE
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description Compared data, or word device which stores such data Device which will store the comparison result
to s28
15
Operator
A
Correspondence between Devices and Addresses
Cautions
Refer to Section 11.4.
B
Function/ Operator List
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
LE
g_bool2
g_bool2:=(g_int1)<=(g_int2);
275
15 Operator
15.15 LT / Comparison
15.15 LT / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
Outline
This operator compares data with regard to "< (smaller)".
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1<s2; Example: M0:=D0<D10;
LT
LT
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
Description Compared data, or word device which stores such data Device which will store the comparison result
to s28
Cautions
Refer to Section 11.5.
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
g_int1 g_int2
[ST]
LT
g_bool2
g_bool2:=(g_int1)<(g_int2);
276
15 Operator
15.16 NE / Comparison
15.16 NE / Comparison
FX3U(C) FX3G(C) FX2N(C) FX1N(C) FX1S FXU/FX2C FX0N FX0(S)
11
Applied Functions (Standard Comparison Functions)
Outline
This operator compares data with regard to " (unequal)".
12
Applied Functions (Standard Character String Functions)
1. Format
Operator name Expression in each language Structured ladder/FBD ST s1<>s2; Example: M0:=D0<>D10;
13
Applied Functions (Functions Of Time Data Types)
NE
NE
D0 D10
s1 s2
M0
In explanation of operators, the input variable is described as "s " and the output variable is descried as "d".
2. Set data
Variable Input variable Output variable
s1 d
14
Standard Function Blocks
Description
s2
to
Compared data, or word device which stores such data Device which will store the comparison result
15
Operator
A
Correspondence between Devices and Addresses
Cautions
Refer to Section 11.6.
Program examples
In this program, the contents of devices specified in s1 and s2 are compared, and the operation result is output to a device specified in d .
[Structured ladder/FBD]
B
Function/ Operator List
g_int1 g_int2
[ST]
NE
g_bool2
g_bool2:=(g_int1)<>(g_int2);
277
Data register Intelligent function unit device Extension register Extension file register Pointer Interrupt pointer Nesting Index register
278
12
13
14
15
11
Operator
MEMO
279
BOOL_TO_ Converts bit data into word [signed] data. INT(_E) BOOL_TO_ Converts bit data into double word [signed] DINT(_E) data. BOOL_TO_ Converts bit data into string data. STR(_E) BOOL_TO_ Converts bit data into word [unsigned]/bit WORD(_E) string [16-bit] data. BOOL_TO_ Converts bit data into double word DWORD(_E) [unsigned]/bit string [32-bit] data. BOOL_TO_ Converts bit data into time data. TIME(_E) INT_TO_ DINT(_E) DINT_TO_ INT(_E) INT_TO_ BOOL(_E) DINT_TO_ BOOL(_E) INT_TO_ REAL(_E) DINT_TO_ REAL(_E) INT_TO_ STR(_E) DINT_TO_ STR(_E) INT_TO_ WORD(_E) DINT_TO_ WORD(_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. Converts double word [signed] data into bit data. Converts word [signed] data into float (single precision) data. Converts double word [signed] data into float (single precision) data. 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.
WORD_TO Converts word [unsigned]/bit string [16-bit] _BOOL(_E) data into bit data. DWORD_TO Converts double word [unsigned]/bit string _BOOL(_E) [32-bit] data into bit data. WORD_TO _INT(_E) WORD_TO _DINT(_E) 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.
DWORD_ Converts double word [unsigned]/bit string TO_INT(_E) [32-bit] data into word [signed] data. Converts double word [unsigned]/bit string DWORD_ [32-bit] data into double word [signed] TO_DINT(_E) data. Converts word [unsigned]/bit string [16-bit] WORD_TO_ data into double word [unsigned]/bit string DWORD(_E) [32-bit]. DWORD_ TO_WORD (_E) WORD_TO _TIME(_E) DWORD_ TO_TIME(_ E) STR_TO_ BOOL(_E) STR_TO_ INT(_E) STR_TO_ DINT(_E) STR_TO_ REAL(_E) STR_TO_ TIME(_E) BCD_TO_ INT(_E) BCD_TO_ DINT(_E) TIME_TO_ BOOL(_E) Converts double word [unsigned]/bit string [32-bit] data into word [unsigned]/bit string [16-bit] data. Converts word [unsigned]/bit string [16-bit] data into time data. Converts double word [unsigned]/bit string [32-bit] data into time data. Converts string data into bit data. 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. Converts BCD data into word [signed] data. Converts BCD data into double word [signed] data. Converts time data into bit data.
101
103 105 107 109 111 113 115 118 120 122 124 126 128 130 132
INT_TO_ Converts word [signed] data into double DWORD(_E) word [unsigned]/bit string [32-bit] data. Converts double word [signed] data into DINT_TO_ double word [unsigned]/bit string [32-bit] DWORD(_E) data. INT_TO_B CD(_E) DINT_TO_ BCD(_E) INT_TO_ TIME(_E) DINT_TO_ TIME(_E) REAL_TO_ INT(_E) REAL_TO_ DINT(_E) Converts word [signed] data into BCD data. Converts double word [signed] data into BCD data. Converts word [signed] data into time data. Converts double word [signed] data into time data. Converts float (single precision) data into word [signed] data. Converts float (single precision) data into double word [signed] data.
TIME_TO_I Converts time data into word [signed] data. NT(_E) TIME_TO_ DINT(_E) TIME_TO_ STR(_E) TIME_TO_ WORD(_E) Converts time data into double word [signed] data. Converts time data into string data. Converts time data into word [unsigned]/bit string [16-bit] data.
280
Function
11
Applied Functions (Standard Comparison Functions)
TIME_TO_ Converts time data into double word DWORD(_E) [unsigned]/bit string [32-bit] data. Converts specified number of bits of a bit BITARR_ array into word [signed] data or word TO_INT(_E) [unsigned]/bit string [16-bit] data. Converts specified number of bits of a bit BITARR_TO array into double word [signed] data or _DINT(_E) double word [unsigned]/bit string [32-bit] data. INT_TO_ BITARR(_E) DINT_TO_ BITARR(_E) Outputs low-order "n" bits of word [signed] data or word [unsigned]/bit string [16-bit] data to a bit array. Outputs low-order "n" bits of double word [signed] data or double word [unsigned]/bit string [32-bit] data to a bit array.
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
CPY_BITARR Copies specified number of bits of a bit (_E) array. GET_BIT_ OF_INT(_E) SET_BIT_ OF_INT(_E) CPY_BIT_ OF_INT(_E) Reads the value of a specified bit of word [signed] data. Writes a value to a specified bit of word [signed] data. Copies a specified bit of word [signed] data to a specified bit of another word [signed] data.
14
Standard Function Blocks
Judges whether data is located within the LIMITATION range between the upper limit value and (_E) the lower limit value. MUX(_E) Selects data, and outputs it. (Number of pins variable)
GET_BOOL Outputs start data as bit data. _ADDR GET_INT_ ADDR Outputs start data as word [signed] data.
15
Operator
GET_WORD Outputs start data as word [unsigned]/bit _ADDR string [16-bit] data.
A
Correspondence between Devices and Addresses
B
Function/ Operator List
281
& Obtains the logical product. AND (Number of pins variable) OR Obtains the logical sum. (Number of pins variable)
Obtains the exclusive logical XOR sum. (Number of pins variable) NOT Obtains the logical not.
272
>=
273
EQ
274
<=
275
LT NE
< <>
276 277
TIMER_10_ 10ms timer drive FB_M TIMER_CO NT Retentive timer drive _FB_M TIMER_100_ 100ms timer drive FB_M
282
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
DINT_TO_T Converts double word [signed] data into IME(_E) time data. DINT_TO_ WORD(_E) DIV_TIME (_E) DIV_E DWORD_T O_BOOL (_E) Converts double word [signed] data into word [unsigned]/bit string [16-bit] data. Divides time data. Divides data (, and outputs the quotient). Converts double word [unsigned]/bit string [32-bit] data into bit data.
13
Applied Functions (Functions Of Time Data Types)
Converts specified number of bits of a bit BITARR_T array into double word [signed] data or O_DINT(_E) double word [unsigned]/bit string [32-bit] data. BITARR_T O_INT(_E) Converts specified number of bits of a bit array into word [signed] data or word [unsigned]/bit string [16-bit] data.
138
14
Standard Function Blocks
136 40 46 38 42 48 44
Converts double word [unsigned]/bit string DWORD_T [32-bit] data into double word [signed] O_DINT(_E) data. DWORD_T O_INT(_E) Converts double word [unsigned]/bit string [32-bit] data into word [signed] data.
99 97 107 103
BOOL_TO_ Converts bit data into double word [signed] DINT(_E) data. BOOL_TO_ Converts bit data into double DWORD(_E) [unsigned]/bit string [32-bit] data. word
DWORD_T Converts double word [unsigned]/bit string O_TIME(_E) [32-bit] data into time data. DWORD_T O_WORD (_E) E EQ_E EXPT(_E) F FIND(_E) Searches a character string. Compares data with regard to "= (equal)". (Number of pins variable) Obtains the raised result. Converts double word [unsigned]/bit string [32-bit] data into word [unsigned]/bit string [16-bit] data.
15
Operator
BOOL_TO_ Converts bit data into word [signed] data. INT(_E) BOOL_TO_ Converts bit data into string data. STR(_E) BOOL_TO_ Converts bit data into time data. TIME(_E) BOOL_TO_ Converts bit data into word [unsigned]/bit WORD(_E) string [16-bit] data. C CONCAT(_ E) COUNTER _FB_M CPY_BITA RR(_E) Connects character strings. (Number of pins variable) Counter drive Copies specified number of bits of a bit array.
A
Correspondence between Devices and Addresses
Detects the falling edge of a signal, and F_TRIG(_E) outputs pulse signal. G GE_E Compares data with regard to " (larger or equal)". (Number of pins variable)
B
Function/ Operator List
Copies a specified bit of word [signed] data CPY_BIT_ to a specified bit of another word [signed] OF_INT(_E) data. CTD(_E) CTUD(_E) CTU(_E) D DELETE(_E) Deletes a character string. DINT_TO_ BCD(_E) Converts double word [signed] data into BCD data. Counts down the number of times of rising of a signal. Counts up/down the number of times of rising of a signal. Counts up the number of times of rising of a signal.
GET_BIT_ Reads the value of a specified bit of word OF_INT(_E) [signed] data. GET_BOOL Outputs start data as bit data. _ADDR GET_INT_A Outputs start data as word [signed] data. DDR GET_WOR D_ADDR GT_E I Outputs start data as word [unsigned]/bit string [16-bit] data. Compares data with regard to "> (larger)". (Number of pins variable)
220 76 142 56 72
INSERT(_E) Inserts a character string. INT_TO_B CD(_E) INT_TO_BI TARR(_E) INT_TO_B OOL(_E) INT_TO_DI NT(_E) Converts word [signed] data into BCD data. Outputs low-order "n" bits of word [signed] data or word [unsigned]/bit string [16-bit] data to a bit array. Converts word [signed] data into bit data. Converts word [signed] data into double word [signed] data.
217 76 140 54 50
Outputs low-order "n" bits of double word DINT_TO_B [signed] data or double word [unsigned]/bit ITARR(_E) string [32-bit] data to a bit array. DINT_TO_ BOOL(_E) Converts double word [signed] data into bit data.
Converts double word [signed] data into DINT_TO_D double word [unsigned]/bit string [32-bit] WORD(_E) data.
283
Function
Function
Ref. Page
STR_TO_D Converts string data into double word INT(_E) [signed] data. STR_TO_I NT(_E) Converts string data into word [signed] data.
INT_TO_ST Converts word [signed] data into string R(_E) data. INT_TO_TI ME(_E) INT_TO_W ORD(_E) L LE_E LIMITATIO N(_E) LT_E M MAXIMUM (_E) MID(_E) MINIMUM (_E) MOD(_E) MOVE(_E) MUL_TIME (_E) MUL_E MUX(_E) N NE_E NOT(_E) O OR_E R REAL_TO_ DINT(_E) Converts float (single precision) data into double word [signed] data. Obtains the logical sum. (Number of pins variable) Compares data with regard to " (unequal)". Obtains the logical not. Searches the maximum value. (Number of pins variable) Obtains a character string from a specified position. Searches the minimum value. (Number of pins variable) Divides data (, and outputs the remainder). Transfers data. Multiplies time data. Multiplies data. (Number of pins variable) Selects data, and outputs it. (Number of pins variable) Compares data with regard to " (smaller or equal)". (Number of pins variable) Judges whether data is located within the range between the upper limit value and the lower limit value. Compares data with regard to "< (smaller)". (Number of pins variable) Converts word [signed] data into time data. Converts word [signed] data into word [unsigned]/bit string [16-bit] data.
STR_TO_R Converts string data into float (single EAL(_E) precision) data. STR_TO_TI Converts string data into time data. ME(_E) SUB_TIME (_E) SUB_E T TIME_TO_ BOOL(_E) TIME_TO_ DINT(_E) Converts time data into bit data. Converts time data into double word [signed] data. Subtracts time data. Subtracts data.
124 128 134 126 130 132 257 256 259 252 250 248
TIME_TO_D Converts time data into double word WORD(_E) [unsigned]/bit string [32-bit] data. TIME_TO_I Converts time data into word [signed] data. NT(_E) TIME_TO_ STR(_E) TIME_TO_ WORD(_E) Converts time data into string data. Converts time data into word [unsigned]/bit string [16-bit] data.
TIMER_CO Retentive timer drive NT_FB_M TIMER_10_ 10ms timer drive FB_M TIMER_100 100ms timer drive _FB_M TOF(_E) TON(_E) Turns OFF the output signal at specified time after the input signal turned OFF. Keeps OFF a signal during specified time duration. Keeps ON a signal during specified time duration.
209 185
TP(_E) W
181
WORD_TO Converts word [unsigned]/bit string [16-bit] _BOOL(_E) data into bit data. WORD_TO _DINT(_E) Converts word [unsigned]/bit string [16-bit] data into double word [signed] data. Converts word [unsigned]/bit string [16-bit] data into double word [unsigned]/bit string [32-bit]. Converts word [unsigned]/bit string [16-bit] data into word [signed] data. Converts word [unsigned]/bit string [16-bit] data into time data. Obtains the exclusive logical sum. (Number of pins variable)
89 95 101 93 105
84 82 86 222 238
REAL_TO_I Converts float (single precision) data into NT(_E) word [signed] data. REAL_TO_ STR(_E) REPLACE (_E) R_TRIG(_E) S SEL(_E) Selects data in accordance with the input condition. Converts float (single precision) data into string data. Replaces a character string. Detects the rising edge of a signal, and outputs pulse signal.
183
SET_BIT_O Writes a value to a specified bit of word F_INT(_E) [signed] data. SHL(_E) SHR(_E) Shifts bits leftward. Shifts bits rightward.
284
11
Applied Functions (Standard Comparison Functions)
12
Applied Functions (Standard Character String Functions)
13
Applied Functions (Functions Of Time Data Types)
14
Standard Function Blocks
15
Operator
A
Correspondence between Devices and Addresses
B
Function/ Operator List
285
MEMO
286
Warranty
Warranty
Please confirm the following product warranty details before using this product.
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.
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 failsafe functions are systematically provided outside of the device for any problem or fault. 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.
2)
287
Revision History
Revision History
Date of preparation 1/2009 7/2009 Revision A B First Edition. Equivalent circuits are deleted. Following instructions are not supported in FX0,FX0S and FX0N PLCs. CTD(_E), CTU(_E), CTUD(_E), TOF(_E), TON(_E), TP(_E) Function blocks (SR(_E), RS(_E)) are deleted. Manual name of a related manual was changed. Operators are added. Following functions are added. BITARR_TO_INT(_E), BITARR_TO_DINT(_E), INT_TO_BITARR(_E), DINT_TO_BITARR(_E), CPY_BITARR(_E), GET_BIT_OF_INT(_E), SET_BIT_OF_INT(_E), CPY_BIT_OF_INT(_E), GET_BOOL_ADDR, GET_INT_ADDR and GET_WORD_ADDR Appendix B is added. FBD language is added. FX3GC is added. The reset method of the counter value and timer value of a function block (COUNTER_FB_M, TIMER_CONT_FB_M) is added. Description
2/2010 9/2010
C D
E F G
288
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
JY997D34801G (MEE)