0% found this document useful (0 votes)
2 views368 pages

M32E_InstructionHelp

The document provides safety instructions and guidelines for using the LS ELECTRIC Programmable Logic Control Motion Control Module (XGF-M32E). It emphasizes the importance of adhering to safety protocols to prevent accidents, including warnings and cautions related to installation, wiring, and maintenance. Additionally, it outlines the structure of the user manual and the features of the IEC 61131-3 language supported by the module.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views368 pages

M32E_InstructionHelp

The document provides safety instructions and guidelines for using the LS ELECTRIC Programmable Logic Control Motion Control Module (XGF-M32E). It emphasizes the importance of adhering to safety protocols to prevent accidents, including warnings and cautions related to installation, wiring, and maintenance. Additionally, it outlines the structure of the user manual and the features of the IEC 61131-3 language supported by the module.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 368

LS ELECTRIC strives to maximize your profits in gratitude for choosing us as your partner.

Programmable Logic Control

Motion Control Module Instruction


XGT Series

XGF-M32E
Safety Instruction

Before using the product …

For your safety and effective operation, please read the safety instructions thoroughly before using the product.

► Safety Instructions should always be observed in order to prevent accident or risk with the safe and

proper use the product.

► Instructions are divided into “Warning” and “Caution”, and the meaning of the terms is as follows.

Warning This symbol indicates the possibility of serious injury or death if some applicable

instruction is violated.

This symbol indicates the possibility of severe or slight injury, and property
Caution
damages if some applicable instruction is violated.

Moreover, even classified events under its caution category may develop into serious accidents relying on

situations. Therefore we strongly advise users to observe all precautions properly just like warnings.

► The marks displayed on the product and in the user’s manual have the following meanings.

Be careful! Danger may be expected.

Be careful! Electric shock may occur.

► The user’s manual even after read shall be kept available and accessible to any user of the product.

1
Safety Instruction

Safety Instructions for Design Process

Caution
 Design the analog input / output signal or pulse input / output line at least 100mm away

from high voltage line or power line so that it is not affected by noise or magnetic field

change. It may cause malfunction due to noise.

 If there is a lot of vibration in the installation environment, take measures to prevent

direct vibration from being applied to the PLC. It may cause electric shock, fire or malfunction.

 If metallic dust is present in the installation environment, take measures to prevent

metallic dust from entering the product. It may cause electric shock, fire or malfunction.

Safety Instructions on Installation Process

Caution
 Use PLC only in the environment specified in PLC manual or general standard of datasheet.

If not, electric shock, fire, abnormal operation of the product may be caused.

 Before install or remove the module, be sure PLC power is off. If not, electric shock or damage

on the product may be caused.

 Be sure that every module is securely attached after adding a module or an extension

connector. If the product is installed loosely or incorrectly, abnormal operation, error or dropping

may be caused. In addition, contact failures under poor cable installation will be causing

malfunctions as well.

 Make sure that the I / O connector is securely fastened. It may cause wrong input or output.

2
Safety Instruction

Safety Instructions for Wiring Process

Warning
 Prior to wiring works, make sure that every power is turned off. If not, electric shock or

damage on the product may be caused.

Caution
 Check rated voltages and terminal arrangements in each product prior to its wiring

process. Applying incorrect voltages other than rated voltages and misarrangement among

terminals may cause fire or malfunctions.

 Secure terminal screws tightly applying with specified torque. If the screws get loose, short

circuit, fire or abnormal operation may be caused. Securing screws too tightly will cause

damages to the module or malfunctions, short circuit, and dropping.

 Be sure to earth to the ground using Class 3 wires for PE terminals which is exclusively

used for PLC. If the terminals not grounded correctly, abnormal operation or electric shock

may be caused.

 Don’t let any foreign materials such as wiring waste inside the module while wiring,

which may cause fire, damage on the product or abnormal operation.

3
Safety Instruction

Safety Instructions for Test-Operation and Maintenance


Warning
 Don’t touch the terminal when powered. Electric shock or abnormal operation may occur.

 Prior to cleaning or tightening the terminal screws, let all the external power off including

PLC power. If not, electric shock or abnormal operation may occur.

Caution

 Do not make modifications or disassemble each module.

Fire, electric shock or abnormal operation may occur.

 Prior to installing or disassembling the module, let all the external power off including

PLC power. If not, electric shock or abnormal operation may occur.

 Keep any wireless equipment such as walkie-talkie or cell phones at least 30cm away

from PLC. If not, abnormal operation may be caused.

Safety Instructions for Waste Disposal

Caution

 Product or battery waste shall be processed as industrial waste. The waste may discharge

toxic materials or explode itself.

4
Revision History

Revision History
Version Date Remark Revised position
V 1.0 2013.9 1. First Edition -
1. Domain address and CI changed -
V1.1 2015.7
2. General specifications changed by reason of changed IEC specifications. 2-1
1. Format and contents modification according to the change of company
V1.2 2020.7 -
name(LSIS  LS ELECTRIC)

5
Abut User’s Manual

Thank you for purchasing PLC of LS ELECTRIC Co., Ltd.


Before use, make sure to carefully read and understand the User’s Manual about the functions, performances, installation and
programming of the product you purchased in order for correct use and importantly, let the end user and maintenance
administrator to be provided with the User’s Manual.

The User’s Manual describes the product. If necessary, you may refer to the following description and order accordingly. In
addition, you may connect our website (http://www.lselectric.co.kr/) and download the information as a PDF file.
Relevant User’s Manuals
Title Description
XG5000 User’s Manual XG5000 software user manual describing online function such as programming, print,
(for XGK, XGB) monitoring, debugging by using XGK, XGB CPU.
XG5000 User’s Manual XG5000 software user manual describing online function such as programming, print,
(for XGI, XGR) monitoring, debugging by using XGI, XGR CPU.
XGK/XGB Instructions & User’s manual for programming to explain how to use instructions that are used PLC system
Programming User’s Manual with XGK, XGB CPU.
XGI/XGR/XEC Instructions & User’s manual for programming to explain how to use instructions that are used PLC system
Programming User’s Manual with XGI, XGR, XEC CPU.
XGK-CPUA/CPUE/CPUH/CPUS/CPUU user manual describing about XGK CPU module,
XGK CPU User’s Manual
power module, base, IO module, specification of extension cable and system configuration,
(XGK-CPUA/E/H/S/U)
EMC standard.
XGI CPU User’s Manual XGI-CPUU/CPUH/CPUS user manual describing about XGI CPU module, power module,
(XGI-CPUU/CPUH/CPUS) base, IO module, specification of extension cable and system configuration, EMC standard.
XGR- CPUH/F, CPUH/T user manual describing about XGR CPU module, power module,
XGR Redundant Series
extension drive, base, IO module, specification of extension cable and system configuration,
User’s Manual
EMC standard.
XG-PM software user manual describing online function such as motion programing,
XG-PM User’s Manual
monitoring, debugging by using Positioning Module.
Motion Control Module Describes the specification, installation method, how to use various functions, programming
User’s Manual and external devices and wiring, etc. of XGF-M32E motion control module.

6
Table of Content

◎ Table of Content ◎

Chapter 1 Introduction ..........................................................................................................................1-1

1.1 Features of IEC 61131-3 Language ............................................................................................................................................ 1-1

1.2 Types of Language ....................................................................................................................................................................... 1-1

Chapter 2 The Structure of Software .......................................................................................... 2-1~2-2

2.1 Introduction .................................................................................................................................................................................... 2-1

2.2 Project ............................................................................................................................................................................................ 2-2

2.3 Global/Direct Variable ................................................................................................................................................................... 2-2

2.4 Parameter and Point/Cam date ................................................................................................................................................... 2-2

2.5 Main task, Periodic task, Initialization task................................................................................................................................... 2-2

2.6 User data type ............................................................................................................................................................................... 2-2

Chapter 3 Common Element ..................................................................................................... 3-1~3-12

3.1 Expression ..................................................................................................................................................................................... 3-1

3.1.1 Identifiers ............................................................................................................................................................................. 3-1

3.1.2 Data Expression ................................................................................................................................................................. 3-1

3.2 Data Type....................................................................................................................................................................................... 3-3

3.2.1 Basic Data Type ................................................................................................................................................................. 3-3

3.2.2 Data Type Hierarchy Chart ................................................................................................................................................ 3-4

3.2.3 Initial Value .......................................................................................................................................................................... 3-4

3.2.4 Data Type Structure............................................................................................................................................................ 3-5

3.3 Variable........................................................................................................................................................................................... 3-7

3.3.1 Variable Expression............................................................................................................................................................ 3-7

3.3.2 Variable Declaration ........................................................................................................................................................... 3-8

3.3.3 Reserved Variable ............................................................................................................................................................ 3-10

3.3.4 Reserved Word ................................................................................................................................................................ 3-10

3.4 Function Selection....................................................................................................................................................................... 3-11

3.4.1 Internally Determined Function ....................................................................................................................................... 3-11

7
Table of Content

Chapter 4 LD (Ladder Diagram) .................................................................................................. 4-1~4-7

4.1 Introduction .................................................................................................................................................................................... 4-1

4.2 Bus.................................................................................................................................................................................................. 4-1

4.3 Link ................................................................................................................................................................................................. 4-2

4.4 Contact ........................................................................................................................................................................................... 4-2

4.5 Coil.................................................................................................................................................................................................. 4-3

4.6 Calling of Function and Function Block ....................................................................................................................................... 4-4

Chapter 5 Function and Function Block .................................................................................. 5-1~5-12

5.1 Functions........................................................................................................................................................................................ 5-1

5.1.1 Type Conversion Function................................................................................................................................................. 5-1

5.1.2 Numerical Operation Function .......................................................................................................................................... 5-6

5.1.3 Angle Convert Function ..................................................................................................................................................... 5-6

5.1.4 Bit Array Function ............................................................................................................................................................... 5-7

5.1.5 Selection Function .............................................................................................................................................................. 5-7

5.1.6 Data Exchange Function ................................................................................................................................................... 5-7

5.1.7 Comparison Function......................................................................................................................................................... 5-8

5.1.8 Data And Time Of Day Function ....................................................................................................................................... 5-8

5.1.9 Data Manipulation Function............................................................................................................................................... 5-8

5.2 Basic Function Block..................................................................................................................................................................... 5-9

5.2.1 Bistable Function Block...................................................................................................................................................... 5-9

5.2.2 Edge Detection Function Block......................................................................................................................................... 5-9

5.2.3 Counter................................................................................................................................................................................ 5-9

5.2.4 Timer.................................................................................................................................................................................. 5-10

5.3 Expanded Function ..................................................................................................................................................................... 5-10

5.4 Motion Control Function Block ................................................................................................................................................... 5-11

Chapter 6 Basic Function.......................................................................................................... 6-1~6-120

Chapter 7 Application Function................................................................................................. 7-1~7-31

8
Table of Content

Chapter 8 Basic Function Block ............................................................................................... 8-1~8-23

Chapter 9 Application Function Block .................................................................................10-1~10-23

Chapter 11 Expanded Function ............................................................................................... 11-1~11-5

Chapter 12 ST (Structured Text) ............................................................................................12-1~12-26

12.1 General ...................................................................................................................................................................................... 12-1

12.2 Comments ................................................................................................................................................................................. 12-1

12.3 Expression ................................................................................................................................................................................. 12-2

12.3.1 + operator........................................................................................................................................................................ 12-3

12.3.2 - operator......................................................................................................................................................................... 12-3

12.3.3 * operator ........................................................................................................................................................................ 12-4

12.3.4 / operator ......................................................................................................................................................................... 12-4

12.3.5 MOD operator................................................................................................................................................................. 12-6

12.3.6 ** operator ....................................................................................................................................................................... 12-6

12.3.7 AND or & operator ......................................................................................................................................................... 12-7

12.3.8 OR operator .................................................................................................................................................................... 12-7

12.3.9 XOR operator ................................................................................................................................................................. 12-8

12.3.10 = operator ..................................................................................................................................................................... 12-8

12.3.11 <> operator ................................................................................................................................................................... 12-9

12.3.12 > operator ..................................................................................................................................................................... 12-9

12.3.13 < operator ................................................................................................................................................................... 12-10

12.3.14 >= operator ................................................................................................................................................................. 12-11

12.3.15 <= operator ................................................................................................................................................................. 12-11

12.3.16 NOT operator ............................................................................................................................................................. 12-12

12.3.17 - operator..................................................................................................................................................................... 12-12

12.4 Statements.................................................................................................................................................................................. 12-13

12.4.1 Assignment statements ............................................................................................................................................... 12-13

12.4.2 Selection statements.................................................................................................................................................... 12-13

12.4.3 Iteration statements...................................................................................................................................................... 12-13

9
Table of Content

12.4.4 IF.................................................................................................................................................................................... 12-15

12.4.5 CASE ............................................................................................................................................................................ 12-16

12.4.6 FOR............................................................................................................................................................................... 12-17

12.4.7 WHILE........................................................................................................................................................................... 12-18

12.4.8 REPEAT........................................................................................................................................................................ 12-19

12.4.9 EXIT............................................................................................................................................................................... 12-20

12.5 Function and Function Block.................................................................................................................................................. 12-22

12.5.1 How to use .................................................................................................................................................................... 12-22

12.5.2 Example ........................................................................................................................................................................ 12-24

Appendix 1 Numerical System and Data Structure ........................................................... A1-1~A1-6

A1.1 Numerical (data) Representation ............................................................................................................................................A1-1

A1.2 Integer Representation.............................................................................................................................................................A1-6

A1.3 Negative Number Representation ..........................................................................................................................................A1-6

Appendix 2 Flag and Parameter List .................................................................................... A2-1~A2-9

A2.1 System Flag ..............................................................................................................................................................................A2-1

A2.2 Motion Flag................................................................................................................................................................................A2-3

A2.3 I/O Flag ......................................................................................................................................................................................A2-6

Warranty and Environmental Policy

10
Chapter1 Introduction

Chapter 1 Introduction
This user’s guide describes the languages supported by Motion control module. The Motion control module is based on the
standard language of International Electrotechnical Commission (IEC).

1.1. Features of IEC 61131-3 Language


The features of the IEC language supported by the PLC are as follows
▷ Supports several data types.
▷ Offers program elements such as functions, function blocks, and programs to enable bottom-up design and top-down
design and structural creation of a PLC program.
▷ Program storage in a library system to enable future use in other environments. This enables the reuse of the software.
▷ Supports various languages so that the user can select the optimal language suitable for the environment.

1.2. Types of Language


The PLC language standardized by IEC consists of two illustrated languages, two character languages and SFC. (XGF-M32E
Motion Control Module supports LD, ST language.)

▷ Illustrated language
a) Ladder Diagram (LD): It is a graphical language based on the ladder logic.
b) Function Block Diagram (FBD): It is a graphical language for depicting signal and data flows through function blocks.
▷ Character language
a) Instruction List (IL): It is a low-level ‘assembly like’ language based on similar instruction list languages.
b) Structured Text (ST):It is a high-level PASCAL type language.
▷ Sequential Function Chart (SFC)

1-1
Chapter1 Introduction

1-2
Chapter2 Software Structure

Chapter 2 Software Structure

2.1 Introduction
Before creating a PLC program, ensure that you have an overall Motion control system defined in software terms. The overall PLC
system is defined as one project in Motion control module. In the project, you must define hierarchically all composition elements
necessary for the Motion control system.

Project Global/Direct Variable

Parameter Basic Parameter

I/O Parameter
User Data Type

Scan Program

User Function/Function Block

Task Program

2-1
Chapter2 Software Structure

2.2 Project
For a Motion control module program, the first priority is given to project configuration. Creating a project comprises of configuring
and programming all elements necessary for a Motion control system (scan programs, task definitions, basic parameters, I/O
parameters, and so on).

2.3 Global/Direct Variable


The project enables global variable setting, direct variable setting and flag, in which a user prepares or uses the necessary
information.

2.4 Parameter and Point/Cam date


Parameters and position/Cam data indicates various parameters and data required to operate the Motion Control System. For
more details on each parameter and data, refer to the Motion Control Module manual.

2.5 Main task, Periodic task, Initialization task


- The main task processes the command executed every control cycle and communication cycle.
- The periodic task processes the command executed every cycle that is set as the multiple of the control cycle.
- The Initialization task is executed when the module’s operation mode is converted from Stop to Run.
- For more details on each task, refer to the Motion Control Module manual (4.3 Motion Control task).

2.6 User data type


A user can set the data type used for the program by making and registering variables, types, comment, etc. The registered user
data type can be used in the program like the basic data type.

2-2
Chapter3 Common Element

Chapter 3 Common Element


The elements of Motion control module (programs, functions, function blocks) can be programmed in other languages such as LD, ST,
and so on. All the language share common grammar elements.

3.1 Expression

3.1.1 Identifiers
▷ Identifiers must be mixed of alphabet, numeric and all letters starting with underlined letters.
▷ Identifiers are used as variable names.
▷ Blank (space) is not allowed in identifiers.
▷ In case of variable or instance name, identifiers may consist of Korean, Alphabet and Chinese characters.
▷ There’s no difference between small letters and capitals in alphabet; all the letters of the alphabet are recognized as upper
case.

Types Examples
Capital alphabet and number IW210, IW215Z, QX75, IDENT
Capital alphabets ,numbers and underline(_) LIM_SW_2, LIMSW5, ABCD, AB_CD
Capital alphabet and number characters starting
_MAIN, _12V7, _ABCD
with an underline(_)

3.1.2 Data Expression


The data in Motion control module is; numeric data type, character string, time data type, and so on.

Types Examples
Integer -12, 0, 123_456, +986
Real number -12.0, 0.0, 0.456, 3.14159_26
Real number with an exponent -1.34E-12, 1.0E+6, 1.234E6
Binary number 2#1111_1111, 2#11100000
Octal number 8#377(decimal 255) 8#340(decimal 224)
Hexadecimal number 16#FF(decimal 255) 16#E0(decimal 224)
BOOL data 0, 1, TRUE, FALSE

1. Numeric data type


▷ There are integer and real numbers.
▷ Discontinuous underline (_) can be placed between numeric characters; and it doesn’t have any meaning.
▷ Decimal complies with general decimal data type expression and if there is a decimal point, they are real numbers.
▷ In case of expressing exponent, you can use plus/minus signs can be used. The letter ‘E’ standing for the exponent does
not distinguish capitals from small letters.

▷ When using real numbers with exponents, the followings are not allowed.
Ex) 12E-5 ( × ) 12.0E-5 ( ○ )
▷ Integer includes binary, octal, hexadecimal numbers and decimal, which can be distinguished by placing # in front of

3-1
Chapter3 Common Element

each numerical character.


▷ 0 ~ 9 and A ~ F are used (including small letters a ~ f) in expressing hexadecimal.
▷ There is no need have plus/minus signs in expressing hexadecimal.
▷ Boolean data may be expressed as an integer 0 or 1.

2. Character String
▷ Character string covers all the letters with single quotation marks.
▷ In case of the character string constant and the initialization, the length is limited up to 31 letters.
Ex) ‘CONVEYER’

3. Time data type


Time data types are classified as follow:
▷ Duration data: calculates and controls the elapsed time of a controlling event.
▷ Time of Day and Date data : displays the time of the starting/ending point of a controlling event.

(1) Duration
▷ Duration data starts with the reserved word, 'T#' or 't#'.
▷ Several data types such as date (d), hour (h), minute (m), second (s) and millisecond (ms) must be written in
sequence. Duration data can start with any unit (d,h,m,s and ms). In case of millisecond , the minimum unit can be
omitted but the medium unit between duration units must not be skipped.
▷ Cannot use the underline (_).
▷ Duration data can overflow at the maximum unit, if any, and the data with a decimal point is available except ‘ms’. It
does not exceed T#49d17h2m47s295ms (32bits by ‘ms’ unit)
▷ The data is limited to the third decimal place in the second unit (s).
▷ Decimal point is not available at ‘ms’ unit.
▷ Capital and small letters are both available.

Content Examples

T#14ms, T#14.7s, T#14.7m, T#14.7h


Duration (no underline)
t#14.7d, t#25h15m, t#5d14h12m18s356ms

(2) Time of day and date


▷ There are three types expressing ‘Time of Day and Date’ as follows: Date, Time of Day; Date and Time.

Content Reserved word


Date prefix D#

Time of Day prefix TOD#

Date and time prefix DT#

▷ The data of starting point is January 1, 1984.


▷ There's a limit on 'Time of Day’ and ‘Date and Time', which is up to the third decimal place in the ‘ms’ unit.
▷ The overflow is not allowed for all the units when expressing ‘Time of Day’ and ‘Date and Time’.

3-2
Chapter3 Common Element

Content Examples
D#1984-06-25
Date
d#1984-06-25
TOD#15:36:55.36
Time of Day
tod#15:36:55.369
DT#1984-06-25-15:36:55.36
Date and Time
dt#1984-06-25-15:36:55.369

3.2 Data Type


Data has a data type showing its character.

3.2.1 Basic Data Type


Motion control module supports the following basic data types.

Size
No. Reserved Word Data Type (bits) Range
1 SINT Short Integer 8 -128 ~ 127
2 INT Integer 16 -32,768 ~ 32,767
3 DINT Double Integer 32 -2,147,483,648 ~ 2,147,483,647
4 LINT Long Integer 64 -263 ~ 263-1
5 USINT Unsigned Short Integer 8 0 ~ 255
6 UINT Unsigned Integer 16 0 ~ 65,535
7 UDINT Unsigned Double Integer 32 0 ~ 4,294,967,295
8 ULINT Unsigned Long Integer 64 0 ~ 264-1
-3.402823466e+038 ~ -1.175494351e-038
9 REAL Real Numbers 32 or 0 or
1.175494351e-038 ~ 3.402823466e+038
-1.7976931348623157e+308 ~
-2.2250738585072014e-308
10 LREAL Long Real Numbers 64
or 0 or 2.2250738585072014e-308 ~
1.7976931348623157e+308
11 TIME Duration 32 T#0S ~ T#49D17H2M47S295MS
12 DATE Date 16 D#1984-01-01 ~ D#2163-6-6
13 TIME_OF_DAY Time Of Day 32 TOD#00:00:00 ~ TOD#23:59:59.999
DT#1984-01-01-00:00:00 ~
14 DATE_AND_TIME Date and Time of Day 64
DT#2163-12-31-23:59:59.999
15 STRING Character String 32*8 -
16 BOOL Boolean 1 0,1
17 BYTE Bit String of Length 8 8 16#0 ~ 16#FF
18 WORD Bit String of Length 16 16 16#0 ~ 16#FFFF
19 DWORD Bit String of Length 32 32 16#0 ~ 16#FFFFFFFF
20 LWORD Bit String of Length 64 64 16#0 ~ 16#FFFFFFFFFFFFFFFF

3-3
Chapter3 Common Element

3.2.2 Data Type Hierarchy Chart


Data types used in XGI/XGR/XEC PLC are as follows:

ANY

ANY_NUM ANY_BIT ANY_STRING ANY_DATE TIME

ANY_REAL ANY_INT LWORD DATE_AND_TIME


DWORD DATE
WORD TIME_OF_DAY
REAL LINT BYTE
LREAL DINT BOOL
INT
SINT
ULINT
UDINT
UINT
USINT

▷ Data expressed as ANY_NUM includes LREAL, REAL, LINT, DINT, INT, SINT, ULINT, UDINT, UINT and USINT.
▷ For example, if a data type is expressed as ANY_BIT, it can use one of the following data types: LWORD, DWORD, WORD,
BYTE and BOOL.

3.2.3 Initial Value


If an initial value of data is not assigned, it is automatically assigned as follows.

Data Type Initial Value


SINT, INT, DINT, LINT 0
USINT, UINT, UDINT, ULINT 0
BOOL, BYTE, WORD, DWORD, LWORD 0
REAL, LREAL 0.0
TIME T#0s
DATE D#1984-01-01
TIME_OF_DAY TOD#00:00:00
DATE_AND_TIME DT#1984-01-01-00:00:00
STRING ' ' (empty string)

3-4
Chapter3 Common Element

3.2.4 Data Type Structure

# Bit String
BOOL
1 bit, range: 0, 1
7 0
USINT
8 bit , range: 2#0000_0000 ~ 2#1111_1111, 16#00 ~ 16#FF
15 87 0
WORD
16 bit, range: 2#0000_0000 _0000_0000 ~ 2#1111_1111_1111_1111 16#0000 ~ 16#FFFF
31 16 15 0
DWORD
32 bit, range: 2#0000_...000 ~ 2#1111_...111 16#00000000 ~ 16#FFFFFFFF
63 32 31 0
LWORD
64 bit, range: 2#0000_...000 ~ 2#1111_...111, 16#0000000000000000 ~ 16#FFFFFFFFFFFFFFFF

# Unsigned Integer
7 0
USINT
8 bit , range: 0 ~ 255
15 87 0
UINT
16 bit, range: 0 ~ 65,535
31 16 15 0
UDINT
32 bit, range: 0 ~ 4,294,967,295
63 32 31 0
ULINT
64 bit, range: 0 ~ 264-1

# Integer (negative number is expressed as 2's complement)


7 0
SINT
8 bit, range: -128 ~ 127
15 87 0
INT
16 bit, range: -32,768 ~ 32,767
31 16 15 0
DINT
32 bit. range: -2,147,483,648 ~ 2,147,483,647
63 32 31 0
LINT
64 bit, range: -263 ~ 263-1

3-5
Chapter3 Common Element

# Real (based on the IEEE Standard 754-1984)


31 30 23 22 0
REAL S Exponent Fraction
32 bit, range: 1.401298E-45 ~ 3.402823E38
63 62 52 51 0
LREAL S Exponent Fraction
64 bit, range: 4.9406564E-324 ~ 1.7976931E308

- S: sign (0: positive number; 1: negative number)

- Exponent: exponent of 2(2e-127: e=b30b29...b23, e=b62b61...b52 )


- Fraction: a decimal fraction (Fraction: f=b22b21...b0, f=b51b50...b0 )

# Time
31 0
TIME
32 bit, range: 0 ~ 4,294,967,295ms ,T#49d17h2m47s295ms

# Date
63 48 47 32 31 0
DT 0000000000000000 TOD DATE
64 bit, range: DT#1984-01-01-00:00:00 ~ DT#2163-12-31-23:59:59.999
31 16 15 0
TOD
32 bit, range: TOD#00:00:00 ~ TOD#23:59:59.999

15 87 0
DATE
16 bit, range: D#1984-01-01 ~ D#2163-6-6

#BCD
7 43 0
1 0
BYTE 10 10
8 bit, range: 0 ~ 99
15 87 0
3 2 1 0
WORD 10 10 10 10
16 bit, range: 0 ~ 9999
31 24 23 16 15 87 0
7 6 5 4 3 2 1 0
DWORD 10 10 10 10 10 10 10 10
32 bit, range: 0 ~ 99,999,999
63 48 47 32 31 16 15 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
LWORD 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
64 bit, range: 0 ~ 9,999,999,999,999,999

3-6
Chapter3 Common Element

3.3 Variable
A variable has its own value and refer to data used in a program. ‘Variable’ refer to something that can vary such as an input/output
of PLC, memory, and so on.

3.3.1 Variable Expression


▷ Variables can be expressed in two ways: by giving a name to a data element using an identifier (Variable by Identifier) or by
directly assigning a memory address or an input/output of PLC to a data element (Direct Variable).
▷ A variable by identifier must be unique within its ‘effective scope’ (program area where the variable was declared) in order to
distinguish it from other variables.
▷ A direct variable is expressed as one, which starts with the percent sign (%) followed by the ‘location prefix’, a prefix of the data
size, and more than one unsigned integer numbers divided by a period (.). The prefixes are shown as follows.

Location prefix
No. Prefix Meaning
1 I Input Location
2 Q Output Location
3 G G Area Position of Internal Memory (Memory Location)
4 D D Area Position of Internal Memory (Memory Location)
5 M M Area Position of Internal Memory (Memory Location)
6 P P Area Position of Internal Memory (Memory Location)

Size prefix
No. Prefix Meaning
1 X 1 bit size
2 None 1 bit size
3 B 1 byte (8 bits) size
4 W 1 word (16 bits) size
5 D 1 double word (32 bits) size
6 L 1 long word (64 bits) size

Expression format
%[Location Prefix][Size Prefix] n1.n2.n3
Number I, Q M, R, W
0: Internal I/O The n1th data according to [size prefix]
n1
1~36: Axis number (starting from “0”)

The n2th data according to [size prefix] (starting The n2th data of the n1th data (starting
n2
from “0”) from “0”) : available to omit

3-7
Chapter3 Common Element

Examples
%QX0.1 1st output of Internal I/O (1 bit)
%IW2.1 1st word input of no.2 Axis (16bits)
%MD48 48th double word memory
%MW40.3 3rd bit of 40th word memory
(internal memory does not have a base or a slot number)

▷ Small alphabets are not allowed as a prefix.


▷ A variable without a size prefix is treated as 1 bit.
▷ Direct variables are available to use without a variable declaration.

3.3.2 Variable Declaration


▷ Program elements (programs, functions, function blocks, and so on) have parts that can be declared to edit their variables.
▷ Variables must be declared before using them in the program elements.
▷ The contents of a variable declaration are as follows.

1. Variable types

The variable type defines how to declare variables.


Variable types Description
VAR General variable available to read/write
VAR_CONSTANT Read only variable
VAR_EXTERNAL Declaration to use the variable declared as VAR_GLOBAL
VAR_EXTERNAL_CONSTAN Declaration to use the variable declared as VAR_GLOBAL
T Read only variable

2. Data type
Data type sets a variable data type.

3. Memory allocation
Memory allocation assigns memory for a variable.
Auto ---- The compiler sets a variable location automatically (Automatic Allocation Variable).
Assign (AT) ---- A user sets a location of variable, using a direct variable (Direct Variable).

3-8
Chapter3 Common Element

Reference
The location of Automatic Allocation Variable is not fixed. If variable VAL1, for example, was declared as BOOL, it is not fixed in
the internal memory; the compiler and linker fix its location. If the program is compiled again after modification, the location may
change.
The merit of Automatic Allocation Variable is that users do not have to care the location of the internal variables because its
location is not overlapped as long as a variable name is different from others.
Use of Direct Variable is not recommended except %Ⅰand % Q because the location of a variable is fixed and it could be
overlapped in a wrong-used case.

▷ Initial Value Assignment: assigns an initial value. A variable is set with an initial value as shown in section ‘3.2.3. Initial Value’ if
not assigned.

Reference
The initial value is not assigned when it comes to VAR_EXTERNAL.
You can not input the initial value to the variables to which G area, D area, M area is allocated during variable declaration.

▷ For the variable whose data value should be retained even after the PLC’s power is shut off, you need to use the Retention
function in case of a blackout. You can apply this function by setting a checkbox based on the below instructions.
1) ‘Retention Variable’ retains its data when the system is set as ‘Warm Restart’.
2) In case of ‘Cold Restart’, variables are initialized as the initial values set by users or the basic initial values.

▷ Variables, which are not declared as VAR_RETAIN, must be initialized as the initial values set by a user or the basic initial
values in case of ‘Warm Restart’ or ‘Cold Restart’.

▷ Users can declare variables 'Array' with Elementary Data Type. When declaring the Array Variable, users are supposed to set
Data Type and Array Size; ‘STRING’ type among Elementary Data Types is not allowed.

▷ Effective scope of variable declaration, the area which is available to use the variable, is limited to the program where
variables are declared. And users can't use variables declared in other program in the above area. On the contrary, users
can get an access to 'Global Variable' from other program elements by declaring it as 'VAR_EXTERNAL'.

3-9
Chapter3 Common Element

Examples of Variable Declaration


Variable Name Variable Kind Data Type Initial Value Memory Allocation
I_VAL VAR INT 1234 Auto
BIPOLAR VAR_RETAIN REAL - Auto
LIMIT_SW VAR BOOL - %MX10
GLO_SW VAR_EXTERNAL DWORD - Auto
READ_BUF VAR ARRAY OF INT[10] - Auto

3.3.3 Reserved Variable


▷ ‘Reserved Variable’ refers to variables previously declared in the system. These variables are used for special purposes and
users cannot declare variables with the name of the Reserved Variables.
▷ Users can use the reserved variables without variable declaration.
▷ For additional information, refer to Appendix 2 : Flag List(XGI) Summary of Special internal flag(F) and XGI-CPUU User’s
Manual.

3.3.4 Reserved Word


Reserved words are previously defined words to use in the system. And these reserved words cannot be used as an identifier.

Reserved words
ACTION ... END_ACTION
ARRAY ... OF
AT
CASE ... OF ... ELSE ... END_CASE
CONFIGURATION ... END_CONFIGURATION
Name of data type
DATE#, D#DATE_AND_TIME#, DT#
EXIT
FOR ... TO ... BY ... DO ... END_FOR
FUNCTION ... END_FUNCTION
FUNCTION_BLOCK ... END_FUNCTION_BLOCK
Name of function block
IF ... THEN ... ELSIF ... ELSE ... END_IF
OK
Operator (IL language)
Operator (ST language)
PROGRAM
PROGRAM ... END_PROGRAM
REPEAT ... UNTIL ... END_REPEAT
RESOURCE ... END_RESOURCE
RETAIN
RETURN
STEP ... END_STEP
STRUCTURE ... END_STRUCTURE
T#
TASK ... WITH
TIME_OF_DAY#, TOD#
TRANSITION ... FROM... TO ... END_TRANSITION

3-10
Chapter3 Common Element

Reserved words
TYPE ... END_TYPE
VAR ... END_VAR
VAR_INPUT ... END_VAR
VAR_OUTPUT ... END_VAR
VAR_IN_OUT ... END_VAR
VAR_EXTERNAL ... END_VAR
VAR_ACCESS ... END_VAR
VAR_GLOBAL ... END_VAR
WHILE ... DO ... END_WHILE
WITH

3.4 Function Selection

3.4.1 Internally Determined Function


▷ Although a function has one name, a command in which a variety of variable types can be entered is divided into various
commands, depending on available variables. For instance, ADD can be divided and processed in various kinds, depending
on the number of input defined or I/O variable types. If you select in the following figure, the function shown in a ladder program
is ADD but ADD2_SINT function executes internally.

3-11
Chapter3 Common Element

▷ An internally used function automatically selects in XG-PM, depending on a user-selected variable type. For instance, two
inputs are selected among ADD function and I/O variables are selected as DINT, ADD2_DINT is selected as described above.
▷ Although IEC allows an operation between and among same types, XG-PM has a “Strict type check” (ViewProgram Check)
option to allow an operation if its operand sizes (BYTE, WORD, DWORD, and LWORD) are same.

3-12
Chapter4 LD (Ladder Digagram)

Chapter 4 LD (Ladder Diagram)

4.1 Introduction
▷ LD program is the graphical representation of a PLC program using symbols such as a coil or contact used in relay logic
diagram.
▷ Configuration

rung
Line comment
No.
Line0 This is an example of LD program function
Function
THERE
START TON block SIGN ADD
Label UP
Line1 IN Q EN EN0 ( )

Line2 SET_TIME PT ET CUR_TIME DATA1 IN1 OUT DATA3 coil

rung Line3 DATA2 IN2


%I0.0.0 STOP
vertical jump label
Line4
Horizontal link
DOWN contact link
THERE
Line5

bus line

4.2 Bus
▷ Bus line as a power line is vertically placed on either sides of a LD graphic diagram.

No Symbol Name Description

1 Left bus line Its value is always 1 (BOOL).

2 Right bus line The value is not fixed.

4-1
Chapter4 LD (Ladder Diagram)

4.3 Link
▷ The value (BOOL 1) of left bus line transmits to the right side by the ladder diagram. The line that transmits value is called as
'power flow line' or 'connection line' which is connected to a contact or coil. Power flow line has always a BOOL value and there
is only one power flow line in one rung that is connected by lines.
▷ There are two types of a connection line of LD: horizontal connection line and vertical connection line.

No. Symbol Name Description

1 Horizontal connection line It transmits the left side value to the right side

It is a logical OR of horizontal connection lines of its left


2 Vertical connection line
side

4.4 Contact
▷ 'Contact' transmits a value to the right horizontal connection line, which is the result of logical AND operation of : the state of left
horizontal connection line, Boolean input/output related to the current contact or memory variables. It does not change the
value of variable related to the contact. Standard contact symbols are as follows.

Static contact
No Symbol Name Description
When the BOOL variable (marked with ***) is on, which
***
Normally open contact transmits the state of the left connection line to the right
1 connection line. Otherwise, the state of the right
connection line is OFF.

When the BOOL variable (marked with ***) is off, which


***
transmits the state of the left connection line to the right
2 Normally closed contact
connection line. Otherwise, the state of the right
connection line is off.

4-2
Chapter4 LD (Ladder Digagram)

State transition-sensing contact


No Symbol Name Description

*** When the BOOL variable (marked with ***), which was
Positive Transition-Sensing
3 off in the previous scan is on, it maintains on state during
Contact
one scan (current scan).
P

*** When the BOOL variable (marked with ***), which was
Negative Transition-
4 on in the previous scan is off, it maintains on state during
Sensing Contact
just one scan (current scan).
N

4.5 Coil
▷ The coil stores the state of the left connection line or the processing result of state transition in the associated BOOL variable.
Standard coil symbols are as follows.

▷ Coils are placed in the right extreme of LD, and its right is a right bus line.

Momentary Coils
No. Symbol Name Description

***
Put the state of left connection line into the associated BOOL
Coil
1 ( ) variable (marked with ***).

Put the negated value of the state of left connection line into the
***
associated BOOL variable (marked with ***).
Negated Coil
2 ( ) That is, if the state of left connection line is off, the associated
BOOL variable is on and if the state of left connection line is on,
the associated BOOL variable is off.

Latched Coils
No. Symbol Name Description

*** It sets the associated BOOL variable (marked with ***) to on


Set (Latch) Coil when the left link is in the on state and remains set until reset by
3 (S)
a Reset coil.

*** It sets the associated BOOL variable (marked with ***) to off
4 Reset (Unlatch) Coil when the left link is in the on state and remains reset until set by
(R)
a Set coil.

4-3
Chapter4 LD (Ladder Diagram)

State Transition-sensing Coils


No. Symbol Name Description

*** If the state of its left connection that was off in the previous scan
Positive Transition-
5 is on in the current scan, the associated BOOL variable (marked
(P) Sensing Coil
with ***) is on during the current scan.

*** If the state of its left connection that was on in the previous scan
Negative Transition-
6 is off in the current scan, the associated BOOL variable (marked
(N) Sensing Coil
with ***) is on during the current scan.

4.6 Calling of Function and Function Block


▷ The connection to a function or a function block is done by entering suitable data or variable to their input/output.

Example

SEL CLK_U CTUD


EN EN0 CU QU FULL

START G ET REG1 CLK_D CD CD STOP

VAL1 IN0 RESET R CV DOWN

VAL2 IN1 SWITCH LD

PLAN PV
Function

Function
block

▷ To enable power flow inside function or function block, it must contain at least one BOOL-type input and BOOL-type output.
EN and ENO are BOOL-type input/output in a function while a data type of the first input and first output are BOOL-type in a
function block.

4-4
Chapter4 LD (Ladder Digagram)

Example
Bool type input/output
of function

ABS EQ LIMIT
EN EN0 EN EN0 EN EN0

IN1 OUT IN1 OUT MN OUT

IN2 IN

MX

T1 F1 C2

TOF F_TRIG CTU


IN Q CLK Q CU Q

PT ET R CV

PV

Bool type input/output of


function block

▷ Conventionally, the ladder logic connecting a Boolean input to a function is called EN and the corresponding output Boolean is
called ENO, or enable out. If the value of EN is 1, then the function executes, otherwise it is do not execute. In all cases, the
value of EN copies the output ENO.
▷ If an error occurs in the execution of a function, the function is responsible to set ENO to false (BOOL 0). EN is connected to
the power flow line but ENO does not have to be connected to it. However, when connecting the power flow line to the function
output instead of the ENO, the output data type must be a BOOL type.
▷ When connecting the power flow line to the function output, do not connect anything to the ENO output. All the inputs of a
function are assigned by entering its data at the left side of the function. The output of a function is stored at the output variable
on its right side.
▷ Assignment of input of a function block in a LD is the same as that of a function. The name of function block is the ‘instance’
name, which can be user-defined and must be unique to LD in which the function block appears.
▷ You do not have to assign output variables because they are in the instance. If a function block is connected to the power flow
line, it is always executes because there is neither EN nor ENO in it.
▷ Therefore, use Jump (-->>) to determine whether or not to execute a function block according to the logic result. When
connecting the power flow line to the function block, connect it to the input/output whose data type is BOOL.

4-5
Chapter4 LD (Ladder Diagram)

Example

CLK REG1 SWITCH ABS EMERGE PLACE1


Line1 N P EN EN0
START CON1
Line2 DOWN IN1 OUT D0

Line3
PLACE2
Line4

T2
PLACE1 START
TON
Line5 IN Q ( )

Line6 TEST PT ET

Line7

PLACE2 CON2 STOP


Line8 ( )

▷ You can place a function or a function block in any place of LD. You can create a program by connecting the power flow line to
the output and then insert the contact to it.

Example

S1
CLK ADD RESET START VAL1 REG1 CON1 EMERGE
SR
EN EN0 P S1 Q1 ( )
STOP VAL2 CON2
PLAN IN1 OUT D0 N REG1 R

DOWN IN2

T4
CON2 SWITCH
TOF
IN Q

TEST PT ET

4-6
Chapter4 LD (Ladder Digagram)

▷ Only one power line connects to a function or a function block.

Example

Correct

EQ REG1 EQ
EN EN0 EN EN0
STOP START
D0 IN1 OUT D0 IN1 OUT

DOWN IN2 DOWN IN2


Wrong: only one
power flow line can
be connected
EQ SWITCH START EQ
EN EN0 EN EN0
STOP REG1
D0 IN1 OUT START IN1 OUT

DOWN IN2 DOWN IN2

Correct

4-7
Chapter4 LD (Ladder Diagram)

4-8
Chapter5 Function and Function Block

Chapter 5 Function and Function Block


It’s a list of function and function block. For each function and function block, please refer to the next chapters (Ch .6/7 Basic/Application
Functions and Ch 8/9 Basic/Application Function Blocks). For more details on the Motion Control Function Block, refer to Chap.6
Command of the Motion Control Module manual.

5.1 Functions

5.1.1 Type Conversion Function


It converts each input data type into an output data type.

Function Group Function Input data type Output data type Remarks
REAL_TO_SINT REAL SINT -
REAL_TO_INT REAL INT -
REAL_TO_DINT REAL DINT -
REAL_TO_LINT REAL LINT -
REAL_TO_USINT REAL USINT -
REAL_TO_***
REAL_TO_UINT REAL UINT -
REAL_TO_UDINT REAL UDINT -
REAL_TO_ULINT REAL ULINT -
REAL_TO_DWORD REAL DWORD -
REAL_TO_LREAL REAL LREAL -
LREAL_TO_SINT LREAL SINT -
LREAL_TO_INT LREAL INT -
LREAL_TO_DINT LREAL DINT -
LREAL_TO_LINT LREAL LINT -
LREAL_TO_USINT LREAL USINT -
LREAL_TO_***
LREAL_TO_UINT LREAL UINT -
LREAL_TO_UDINT LREAL UDINT -
LREAL_TO_ULINT LREAL ULINT -
LREAL_TO_LWORD LREAL LWORD -
LREAL_TO_REAL LREAL REAL -
SINT_TO_INT SINT INT -
SINT_TO_DINT SINT DINT -
SINT_TO_LINT SINT LINT -
SINT_TO_USINT SINT USINT -
SINT_TO_UINT SINT UINT -
SINT_TO_UDINT SINT UDINT -
SINT_TO_***
SINT_TO_ULINT SINT ULINT -
SINT_TO_BOOL SINT BOOL -
SINT_TO_BYTE SINT BYTE -
SINT_TO_WORD SINT WORD -
SINT_TO_DWORD SINT DWORD -
SINT_TO_LWORD SINT LWORD -

5-1
Chapter5 Function and Function Block

Function Group Function Input data type Output data type Remarks
SINT_TO_REAL SINT REAL -
SINT_TO_LREAL SINT LREAL -
INT_TO_SINT INT SINT -
INT_TO_DINT INT DINT -
INT_TO_LINT INT LINT -
INT_TO_USINT INT USINT -
INT_TO_UINT INT UINT -
INT_TO_UDINT INT UDINT -
INT_TO_ULINT INT ULINT -
INT_TO_***
INT_TO_BOOL INT BOOL -
INT_TO_BYTE INT BYTE -
INT_TO_WORD INT WORD -
INT_TO_DWORD INT DWORD -
INT_TO_LWORD INT LWORD -
INT_TO_REAL INT REAL -
INT_TO_LREAL INT LREAL -
DINT_TO_SINT DINT SINT -
DINT_TO_INT DINT INT -
DINT_TO_LINT DINT LINT -
DINT_TO_USINT DINT USINT -
DINT_TO_UINT DINT UINT -
DINT_TO_UDINT DINT UDINT -
DINT_TO_ULINT DINT ULINT -
DINT_TO_***
DINT_TO_BOOL DINT BOOL -
DINT_TO_BYTE DINT BYTE -
DINT_TO_WORD DINT WORD -
DINT_TO_DWORD DINT DWORD -
DINT_TO_LWORD DINT LWORD -
DINT_TO_REAL DINT REAL -
DINT_TO_LREAL DINT LREAL -
LINT_TO_SINT LINT SINT -
LINT_TO_INT LINT INT -
LINT_TO_DINT LINT DINT -
LINT_TO_USINT LINT USINT -
LINT_TO_UINT LINT UINT -
LINT_TO_UDINT LINT UDINT -
LINT_TO_ULINT LINT ULINT -
LINT_TO_***
LINT_TO_BOOL LINT BOOL -
LINT_TO_BYTE LINT BYTE -
LINT_TO_WORD LINT WORD -
LINT_TO_DWORD LINT DWORD -
LINT_TO_LWORD LINT LWORD -
LINT_TO_REAL LINT REAL -
LINT_TO_LREAL LINT LREAL -
USINT_TO_SINT USINT SINT -
USINT_TO_***
USINT_TO_INT USINT INT -

5-2
Chapter5 Function and Function Block

Function Group Function Input data type Output data type Remarks
USINT_TO_DINT USINT DINT -
USINT_TO_LINT USINT LINT -
USINT_TO_UINT USINT UINT -
USINT_TO_UDINT USINT UDINT -
USINT_TO_ULINT USINT ULINT -
USINT_TO_BOOL USINT BOOL -
USINT_TO_BYTE USINT BYTE -
USINT_TO_WORD USINT WORD -
USINT_TO_DWORD USINT DWORD -
USINT_TO_LWORD USINT LWORD -
USINT_TO_REAL USINT REAL -
USINT_TO_LREAL USINT LREAL -
UINT_TO_SINT UINT SINT -
UINT_TO_INT UINT INT -
UINT_TO_DINT UINT DINT -
UINT_TO_LINT UINT LINT -
UINT_TO_USINT UINT USINT -
UINT_TO_UDINT UINT UDINT -
UINT_TO_ULINT UINT ULINT -
UINT_TO_*** UINT_TO_BOOL UINT BOOL -
UINT_TO_BYTE UINT BYTE -
UINT_TO_WORD UINT WORD -
UINT_TO_DWORD UINT DWORD -
UINT_TO_LWORD UINT LWORD -
UINT_TO_REAL UINT REAL -
UINT_TO_LREAL UINT LREAL -
UINT_TO_DATE UINT DATE -
UDINT_TO_SINT UDINT SINT -
UDINT_TO_INT UDINT INT -
UDINT_TO_DINT UDINT DINT -
UDINT_TO_LINT UDINT LINT -
UDINT_TO_USINT UDINT USINT -
UDINT_TO_UINT UDINT UINT -
UDINT_TO_ULINT UDINT ULINT -
UDINT_TO_BOOL UDINT BOOL -
UDINT_TO_***
UDINT_TO_BYTE UDINT BYTE -
UDINT_TO_WORD UDINT WORD -
UDINT_TO_DWORD UDINT DWORD -
UDINT_TO_LWORD UDINT LWORD -
UDINT_TO_REAL UDINT REAL -
UDINT_TO_LREAL UDINT LREAL -
UDINT_TO_TOD UDINT TOD -
UDINT_TO_TIME UDINT TIME -
ULINT_TO_SINT ULINT SINT -
ULINT_TO_*** ULINT_TO_INT ULINT INT -
ULINT_TO_DINT ULINT DINT -

5-3
Chapter5 Function and Function Block

Function Group Function Input data type Output data type Remarks
ULINT_TO_LINT ULINT LINT -
ULINT_TO_USINT ULINT USINT -
ULINT_TO_UINT ULINT UINT -
ULINT_TO_UDINT ULINT UDINT -
ULINT_TO_BOOL ULINT BOOL -
ULINT_TO_BYTE ULINT BYTE -
ULINT_TO_WORD ULINT WORD -
ULINT_TO_DWORD ULINT DWORD -
ULINT_TO_LWORD ULINT LWORD -
ULINT_TO_REAL ULINT REAL -
ULINT_TO_LREAL ULINT LREAL -
BOOL_TO_SINT BOOL SINT -
BOOL_TO_INT BOOL INT -
BOOL_TO_DINT BOOL DINT -
BOOL_TO_LINT BOOL LINT -
BOOL_TO_USINT BOOL USINT -
BOOL_TO_*** BOOL_TO_UINT BOOL UINT -
BOOL_TO_UDINT BOOL UDINT -
BOOL_TO_ULINT BOOL ULINT -
BOOL_TO_BYTE BOOL BYTE -
BOOL_TO_WORD BOOL WORD -
BOOL_TO_DWORD BOOL DWORD -
BOOL_TO_LWORD BOOL LWORD -
BYTE_TO_SINT BYTE SINT -
BYTE_TO_INT BYTE INT -
BYTE_TO_DINT BYTE DINT -
BYTE_TO_LINT BYTE LINT -
BYTE_TO_USINT BYTE USINT -
BYTE_TO_UINT BYTE UINT -
BYTE_TO_***
BYTE_TO_UDINT BYTE UDINT -
BYTE_TO_ULINT BYTE ULINT -
BYTE_TO_BOOL BYTE BOOL -
BYTE_TO_WORD BYTE WORD -
BYTE_TO_DWORD BYTE DWORD -
BYTE_TO_LWORD BYTE LWORD -
WORD_TO_SINT WORD SINT -
WORD_TO_INT WORD INT -
WORD_TO_DINT WORD DINT -
WORD_TO_LINT WORD LINT -
WORD_TO_USINT WORD USINT -
WORD_TO_*** WORD_TO_UINT WORD UINT -
WORD_TO_UDINT WORD UDINT -
WORD_TO_ULINT WORD ULINT -
WORD_TO_BOOL WORD BOOL -
WORD_TO_BYTE WORD BYTE -
WORD_TO_DWORD WORD DWORD -

5-4
Chapter5 Function and Function Block

Function Group Function Input data type Output data type Remarks
WORD_TO_LWORD WORD LWORD -
WORD_TO_DATE WORD DATE -
DWORD_TO_SINT DWORD SINT -
DWORD_TO_INT DWORD INT -
DWORD_TO_DINT DWORD DINT -
DWORD_TO_LINT DWORD LINT -
DWORD_TO_USINT DWORD USINT -
DWORD_TO_UINT DWORD UINT -
DWORD_TO_UDINT DWORD UDINT -
DWORD_TO_*** DWORD_TO_ULINT DWORD ULINT -
DWORD_TO_BOOL DWORD BOOL -
DWORD_TO_BYTE DWORD BYTE -
DWORD_TO_WORD DWORD WORD -
DWORD_TO_LWORD DWORD LWORD -
DWORD_TO_REAL DWORD REAL -
DWORD_TO_TIME DWORD TIME -
DWORD_TO_TOD DWORD TOD -
LWORD_TO_SINT LWORD SINT -
LWORD_TO_INT LWORD INT -
LWORD_TO_DINT LWORD DINT -
LWORD_TO_LINT LWORD LINT -
LWORD_TO_USINT LWORD USINT -
LWORD_TO_UINT LWORD UINT -
LWORD_TO_UDINT LWORD UDINT -
LWORD_TO_***
LWORD_TO_ULINT LWORD ULINT -
LWORD_TO_BOOL LWORD BOOL -
LWORD_TO_BYTE LWORD BYTE -
LWORD_TO_WORD LWORD WORD -
LWORD_TO_DWORD LWORD DWORD -
LWORD_TO_LREAL LWORD LREAL -
LWORD_TO_DT LWORD DT -
TIME_TO_UDINT TIME UDINT -
TIME_TO_***
TIME_TO_DWORD TIME DWORD -
DATE_TO_UINT DATE UINT -
DATE_TO_***
DATE_TO_WORD DATE WORD -
-
TOD_TO_UDINT TOD UDINT
TOD_TO_*** -
TOD_TO_DWORD TOD DWORD
-
DT_TO_LWORD DT LWORD
-
DT_TO_*** DT_TO_DATE DT DATE
-
DT_TO_TOD DT TOD

5-5
Chapter5 Function and Function Block

5.1.2 Numerical Operation Function

1. Numerical operation function with one Input


No. Function Function Remarks
General Function
1 ABS Absolute value operation -
2 SQRT Square root operation -
Logarithm
3 LN Natural logarithm operation -
4 LOG Common logarithm Base to 10 operation -
5 EXP Natural exponential operation -
Trigonometric function
6 SIN Sine operation -
7 COS Cosine operation -
8 TAN Tangent operation -
9 ASIN Arc sine operation -
10 ACOS Arc Cosine operation -
11 ATAN Arc Tangent operation -

2. Basic arithmetic function

No. Function Description Remarks


Operation function whose input number (n) can be extended up to 8.
1 ADD Addition (OUT <= IN1 + IN2 + ... + INn) -
2 MUL Multiplication (OUT <= IN1 * IN2 * ... * INn) -
Operation function of which input number is fixed.
3 SUB Subtraction (OUT <= IN1 - IN2) -
4 DIV Division (OUT <= IN1 / IN2) -
5 MOD Calculate remainder (OUT <= IN1 Modulo IN2) -
6 EXPT Exponential operation (OUT <= IN1IN2) -
7 MOVE Copy data (OUT <= IN) -

5.1.3 Angle Convert Function

No. Function Description Remarks


-
1 DEG Convert radian into degree
-
2 RAD Convert degree into radian

5.1.4 Bit Array Function

5-6
Chapter5 Function and Function Block

1. Bit-shift function
No. Function Description Remarks
-
1 SHL Shift input to the left of N bit(the right is filled with 0)
-
2 SHR Shift input to the right of N bit (the left is filled with 0)
-
3 ROL Rotate input to the left of N bit
-
4 ROR Rotate input to the right of N bit

2. Bit operation function

No. Function Description (n can be extended up to 8) Remarks


-
1 AND Logical AND (OUT <= IN1 AND IN2 AND ... AND INn)
-
2 OR Logical OR (OUT <= IN1 OR IN2 OR ... OR INn)
-
3 XOR Exclusive OR (OUT <= IN1 XOR IN2 XOR ... XOR INn)
-
4 NOT Reverse logic (OUT <= NOT IN1)
-
5 XNR Exclusive logic AND (OUT <= IN1 XNR IN2 XNR ... XNR INn)

5.1.5 Selection Function

No. Function Description(n can be extended up to 8) Remarks


-
1 MAX Produces the maximum value among input IN1,...INn
-
2 MIN Produces the minimum value among input IN1,...INn
-
3 LIMIT Limits upper and lower boundaries
-
4 MUX Outputs the Kth input among input IN1,…INn

5.1.6 Data Exchange Function

No. Function Description Remarks


-
1 SWAP Swaps upper data for lower data
-
2 XCHG Exchanges two input data

5.1.7 Comparison Function

No. Function Description (n can be extended up to 8) Remarks

5-7
Chapter5 Function and Function Block

1 ‘Greater than’ comparison


GT -
OUT <= (IN1>IN2) & (IN2>IN3) & ... & (INn-1 > INn)
2 ‘Greater than or equal to’ comparison
GE -
OUT <= (IN1>=IN2) & (IN2>=IN3) & ... & (INn-1 >= INn)
3 ‘Equal to’ comparison
EQ -
OUT <= (IN1=IN2) & (IN2=IN3) & ... & (INn-1 = INn)
4 'Less than or equal to' comparison
LE -
OUT <= (IN1<=IN2) & (IN2<=IN3) & ... & (INn-1 <= INn)
5 ‘Less than’ comparison
LT -
OUT <= (IN1<IN2) & (IN2<IN3) & ... & (INn-1 < INn)
6 ‘Not equal to’ comparison
NE -
OUT <= (IN1<>IN2) & (IN2<>IN3) & ... & (INn-1 <> INn)

5.1.8 Date And Time Of Day Function

No. Function Description Remarks


-
1 ADD_TIME Add time (time/time of day/date and time addition)
-
2 SUB_TIME Subtract time (time/time of day/date and time subtraction)
-
SUB_DATE Calculate time by subtracting date from date
-
SUB_TOD Calculate time by subtracting TOD from TOD
-
SUB_DT Calculate time by subtracting DT from DT
-
3 CONCAT_TIME Concatenate date to make TOD

5.1.9 Data Manipulation Function

No. Function Description Remarks


-
1 BIT_BYTE Combine 8 bits into one BYTE
-
2 BYTE_BIT Divide one BYTE into 8 bits
-
3 BYTE_WORD Combine two bytes into one WORD
-
4 WORD_BYTE Divide one WORD into two bytes
-
5 WORD_DWORD Combine two WORD data into DWORD
-
6 DWORD_WORD Divide DWORD into 2 WORD data
-
7 DWORD_LWORD Combine two DWORD data into LWORD
-
8 LWORD_DWORD Divide LWORD into two DWORD data
9 DEC Decreases data by one.
10 DECO Activates(On) the designated bit position
11 ENCO Outputs the activated(On) bit position as number
12 INC Increases the IN data by one

5-8
Chapter5 Function and Function Block

5.2 Basic Function Block

5.2.1 Bistable Function Block

No. Function Block Description Remarks


-
1 SR Set preference bistable
-
2 RS Reset preference bistable

5.2.2 Edge Detection Function Block

No. Function Block Description Remarks


-
1 R_TRIG Rising edge detector
-
2 F_TRIG Falling edge detector
-
3 FF Reverse output if input condition rises

5.2.3 Counter

No. Function Block Description Remarks


1 Up Counter
CTU_*** -
INT,DINT,LINT,UINT,UDINT,ULINT
2 Down Counter
CTD_*** -
INT,DINT,LINT,UINT,UDINT,ULINT
3 Up Down Counter
CTUD_*** -
INT,DINT,LINT,UINT,UDINT,ULINT
4 CTR Ring Counter -

5.2.4 Timer

No. Function Block Description Remarks


-
1 TP Pulse Timer
-
2 TON On-Delay Timer
-
3 TOF Off-Delay Timer
-
4 TMR Integrating Timer
-
5 TP_RST TP with reset
-
6 TRTG Retriggerable Timer

5-9
Chapter5 Function and Function Block

-
7 TOF_RST TOF with reset
-
8 TON_UINT TON with integer setting
-
9 TOF_UINT TOF with integer setting
-
10 TP_UINT TP with integer setting
-
11 TMR_UINT TMR with integer setting
-
12 TMR_FLK Blink timer
-
13 TRTG_UINT Integer setting retriggerable timer

5.3 Expanded Function


No. Function Block Description Remarks
-
1 FOR
Repeat a block of FOR ~ NEXT n times -
2 NEXT
-
3 BREAK Escape a block of FOR ~ NEXT
-
4 CALL Call a SBRT routine
-
5 SBRT Assign a routine to be called by the CALL function
-
6 RET RETURN
-
7 JMP Jump to a place of LABLE
-
8 INIT_DONE Terminate an initial task
-
9 END Terminate a program

5.4 Motion Control Function Block


No. Function Block Description Remarks
Single-Axis Motion Instructions
1 MC_Power Servo on/off
2 MC_Home Perform the search home
3 MC_Stop Stop immediately
4 MC_Halt Stop
5 MC_MoveAbsolute Absolute position operation
6 MC_MoveRelative Incremental position operation
7 MC_MoveAdditive Additive position operation

5-10
Chapter5 Function and Function Block

No. Function Block Description Remarks


8 MC_MoveVelocity Designated speed operation
Designated speed operation after absolute position
9 MC_MoveContinuousAbsolute
operation
Designated speed operation after incremental position
10 MC_MoveContinuousRelative
operation
11 MC_TorqueControl Torque control operation
12 MC_SetPosition Current position setting
13 MC_SetOverride Speed/Acceleration override
14 MC_ReadParameter Reads parameter
15 MC_WriteParameter Writes parameter
16 MC_Reset Reset axis error
17 MC_TouchProbe Touch probe function
18 MC_AbortTrigger Abort trigger events
19 LS_Connect Connect servo drives
20 LS_DisConnect Disconnect servo drives
21 LS_ReadServoParameter Read servo parameters
22 LS_WriteServoParameter Write servo parameters
23 LS_EncoderPreset Encoder preset
24 LS_Jog JOG operation

Multi-Axis Motion Instructions


25 MC_CamIn CAM operation
26 MC_CamOut CAM operation stop
27 MC_GearIn Electrical gear operation
28 MC_GearOut Electrical gear stop
28 MC_GearInPos Position designated electrical gear operation

Group-Axis Motion Instructions


29 MC_AddAxisToGroup Adds axis to a group
30 MC_RemoveAxisFromGroup Removes axis from a group
31 MC_UngroupAllAxes Removes all axes from a group
32 MC_GroupEnable Enable a group
33 MC_GroupDisable Disable a group
34 MC_GroupHome Group home return operation
35 MC_GroupSetPosition Group current position setting
36 MC_GroupStop Group immediate stop
37 MC_GroupHalt Group stop
38 MC_GroupReset Resets a group error
39 MC_MoveLinearAbsolute Group absolute position linear interpolation operation

5-11
Chapter5 Function and Function Block

No. Function Block Description Remarks


Group incremental position linear interpolation
40 MC_MoveLinearRelative
operation
41 MC_MoveCircularAbsolute Group absolute position circular interpolation operation
Group incremental position circular interpolation
42 MC_MoveCircularRelative
operation

5-12
Chapter6 Basic Function

Chapter 6 Basic Function


This chapter describes basic functions.

ABS

Absolute value operation


ABS Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1

ABS IN: input value of absolute value operation


BOOL EN ENO BOOL

ANY_NUM IN OUT ANY_NUM Output ENO: 1


OUT: absolute value
IN, OUT should be the same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. Output the absolute value of IN as ‘OUT’.


OUT = IN
2. X’s absolute value, │X│;
A. If X≥0, │X│= X,
B. If X<0, │X│= -X.

■ Flag

Flag Description

_ERR If IN value is (-)min value, _ERR and _LER flags are set.
ex) if data type is SINT and IN and value is -128, an error is activated.

6-1
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

ABS_Value := ABS(EN:=%GX0, IN:=Value);

(1) If the transition condition (%GX0) is on, ABS function executes.


(2) If VALUE = -7, ABS_VALUE = -7 = 7.
If VALUE = 200, ABS_VALUE = 200 = 200.
(3) The negative number of INT type is represented as the 2's compliment form (refer to 3.2.4. Data type structure)

INPUT (IN) : VALUE (INT)= -7 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 (16#FFF9)

OUTPUT (OUT) : ABS_VALUE (INT)= 7 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 (16#0007)

6-2
Chapter6 Basic Function

1.1. ACOS

Arc Cosine operation


ACOS Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input value of Arc Cosine operation
ACOS
BOOL EN ENO BOOL
Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: Arc Cosine (radian)
IN, OUT must be the same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It converts input IN into its Arc Cosine value and produces output OUT. The output range is between 0 and π.
OUT = ACOS (IN)

■ Flag

Flag Description
_ERR Unless an IN value is between -1.0 and 1.0, _ERR, _LER flags are set.

6-3
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

RESULT := ACOS(EN:=%IX0.1.3, IN:=INPUT);

(1) If the transition condition (%IX0.1.3) is on, Arc Cosine operation function, ACOS executes

(2) If INPUT is 0.8660... ( 3 / 2), RESULT will be 0.5235... (π/6 rad = 30°).

6-4
Chapter6 Basic Function

1.2. ADD

Addition
ADD Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: value to be add

ADD IN2: value to add


BOOL EN ENO BOOL Input variable number can be extended up to 8

ANY_NUM IN1 OUT ANY_NUM


Output ENO: without an error, it is 1
ANY_NUM IN2
OUT: added value

IN1, IN2, ..., OUT must be the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. It adds input variables up (IN1, IN2, ..., and INn, n: number of inputs, up to 8) and produces output ,OUT.
OUT = IN1 + IN2 + ... + INn

■ Flag

Flag Description
_ERR When the output value is out of its data type, _ERR, _LER flags are set.

☆ If REAL (or LREAL) type operation exceeds the max. or min. value of REAL (or LREAL) in the middle of operation
because it performs operation sequentially from IN1 to IN8, _ERR, _LER flag are set and the result is unlimited or
abnormal value.
(1.#INF000000000000e+000, 1.#SNAN00000000000e+000, 1.#QNAN00000000000e+000).

6-5
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

OUT_VAL := ADD(EN:=%GX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%GX0) is on, ADD function executes


(2) If input variable VALUE1 = 300, VALUE2 = 200, and VALUE3 = 100, output variable OUT_VAL = 300 + 200 +
100 = 600

INPUT (IN1) : VALUE1 (INT) = 300(16#012C) 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0


+(ADD)

(IN2) : VALUE2(INT) = 200(16#00C8) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0


+(ADD)

(IN3) : VALUE3(INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0

(OUT): OUT_VAL(INT) = 600(16#0258) 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0

6-6
Chapter6 Basic Function

1.3. ADD_TIME

Time addition
ADD_TIME Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: reference time, time of date

ADD_TIME IN2: time to add


BOOL EN ENO BOOL Output ENO: without an error, it is 1
TIME,TOD,DT IN1 OUT TIME,TOD,DT OUT: added result of TOD or time
TIME IN2

IN1, IN2, and OUT must be of the same data type:


If IN1 type is TIME_OF_DAY, OUT type is
also TIME_OF_DAY.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○
OUT ○ ○ ○

■ Function

1. If IN1 is TIME, added TIME is an output.


2. IN1 is TIME_OF_DAY, it adds TIME to reference TIME_OF_DAY and produces output TIME_OF_DAY.
3. If IN1 is DATE_AND_TIME, the output data type is DT (Date and Time of Day) adding the time to the standard date
and time of day.

■ Flag

Flag Description

If an output value is out of range of related data type, _ERR, _LER flag are set. An error occurs:
1) When the result of adding the time and the time is out of range of TIME data type :
_ERR T#49D17H2M47S295MS
2) The result of adding TOD (Time of Day) and the time exceeds 24h;
3) The result of adding the date and DT (Date and the Time of Day) exceeds the year, 2163.

6-7
Chapter6 Basic Function

■ Program Example
1. LD

2. ST

END_TIME := ADD_TIME(EN:= %GX0, IN1:= START_TIME, IN2:= WORK_TIME);

(1) If the transition condition (%GX0) is on, ADD_TIME function is executes.


(2) If START_TIME is TOD#08:30:00 and WORK_TIME is T#2H10M20S500MS, END_TIME is TOD#10:40:20.5.

INPUT (IN1) : START_TIME (TOD) = TOD#08:30:00

+ (ADD_TIME)

(IN2) : WORK_TIME(TIME) = T#2H10M20S500MS

OUTPUT (OUT) : END_TIME (TOD) = TOD#10:40:20.5

6-8
Chapter6 Basic Function

1.4. AND

Logical AND (Logical multiplication)


AND Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: input 1
IN2: input 2
AND
Input variables can be extended up to 8.
BOOL EN ENO BOOL
ANY_BIT IN1 OUT ANY_BIT
ANY_BIT IN2 Output ENO: outputs EN value as it is
OUT: AND result

IN1, IN2, and OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○

■ Function

It performs a logical AND operation on the input variables by bit and produces output ,OUT.
IN1 1111 ..... 0000
&
IN2 1010 ..... 1010
OUT 1010 ..... 0000

6-9
Chapter6 Basic Function

■ Program Example

1. LD

2. ST
ST doesn’t support AND.
In case of AND2_BYTE

%DB0 := AND2_BYTE(EN:=%GX0, IN1:= %MB10, IN2:= ABC);

(1) If the transition condition (%IX0.1.1) is on, the AND function executes.
(2) If INI = %MB10 and IN2 = ABC, the result of AND is shown in OUT (%DB0).

6-10
Chapter6 Basic Function

1.5. ASIN

Arc Sine operation


ASIN Availability XGF-M32E
Flags _ERR, _LER

Function Description
Input EN: executes the function in case of 1
IN: input value of Arc Sine operation

ASIN
BOOL EN ENO BOOL Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL OUT: radian output value after Arc Sine operation

IN and OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It produces an output (Arc Sine value) of IN. The output value is between -π/2 and π/2.
OUT = ASIN (IN)

■ Error

Flag Description

_ERR If an input value exceeds the range from -1.0 to 1.0, _ERR and _LER flags are set.

6-11
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

RESULT := ASIN(EN:=%GX0, IN1:= INPUT);

(1) If the transition condition (%GX0) is on, ASIN function executes.

(2) If INPUT variable is 0.8660.... ( 3 /2), the RESULT will be 1.0471.... (π/3 radian = 60°).

6-12
Chapter6 Basic Function

1.6. ATAN

Arc Tangent operation


ATAN Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: Input value of Arc Tangent operation

ATAN
BOOL EN ENO BOOL Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL OUT: radian output value after Arc Tangent operation

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It produces an output (Arc Tangent value) of IN value. The output value is between -π/2 and π/2.
OUT = ATAN (IN)

■ Program Example

1. LD

2. ST
RESULT := ATAN(EN:=%GX0, IN1:= INPUT);
(1) If the transition condition (%GX0) is on, ATAN function executes.
(2) If INPUT = 1.0, then output RESULT will be 0.7853... ( π/4 rad = 45°).

6-13
Chapter6 Basic Function

1.7. BOOL_TO_***

BOOL type conversion


BOOL_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


BOOL_TO_*** IN: bit to convert (1 bit)
BOOL EN ENO BOOL
BOOL IN OUT *ANY_BIT
ANY_INT Output ENO: outputs EN value as it is
STRING OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function
It converts input IN type and produces output ,OUT.
Function Output type Description
BOOL_TO_SINT SINT
BOOL_TO_INT INT
BOOL_TO_DINT DINT If the input value (BOOL) is 2#0, it produces the integer number ‘0’
BOOL_TO_LINT LINT and if it is 2#1, it produces the integer number ‘1’ according to the
BOOL_TO_USINT USINT output data type.
BOOL_TO_UINT UINT
BOOL_TO_UDINT UDINT
BOOL_TO_ULINT ULINT
BOOL_TO_BYTE BYTE
BOOL_TO_WORD WORD It converts BOOL into the output data type whose upper bits are
BOOL_TO_DWORD DWORD filled with 0.
BOOL_TO_LWORD LWORD

6-14
Chapter6 Basic Function

■ Program Example

1. LD

BOOL_TO_***
%MX0
EN ENO

BOOL_VAL IN OUT OUT_VAL


(BOOL) (BYTE)

2. ST

ST language doesn’t support BOOL_TO_***


In case of BOOL_TO_BYTE

OUT_VAL := BOOL_TO_BYTE(EN:=%MX0, IN:= BOOL_VAL);

(1) If the transition condition (%MX0) is on, BOOL_TO_*** function executes.


(2) If input BOOL_VAL (BOOL) = 2#1, then output, OUT_VAL (BYTE) = 2#0000_ 0001.

INPUT (IN) : BOOL_VAL (BOOL) = 2#1 1


(BOOL_TO_SINT)

OUTPUT (OUT): OUT_VAL (BYTE) = 16#1 0 0 0 0 0 0 0 1

6-15
Chapter6 Basic Function

1.8. BTYE_TO_***

BYTE type conversion


BYTE_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


BYTE_TO_*** IN: bit String to convert (8 bits)
BOOL EN ENO BOOL
BYTE IN OUT *ANY_BIT
ANY_INT
Output ENO: outputs EN value as it is
STRING OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

It converts input IN type and produces output ,OUT.


Function Output type Description
BYTE _TO_SINT SINT Converts into SINT type without changing its internal bit array.
BYTE _TO_INT INT Converts into INT type filling the upper bits with 0.
BYTE _TO_DINT DINT Converts into DINT type filling the upper bits with 0.
BYTE _TO_LINT LINT Converts into LINT type filling the upper bits with 0.
BYTE _TO_USINT USINT Converts into USINT type without changing its internal bit array.
BYTE _TO_UINT UINT Converts into UINT type filling the upper bits with 0.
BYTE _TO_UDINT UDINT Converts into UDINT type filling the upper bits with 0.
BYTE _TO_ULINT ULINT Converts into ULINT type filling the upper bits with 0.
BYTE _TO_BOOL BOOL Takes the lower 1 bit and converts it into BOOL type.
BYTE _TO_WORD WORD Converts into WORD type filling the upper bits with 0.
BYTE _TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
BYTE _TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.

6-16
Chapter6 Basic Function

■ Program Example

1. LD
BYTE_TO_***
%MX10
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST
ST language doesn’t support BYTE_TO_***
In case of BYTE_TO_SINT

OUT_VAL := BYTE_TO_SINT(EN:=%MX10, IN:= IN_VAL);

(1) If the transition condition (%MX10) is on, BYTE_TO_*** function executes.


(2) If IN_VAL (BYTE) = 2#0001_1000, OUT_VAL (SINT) = 24 (2#0011_0000).

INPUT (IN1) : IN_VAL (BYTE) = 16#18 0 0 0 1 1 0 0 0

(BYTE_TO_***)

OUTPUT (OUT) : OUT_VAL (SINT) = 24


0 0 1 1 0 0 0 0

6-17
Chapter6 Basic Function

1.9. CONCAT_TIME

Concatenates date and time of day


CONCAT_TIME Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


CONCAT_TIME IN1: date data input
BOOL EN ENO BOOL IN2: Time of day data input
DATA IN1 OUT DATE AND TIME
TIME OF DAY IN2
Output ENO: outputs EN value as it is
OUT: DT (Date and Time of Day) output

■ Function

It concatenates IN1 (date) and IN2 (time of day) and produces output, OUT (DT).

■ Program Example

1. LD

%MX1 CONCAT_TIME
EN ENO

START_DATE IN1 OUT START_DT


START_TIME IN2

2. ST
START_DT := CONCAT_TIME(EN:=%MX1, IN1:= START_DATE, IN2:= START_TIME);

(1) If the transition condition (%MX1) is on, CONCAT_TIME function executes.


(2) If START_DATE = D#1995-12-06 and START_TIME = TOD#08:30:00, then, output START_DT = DT#1995-
12-06-08:30:00.

INPUT (IN1) : START_DATE (DATE) = D#1995-12-06

(CONCAT_TIME)
INPUT (IN2) : START_TIME (TOD) = TOD#08:30:00

OUTPUT (OUT) : START_DT (DT) = DT#1995-12-06-08:30:00

6-18
Chapter6 Basic Function

1.10. COS

Cosine operation
COS Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: radian input value of Cosine operation
COS
BOOL EN ENO BOOL Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: result value of Cosine operation

IN and OUT must be the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It produces IN’s Cosine operation value.


OUT = COS (IN)

■ Program Example

1. LD

6-19
Chapter6 Basic Function

2. ST

RESULT := COS(EN:= %GX0, IN:= INPUT);

(1) If the transition condition (%GX0) is on, COS function executes.

(2) If input INPUT = 0.5235 (π/6 rad = 30°), output RESULT = 0.8660 ... ( 3 / 2 ).

COS (π/6) = 3 / 2 = 0.866

INPUT (IN) : INPUT (REAL) = 0.5235

(COS)

OUTPUT (OUT) : RESULT (REAL) = 8.66074800E-01

6-20
Chapter6 Basic Function

1.11. DATE_T0_***

Date type conversion


DATE_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


DATE_TO_*** IN: date data to convert
BOOL EN ENO BOOL
DATE IN OUT WORD,UINT
STRING Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

IN ○ ○

■ Function

It converts an input IN type and produces output, OUT.


Function Output type Description
DATE_TO_UINT UINT Converts DATE into UINT type.

DATE_TO_WORD WORD Converts DATE into WORD type.

6-21
Chapter6 Basic Function

■ Program Example

1. LD
DATE_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST
ST language doesn’t support DATE_TO_****

(1) If the transition condition (%MX0) is on, DATE_TO_*** function executes.


(2) If IN_VAL (DATE) = D#2013-06-18, OUT_VAL (UNIT) = 10761

6-22
Chapter6 Basic Function

1.12. DINT_TO_***

DINT type conversion


DINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


DINT_TO_***
IN: double integer value to convert
BOOL EN ENO BOOL
DINT IN OUT *ANY
Output ENO: without an error, it is 1.
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude DINT, TIME and DATE from ANY type.

■ Function

It converts Input IN type and produces output, OUT.

Function Output type Description


If input is -128 ∼ 127, normal conversion.
DINT_TO_SINT SINT
Except this, an error occurs.
If input is -32,768 ∼ 32,767, normal conversion.
DINT_TO_INT INT
Except this, an error occurs.
DINT_TO_LINT LINT Converts normally into LINT type.
If input is 0 ∼ 255, normal conversion.
DINT_TO_USINT USINT
Otherwise an error occurs.
If input is 0 ∼ 65,535, normal conversion.
DINT_TO_UINT UINT
Otherwise an error occurs.
If input is 0 ∼ 2,147,483,647, normal conversion.
DINT_TO_UDINT UDINT
Otherwise an error occurs.
If input is 0 ∼ 2,147,483,647, normal conversion.
DINT_TO_ULINT ULINT
Otherwise an error occurs.
DINT_TO_BOOL BOOL Takes the low 1 bit and converts into BOOL type.
DINT_TO_BYTE BYTE Takes the low 8 bit and converts into BYTE type.

6-23
Chapter6 Basic Function

Function Output type Description


DINT_TO_WORD WORD Takes the low 16 bit and converts into WORD type.
DINT_TO_DWORD DWORD Converts into DWORD type without changing the internal bit array.
DINT_TO_LWORD LWORD Converts into LWORD type filling the upper bytes with 0.
Converts DINT into REAL type.
DINT_TO_REAL REAL
During conversion, an error caused by the precision may occur.
Converts DINT into LREAL type.
DINT_TO_LREAL LREAL
During conversion, an error caused by the precision may occur.

■ Flag

Flag Description

If a conversion error occurs, _ERR, _LER flags are set.


_ERR When an error occurs, it takes as many lower bits as the bit number of the output type and produces
an output without changing the internal bit array.

■ Program Example
1. LD

DINT_TO
%MX1 _***
EN ENO

DINT_VAL IN OUT SINT_VAL

2. ST
ST language doesn’t support DINT_TO_***
In case of DINT_TO_SINT

SINT_VAL := DINT_TO_SINT(EN:= %MX1, IN:= DINT_VAL);

(1) If the transition condition (%MX1) is on, DINT_TO_*** function executes.


(2) If INI = DINT_VAL (DINT) = -77, SINT_VAL (SINT) = -77.

6-24
Chapter6 Basic Function

1.13. DIV

Division
DIV Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: the value to be divided (dividend)
DIV
IN2: the value to divide (divisor)
BOOL EN ENO BOOL

ANY_NUM IN1 OUT ANY_NUM Output ENO: without an error, it is 1.

ANY_NUM IN2
OUT: the divided result (quotient)

The variable connected to IN1, IN2 and OUT must be of the


same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

It divides IN1by IN2 and produces an output omitting decimal fraction from the quotient.
OUT = IN1/IN2

IN1 IN2 OUT Remarks


7 2 3
7 -2 -3
Decimal fraction omitted
-7 2 -3
-7 -2 3
7 0 × Error

■ Flag

Flag Description
If the value to divide (divisor) is ‘0’, and the results exceeds the maximum value of each type, _ERR,
_ERR _LER flags are set.

6-25
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

OUT_VAL := DIV(EN:= %GX0, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%GX0) is on, DIV function executes.


(2) If input VALUE1 = 300 and VALUE2 = 100, then output, OUT_VAL = 300/100 = 3.

INPUT (IN1) : VALUE1 (INT) = 300(16#012C) 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0

/(DIV)

(IN2): VALUE2(INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0

OUTPUT (OUT) : OUT_VAL (INT) = 3(16#3) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1

6-26
Chapter6 Basic Function

1.14. DIV_

1.15. DT_TO_***

DT type conversion
DT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


DT_TO_*** IN: date and time of day data to convert
BOOL EN ENO BOOL

DT IN OUT LWORD,DATE Output ENO: outputs EN value as it is


TOD,STRING
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○

■ Function

It converts Input IN type and produces output, OUT.

Function Output type Description


Converts DT into LWORD type.
DT_TO_LWORD LWORD
(The inverse conversion is available as there is no internal data change).
DT_TO_DATE DATE Converts DT into DATE type.
DT_TO_TOD TOD Converts DT into TOD type.

6-27
Chapter6 Basic Function

■ Program Example

1. LD
%MX20 DT_TO_***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST
ST language doesn’t support DT_TO_***
In case of DT_TO_DATE

OUT_VAL := DT_TO_DATE(EN:= %MX20, IN1:= IN_VAL);

(1) If the transition condition (%MX20) is on, DT_TO_*** function executes.


(2) If input IN_VAL (DT) = DT#1995-12-01-12:00:00, output ,OUT_VAL (DATE) = D#1995-12-01

INPUT (IN) : IN_VAL (DT) = DT#1995-12-01-12:00:00

(DT_TO_DATE)

OUTPUT (OUT) : OUT_VAL (DATE) = D#1995-12-01

6-28
Chapter6 Basic Function

1.16. DWORD_TO_***

DWORD type conversion


DWORD_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


DWORD_TO_*** IN: bit String to convert (32bit)
BOOL EN ENO BOOL
DWORD IN OUT *ANY
Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude DWORD, LREAL and DATE from ANY type.

■ Function

It converts Input IN type and produces output. OUT.

Function Output type Description


DWORD_TO_SINT SINT Takes the lower 8 bits and converts into SINT type.
DWORD_TO_INT INT Takes the lower 16 bits and converts into INT type.
DWORD_TO_DINT DINT Converts into DINT type without changing the internal bit array.
DWORD_TO_LINT LINT Converts into LINT type filling the upper bits with 0
DWORD_TO_USINT USINT Takes the lower 8 bits and converts into USINT type.
DWORD_TO_UINT UINT Takes the lower 16 bits and converts into UINT type.
DWORD_TO_UDINT UDINT Converts into UDINT type without changing the internal bit array.
DWORD_TO_ULINT ULINT Converts into ULINT type filling the upper bits with 0.
DWORD_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
DWORD_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
DWORD_TO_WORD WORD Takes the lower 16 bits and converts into WORD type.
DWORD_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
DWORD_TO_REAL REAL Converts into REAL type without changing the internal bit array.
DWORD_TO_TIME TIME Converts into TIME type without changing the internal bit array.

6-29
Chapter6 Basic Function

Function Output type Description


Converts into TOD type without changing the internal bit array.
However, with a value out of TOD range (TOD#23:59:59.999), _ERR,
DWORD_TO_TOD TOD
_LER flags are set and it is alternately converted within the range of
TOD.

■ Program Example

1. LD
DWORD_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST
ST language doesn’t support DWORD_TO_***
In case of DWORD_TO_TOD

OUT_VAL := DWORD_TO_TOD(EN:= %MX0, IN1:= IN_VAL);

(1) If the transition condition (%MX0) is on, DWIRD_TO_TOD function executes.


(2) If output IN_VAL (DWORD) = 16#3E8 (1000), output , OUT_VAL (TOD) = TOD#1S.
(3) Calculates TIME, TOD by converting decimal into MS unit. That is, 1000 is 1000ms = 1s.
(Refer to 3.2.4. Data Type Structure)

6-30
Chapter6 Basic Function

1.17. EQ

‘Equal to’ comparison


EQ Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared
EQ IN2: the value to compare
BOOL EN ENO BOOL Input variable number can be extended up to 8.
ANY IN1 OUT BOOL IN1, IN2, ... must be the same type.
ANY IN2

Output ENO: outputs EN value as it is


OUT: comparison result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. If IN1 = IN2 = IN3 ... = INn (n : number of inputs), output , OUT is 1.


2. In other cases, OUT is 0.

■ Program Example

1. LD

6-31
Chapter6 Basic Function

2. ST

%MX0 := EQ(EN:= %GX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%GX0) is on, EQ function executes.


(2) If VALUE1 = 300, VALUE2 = 300, VALUE3 = 300 (comparison result VALUE1 = VALUE2 = VALUE3),
output %MX0 = 1.

6-32
Chapter6 Basic Function

1.18. EXP

EXP operation
EXP Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input value of exponent operation
EXP
BOOL EN ENO BOOL Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: result value of exponent operation

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It calculates the natural exponent with exponent IN and produces output, OUT.
IN
OUT = e

■ Error

Flag Description

_ERR If output is out of the range of a type, _ERR and _LER flags are set.

6-33
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

RESULT := EXP(EN:= %GX0, IN1:= INPUT);

(1) If the transition condition (%GX0) is on, EXP function executes.


(2) If INPUT is 2.0, RESULT is 7.3890….
INPUT
RESULT = e

INPUT = 2.0, RESULT = 7.3890...

6-34
Chapter6 Basic Function

1.19. EXPT

Exponential operation
EXPT Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: real number
EXPT IN2: exponent
BOOL EN ENO BOOL
ANY_REAL IN1 OUT ANY_REAL
Output ENO: outputs EN value as it is
ANY_REAL IN2
OUT: result value

IN1 and OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○
IN2 ○ ○
OUT ○ ○

■ Function

It calculates IN1 with exponent IN2 and produces output, OUT.


IN2
OUT = IN1

■ Error

Flag Description

_ERR If an output is out of range of related data type, _ERR and _LER flags are set.

6-35
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

RESULT := EXPT(EN:= %GX0, IN1:= INPUT1, IN2:= INPUT2);

(1) If the transition condition %GX0) is on, ‘EXPT’ exponential function executes.
(2) If input INPUT1= 1.5, INPUT2 = 3, output RESULT = 1.53 = 1.5 ×1.5 ×1.5 = 3.375.
3
3.375 = 1.5

6-36
Chapter6 Basic Function

1.20. FI

1.21. GE

‘Greater than or equal to’ comparison


GE Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared
GE IN2: the value to compare
BOOL EN ENO BOOL
Input variable number can be extended up to 8.
ANY IN1 OUT BOOL
IN1, IN2, ... must be of the same data type.
ANY IN2

Output ENO: outputs EN value as it is


OUT: comparison result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

If IN1 ≥ IN2 ≥ IN3... ≥ INn (n: number of inputs), an output is 1.


Otherwise it is 0.

■ Program Example
1. LD

6-37
Chapter6 Basic Function

2. ST

%MX0:= GE(EN:= %MX77, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%MX77) is on, GE function executes.


(2) If input variable VALUE1 = 300, VALUE3 = 200, comparison result is VALUE1 ≥ VALUE2 ≥ VALUE3.
The output %MX0= 1.

6-38
Chapter6 Basic Function

1.22. GT

‘Greater than’ comparison


GT Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared
GT IN2: the value to compare
BOOL EN ENO BOOL Input variable number can be extended up to 8.
ANY IN1 OUT BOOL IN1, IN2, ... must be of the same data type.
ANY IN2

Output ENO: outputs EN value as it is


OUT: comparison result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. If IN1 > IN2 > IN3... > INn (n: number of inputs), an output is 1.
2. Otherwise it is 0.

■ Program Example
1. LD

2. ST
%MX0 := GT(EN:= %GX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);
(1) If the transition condition (%GX0) is on, GT function executes.
(2) If input variable VALUE1 = 300, VALUE2 = 200, and VALUE3 = 100, comparison result is VALUE1 > VALUE2 >
VALUE3. The output % MX0 = 1.

6-39
Chapter6 Basic Function

1.23. IN T_TO_***

INT type conversion


INT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


INT_TO_***
IN: integer value to convert
BOOL EN ENO BOOL
Output ENO: without an error, it is 1.
INT IN OUT *ANY
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude INT, TIME, DATE, TOD and DT from ANY type.

■ Function

It converts input IN type and produces output, OUT.

Function Output Type Description


INT_TO_SINT SINT If input is -128 ∼ 127, normal conversion. Otherwise an error occurs.
INT_TO_DINT DINT Converts into DINT type normally.
INT_TO_LINT LINT Converts into LINT type normally.
INT_TO_USINT USINT If input is 0 ∼ 255, normal conversion. Otherwise an error occurs.
INT_TO_UINT UINT If input is 0 ∼ 32767, normal conversion. Otherwise an error occurs.
INT_TO_UDINT UDINT If input is 0 ∼ 32767, normal conversion. Otherwise an error occurs.
h INT_TO_ULINT ULINT If input is 0 ∼ 32767, normal conversion. Otherwise an error occurs.
INT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
INT_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
INT_TO_WORD WORD Converts into WORD type without changing the internal bit array.
INT_TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
INT_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
INT_TO_REAL REAL Converts INT into REAL type normally.
INT_TO_LREAL LREAL Converts INT into LREAL type normally.

6-40
Chapter6 Basic Function

■ Flag

Flag Description

If a conversion error occurs, _ERR _LER flags are set.


_ERR If an error occurs, take as many lower bits as the bit number of the output type and produces an
output without changing the internal bit array.

■ Program Example

1. LD
%MX0 INT_TO_***
EN ENO

IN_VAL IN OUT OUT_WORD

2. ST

ST language doesn’t support INT_TO_***


In case of INT_TO_WORD

OUT_WORD := INT_TO_WORD(EN:= %MX0, IN1:= IN_VAL);

(1) If the input condition (%MX0) is on, INT_TO_*** function executes.


(2) If input variable IN_VAL (INT) = 512 (16#200), output variable OUT_WORD (WORD) = 16#200.

INPUT (IN1) : IN_VAL (INT) = 512(16#200) 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0


(INT_TO_WORD)

OUTPUT (OUT) : OUT_WORD (WORD) = 16#200 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0

6-41
Chapter6 Basic Function

1.24. LE

'Less than or equal to' comparison


LE Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared
LE IN2: the value to compare
BOOL EN ENO BOOL
Input variable number can be extended up to 8.
ANY IN1 OUT BOOL
IN1, IN2, ...must be of the same data type.
ANY IN2

Output ENO: outputs EN value as it is


OUT: comparison result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. If IN1 ≤ IN2 ≤ IN3... ≤ INn (n: number of inputs), output OUT is 1.


2. Otherwise it is 0.

■ Program Example

1. LD

6-42
Chapter6 Basic Function

2. ST

%GX0 := LE(EN:= %MX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%MX0) is on, LE function executes.


(2) If input variable VALUE1 = 100, VALUE2 = 200, and VALUE3 = 200, output %GX0 = 1
(VALUE1 ≤ VALUE2 ≤ VALUE3).

6-43
Chapter6 Basic Function

1.25. LIMIT

Limits upper and lower boundaries


LIMIT Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


MN: minimum value

LIMIT IN: the value to be limited


BOOL EN ENO BOOL MX: maximum value
ANY MN OUT ANY
ANY IN
ANY MX Output ENO: outputs EN value as it is
OUT: value in the range

MN, IN, MX, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable MN ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○


IN ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
MX ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. If input IN value is between MN and MX, the IN is an output. That is, if MN ≤ IN ≤ MX, OUT = IN.
2. If input IN value is less than MN, MN is an output. That is, if IN < MN, OUT = MN.
3. If input IN value is greater than MX, MX is an output. That is, if IN > MX, OUT = MX.

■ Program Example
1. LD

%MX0 LIMIT
EN ENO

LIMIT_LOW MN OUT OUT_VAL


IN_VALUE IN

LIMIT_HIGH MX

6-44
Chapter6 Basic Function

2. ST

OUT_VAL := LIMIT(EN:= %MX0, MX:= LIMIT_LOW, IN:= IN_VALUE, MX:= LIMIT_HIGH);

(1) If the transition condition (%MX0) is on, LIMIT function executes.


(2) Output variable OUT_VAL for lower limit input LIMIT_LOW, upper limit input (LIMIT_HIGH) and limited value input
IN_VALUE is as follows.

LIMIT_LOW IN_VALUE LIMIT_HIGH OUT_VAL


1000 2000 3000 2000
1000 500 3000 1000
1000 4000 3000 3000

INPUT (MN) : LIMIT_LOW (INT) = 1000

(IN) : IN_VALUE (INT) = 4000

(MX) : LIMIT_HIGH(INT) = 3000

(LIMIT)

OUTPUT (OUT) : OUT_VAL (INT) = 3000

6-45
Chapter6 Basic Function

1.26. LINT_TO_***

LINT type conversion


LINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


LINT_TO_***
IN: long integer value to convert
BOOL EN ENO BOOL
LINT IN OUT *ANY
Output ENO: without an error, it is 1
OUT: type converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude LINT, TIME, DATE, TOD, and DT from ANY type.

■ Function

It converts input IN type and produces output, OUT.

Function Output type Description


LINT_TO_SINT SINT If input is -128 ∼ 127, normal conversion. Otherwise an error occurs.
LINT_TO_INT INT If input is –32,768∼ 32,767, normal conversion. Otherwise an error occurs.
LINT_TO_DINT DINT If input is -231 ∼ 231-1, normal conversion. Otherwise an error occurs.
LINT_TO_USINT USINT If input is 0∼ 255, normal conversion. Otherwise an error occurs.
LINT_TO_UINT UINT If input is 0∼ 65,535, normal conversion. Otherwise an error occurs.
LINT_TO_UDINT UDINT If input is 0 ∼ 232-1, normal conversion. Otherwise an error occurs.
LINT_TO_ULINT ULINT If input is 0 ∼ 263-1, normal conversion. Otherwise an error occurs.
LINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
LINT_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
LINT_TO_WORD WORD Takes the lower 16 bits and converts into WORD type.
LINT_TO_DWORD DWORD Takes the lower 32 bits and converts into DWORD type.
LINT_TO_LWORD LWORD Converts into LWORD type without changing the internal bit array.
Converts LINT into REAL type.
LINT_TO_REAL REAL
During the conversion, an error caused by the precision may occur.

6-46
Chapter6 Basic Function

Function Output type Description


Converts LINT into LREAL type.
LINT_TO_LREAL LREAL
During the conversion, an error caused by the precision may occur.

■ Flag

Flag Description

If a conversion error occurs, _ERR and _LER flags are set. If an error occurs, lower bits equal to the
_ERR
bit number of the output type are taken to produces an output without changing the Internal bit array.

■ Program Example

1. LD

2. ST

ST language doesn’t support LINT_TO_***


In case of LINT_TO_DINT

OUT_VAL := LINT_TO_DINT(EN:= %%GX0, IN:= IN_VAL);

(1) If the input condition (%%GX0) is on, LINT_TO_*** function executes.


(2) If input variable IN_VAL (LINT) = 123,456,789, output variable OUT_VAL (DINT) = 123,456,789.

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
INOUT (IN) : IN_VAL (LINT) = 123,456,789(16#00000000075BCD15)
0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1

1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1
(LINT_TO_DINT)

0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1
OUTPUT (OUT) : OUT_VAL (DINT) = 123,456,789 (16#075BCD15)
1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1

6-47
Chapter6 Basic Function

1.27. LN

Natural logarithm operation


LN Availability XGF-M32E
Flags _ERR, _LER

Function Description
Input EN: executes the function in case of 1
IN: input value of natural logarithm operation

LN
BOOL EN ENO BOOL Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: natural logarithm value

IN, OUT must be of the same data type


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It finds a natural logarithm value of IN and produces output, OUT.


OUT = ln (IN)

■ Error

Flag Description
_ERR If an input is 0 or a negative number, _ERR and _LER flags are set.

6-48
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

RESULT := LN(EN:= %%GX0, IN1:= INPUT);

(1) If the transition condition (%%GX0) is on, LN function executes.


(2) If input variable INPUT is 2.0, output variable RESULT is 0.6931 ....
ln(2.0) = 0.6931...

6-49
Chapter6 Basic Function

LOG

Base 10 Logarithm operation


LOG Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input value of common logarithm operation

LOG
BOOL EN ENO BOOL Output END: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: the value of common logarithm operation

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It finds the value of Base 10 Logarithm of IN and produces output, OUT.


OUT = log10 (IN) = log (IN)

■ Error

Flag Description
_ERR If input value IN is 0 or a negative number, _ ERR and _LER flags are set.

6-50
Chapter6 Basic Function

■ Program Example
1. LD

2. ST

RESULT := LOG(EN:= %GX0, IN:= INPUT);

(1) If the transition condition (%GX0) is on, LOG function executes.


(2) If input variable INPUT is 2.0, output variable RESULT is 0.3010 ..…
Log10 (2.0) = 0.3010...

6-51
Chapter6 Basic Function

1.28. LREAL_TO_***

LREAL type conversion


LREAL_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: LREAL value to convert

Output ENO: without an error, it is 1.


OUT: type converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

It converts input IN type and produces output, OUT.

Function Output type Operation


If integer number of input is -128 ∼ 127, normal conversion.
LREAL_TO_SINT SINT
Otherwise an error occurs (decimal round off).
If integer number of input is -32,768 ∼ 32,767, normal conversion.
LREAL_TO_INT INT
Otherwise an error occurs (decimal round off).
If integer number of input is -231 ∼ 231-1, normal conversion.
LREAL_TO_DINT DINT
Otherwise an error occurs (decimal round off).
If integer number of input is -263 ∼ 263-1, normal conversion.
LREAL_TO_LINT LINT
Otherwise an error occurs (decimal round off).
If integer number of input is 0 ∼ 255, normal conversion.
LREAL_TO_USINT USINT
Otherwise an error occurs (decimal round off).
If integer number of input is 0 ∼ 65,535, normal conversion.
LREAL_TO_UINT UINT
Otherwise an error occurs (decimal round off).

If integer number of input is 0 ∼ 232-1, normal conversion.


LREAL_TO_UDINT UDINT
Otherwise an error occurs (decimal round off).

LREAL_TO_ULINT ULINT If integer number of input is 0 ∼ 264-1, normal conversion.

6-52
Chapter6 Basic Function

Function Output type Operation


Otherwise an error occurs (decimal round-off).
LREAL_TO_LWORD LWORD Converts into LWORD type without changing the internal bit array.
Converts LREAL into REAL type normally.
LREAL_TO_REAL REAL
During the conversion, an error caused by the precision may occur.

■ Flag

Flag Description

If an overflow occurs because an input value is greater than the value available for the output type,
_ERR
_ERR and _LER flags are set. If an error occurs, an output is 0.

■ Program Example
1. LD
LREAL_TO
%MX0 _***
EN ENO

LREAL_VAL IN OUT REAL_VAL

2. ST

ST language doesn’t support LREAL_TO_***


In case of LREAL_TO_REAL

REAL_VAL := LREAL_TO_REAL(EN:= %MX0, IN:= LREAL_VAL);

(1) If the input condition (%MX0) is on, LREAL_TO_*** function executes.


(2) If input variable LREAL_VAL (LREAL) = -1.34E-12, output variable REAL_VAL (REAL) = -1.34E-12.

INPUT (IN) : LREAL_VAL (LREAL) = -1.34E-12

(LREAL_TO_REAL)

OUTPUT (OUT) : REAL_VAL (REAL) = -1.34E-12

6-53
Chapter6 Basic Function

1.29. LT

‘Less than’ comparison


LT Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared

LT IN2: the value to compare


BOOL EN ENO BOOL Input variable number can be extended up to 8
ANY IN1 OUT BOOL IN1, IN2, ...must be of the same data type
ANY IN2

Output ENO: outputs EN value as it is


OUT: comparison result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. If IN1 < IN2 < IN3... < INn (n: number of inputs), output value OUT is 1.
2. Otherwise output, OUT is 0.

■ Program Example

1. LD

6-54
Chapter6 Basic Function

2. ST

%GX0 := LT(EN:= %MX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%MX0) is on, LT function executes.


(2) If input variable VALUE1 = 100, VALUE2 = 200, and VALUE3 = 300, output %GX0 = 1 because of VALUE1 <
VALUE 2 < VALUE 3 as a result of the comparison.

6-55
Chapter6 Basic Function

1.30. LWORD_TO_***

LWORD type conversion


LWORD_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


LWORD_TO_***
IN: bit String to convert (64bit)
BOOL EN ENO BOOL

LWORD IN OUT *ANY Output ENO: outputs EN value as it is


OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude LWORD, REAL, TIME, DATE and TOD from ANY type.

■ Function

It converts input IN type and produces output, OUT.

Function Output type Description


LWORD_TO_SINT SINT Takes the lower 8 bits and converts into SINT type.
LWORD_TO_INT INT Takes the lower 16bits and converts into INT type.
LWORD_TO_DINT DINT Takes the lower 32bits and converts into DINT type.
LWORD_TO_LINT LINT Converts into LINT type without changing the internal bit array.
LWORD_TO_USINT USINT Takes the lower 8 bits and converts into USINT type.
LWORD_TO_UINT UINT Takes the lower 16 bits and converts into UINT type.
LWORD_TO_UDINT UDINT Takes the lower 32bits and converts into UDINT type.
LWORD_TO_ULINT ULINT Converts into ULINT type without changing the internal bit array.
LWORD_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
LWORD_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
LWORD_TO_WORD WORD Takes the lower 16 bits and converts into WORD type.
LWORD_TO_DWORD DWORD Takes the lower 32 bits and converts into DWORD type.

LWORD_TO_LREAL LREAL Converts LWORD into LREAL type.

LWORD_TO_DT DT Converts into DT type without changing the internal bit array. However,

6-56
Chapter6 Basic Function

Function Output type Description


with a value out of DT range (DT#2163-12-31-23:59:59:999), _ERR, _LER
flags are set and it is alternately converted within the range of DT.

■ Program Example

1. LD
LWORD_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST
ST language doesn’t support LWORD_TO_***
In case of LWORD_TO_LINT

OUT_VAL := LWROD_TO_LINT(EN:= %MX0, IN:= IN_VAL);

(1) If the input condition (%MX0) is on, LWORD_TO_*** function executes.


(2) If input variable IN_VAL (LWORD) = 16#FFFF_FFFF_FFFF_FFFF, output variable OUT_VAL (LINT) is -1
(16#FFFF_FFFF_FFFF_FFFF).

INPUT (IN) : IN_VAL (LWORD) = 16#FFFFFFFFFFFFFFFF


(LWORD_TO_LINT)

OUTPUT (OUT) : OUT_VAL (LINT) = -1

6-57
Chapter6 Basic Function

1.31. MAX

Maximum value
MAX Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be compared
IN2: the value to compare
MAX
BOOL EN ENO BOOL Input variable number can be extended up to 8.
ANY IN1 OUT ANY
ANY IN2 Output ENO: outputs EN value as it is
OUT: maximum value among input

IN1, IN2,…, OUT must be of the same data type


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type Variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

6-58
Chapter6 Basic Function

■ Function

It produces the maximum value among input IN1, IN2,..., INn (n: number of inputs).

■ Program Example

1. LD

%MX0 MAX
EN ENO

VALUE1 IN1 OUT OUT_VALUE


VALUE2 IN2

2. ST

OUT_VALUE := MAX(EN:= %MX0, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%MX0) is on, MAX function executes.


(2) As the result of comparing input variable (VALUE1 = 100 and VALUE2 = 200), maximum value is 200.
Output OUT_VAL is 200.

INPUT (IN1) : VALUE1 (INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0


(MAX)

(IN2) : VALUE2(INT) = 200(16#00C8) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0

OUTPUT (OUT): OUT_VALUE (INT) = 200(16#00C8) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0

6-59
Chapter6 Basic Function

1.32.

1.33. MIN

Minimum value
MIN Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: value to be compared
IN2: value to compare
MIN
BOOL EN ENO BOOL Input variable number can be extended up to 8
ANY IN1 OUT ANY
ANY IN2 Output ENO: outputs EN value as it is
OUT: minimum value among input values

IN1, IN2, ..., OUT must be of all the same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

6-60
Chapter6 Basic Function

■ Function

Produces the minimum value among input IN1, IN2, ... , INn (n: number of inputs).

■ Program Example

1. LD

%MX100 MIN
EN ENO

VALUE1 IN1 OUT OUT_VALUE


VALUE2 IN2

2. ST

OUT_VALUE := MIN(EN:= %MX100, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%MX100) is on, MIN function executes.


(2) The output is OUT_VALUE = 100 because its minimum value is 100 as the result of comparing VALUE1 = 100
to VALUE2 = 200.

INPUT (IN1) : VALUE1 (INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0


(MIN)

(IN2) : VALUE2(INT) = 200(16#00C8) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0

OUTPUT(OUT): OUT_VALUE (INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0

6-61
Chapter6 Basic Function

1.34. MOD

Dividing result (remainder)


MOD Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: dividend
MOD
IN2: divisor
BOOL EN ENO BOOL
ANY_INT IN1 OUT ANY_INT
ANY_INT IN2 Output ENO: outputs EN value as it is
OUT: dividing result (remainder)

IN1, IN2, ..., OUT must be of all the same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. Divides IN1 by IN2 and outputs its remainder as OUT.


OUT = IN1 - (IN1/IN2) × IN2 ( If IN2 = 0, OUT = 0 )

IN1 IN2 OUT


7 2 1
7 -2 1
-7 2 -1
-7 -2 -1
7 0 0

6-62
Chapter6 Basic Function

■ Program Example

1. LD

%MX100 MOD
EN ENO

VALUE1 IN1 OUT OUT_VAL

VALUE2 IN2

2. ST

OUT_VAL := MOD(EN:= %MX100, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%MX100) is on, MOD function executes.


(2) If the dividend VALUE1 = 37 and the divisor VALUE2 = 10, the remainder value OUT_VAL is 7 as a result of
dividing 37 by 10.

INPUT (IN1) : VALUE1 (INT) = 37(16#0025) 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1


(MOD)

(IN2) : VALUE2(INT) = 10(16#000A) 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0

OUTPUT (OUT) : OUT_VAL (INT) = 7(16#0007) 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

6-63
Chapter6 Basic Function

1.35. MOVE

Data movement (Copy data)


MOVE Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: value to be moved
MOVE
BOOL EN ENO BOOL
Output ENO: outputs EN value as it is
ANY IN OUT ANY
OUT: moved value

Variables connected to IN and OUT are of the same type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

Moves an IN value to OUT.

■ Program Example

This is a program that transfers the 8-contact inputs %I0.0 ∼ %I0.7 to the variable D and then moves them to
output %Q0.0 ∼ %Q0.7.

1. LD

6-64
Chapter6 Basic Function

2. ST

D := MOVE(EN:= %MX100, IN:= %IB0.0);


%QB0.0 := MOVE(EN:= %MX100, IN:= D);

(1) If the transition condition (%MX100) is on, MOVE function executes.


(2) It moves 8-contact input module data to the variable D by the first MOVE function and moves them to %Q0.4.0
∼ %Q0.4.7 by the second one.

6-65
Chapter6 Basic Function

1.36. MUL

Multiplication
MUL Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: multiplicand
MUL
BOOL EN ENO BOOL IN2: multiplier
Input is available to extend up to 8.
ANY_NUM IN1 OUT ANY_NUM
Output ENO: without an error, it is 1
ANY_NUM IN2
OUT: multiplied value

Variables connected to IN1, IN2, ..., OUT are all of the same
data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

Multiplies an IN1, IN2,..., INn (n: number of inputs) and outputs the result as OUT.
OUT = IN1 × IN2 × ... × INn

■ Flag

Flag Description
_ERR If an output value is beyond the range of its data-type, _ERR and _LER flags are set.

☆ If REAL, LREAL type operation exceeds the maximum or minimum value in the middle of the operation because it
performs the operation sequentially from IN1 to IN8, _ERR, _LER flag are set and the result is an unlimited or
abnormal value.
(1.#INF000000000000e+000, 1.#SNAN00000000000e+000, 1.#QNAN00000000000e+000).

6-66
Chapter6 Basic Function

■ Program Example

1. LD

%MX0 MUL
EN ENO

VALUE1 IN1 OUT OUT_VAL


VALUE2 IN2

VALUE3 IN3

2. ST

OUT_VAL := MUL(EN:= %MX0, IN1:= VALUE1, IN2:= VALUE2, IN3:= VALUE3);

(1) If the transition condition (%MX0) is on, MUL function executes.


(2) If input variables of MUL function, VALUE1 = 30, VALUE2 = 20, VALUE3 = 10, then the output variable
OUT_VAL = 30 ×20 ×10 = 6000.

INPUT (IN1) : VALUE1 (INT) = 30(16#001E) 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0


+(MUL)

(IN2) : VALUE2(INT) = 20(16#0014) 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0


+(MUL)

(IN3) : VALUE3(INT) = 10(16#000A) 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0

OUTPUT (OUT) : OUT_VAL (INT) = 6,000(16#1770) 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0

6-67
Chapter6 Basic Function

1.37.

1.38. MUX

Selection from multiple inputs


MUX Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


K: selection
IN0: the value to be selected

MUX IN1: the value to be selected

BOOL EN ENO BOOL Input variable number can be extended up to 7(IN0,


INT K OUT ANY IN1, …, IN6)
ANY IN0
ANY IN1
Output ENO: without an error, it is 1.
OUT: the selected value

IN0, IN1, ..., OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN0 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. Selects one among several inputs (IN0, IN1, …, INn) with K value and produces it.
2. If K = 0, IN0 is an output; if K = 1, IN1 is an output; if K = n, INn is an output.

■ Flag

Flag Description

If K is greater than or equal to ‘n’ which is the number of input variable INn, then IN0 is an output and
_ERR
_ERR, _LER flags are set. If K is negative, _ERR and _LER flags are set

6-68
Chapter6 Basic Function

■ Program Example

1. LD
%MX0 MUX
EN ENO

S K OUT OUT_VAL
VALUE0 IN0

VALUE1 IN1
VALUE2 IN2

2. ST

OUT_VAL := MUX(EN:= %MX0, K:= S, IN0:= VALUE0, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%MX0) is on, MUX function executes.


(2) Input variable is selected by selection variable S and is moved to OUT.

INPUT (K) : S (INT) = 2


(IN0) : VALUE0(WORD) = 16#0011
(IN1) : VALUE1(WORD) = 16#0022
(IN2) : VALUE2(WORD) = 16#0033
(MUX)

OUTPUT (OUT) : OUT_VAL (WORD) = 16#0033

6-69
Chapter6 Basic Function

1.39. NE

‘Not equal to’ comparison


NE Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: The value to be compared
NE
IN2: The value to be compared
BOOL EN ENO BOOL
ANY IN1 OUT BOOL IN1, IN2 must be of the same data type.
ANY IN2
Output ENO: outputs EN value as it is
OUT: the compared result value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

6-70
Chapter6 Basic Function

■ Function

1. If IN1 is not equal to IN2, output, OUT is 1.


2. If IN1 is equal to IN2, output, OUT is 0.

■ Program Example

1. LD

2. ST

%QX0.0 := NE(EN:= %IX0.0, IN1:= VALUE1, IN2:= VALUE2);

(1) If the transition condition (%IX0.0) is on, NE function executes.


(2) If input variable VALUE1 = 300, VALUE2 = 200 (the compared result VALUE1 and VALUE2 are different),
output result value is %QX0.1 = 1.

6-71
Chapter6 Basic Function

1.40. NE

Reverse Logic (Logic inversion)


NOT Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: the value to be logically inverted
NOT
BOOL EN ENO BOOL
ANY_BIT IN OUT ANY_BIT Output ENO: outputs EN value as it is
OUT: the inversed (NOT) value

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○

6-72
Chapter6 Basic Function

■ Function

It inverts the IN (by bit) and produces output, OUT.


IN 1100 ..... 1010
OUT 0011 ..... 0101

■ Program Example

1. LD

2. ST

%QB0.0 := NOT_BYTE(EN:= %MX0, IN1:=MB10);

(1) If the transition condition (%MX0) is on, NOT function executes.


(2) If NOT function executes, input data value of %MB10 is inversed and is written in %QB0.0.0.

6-73
Chapter6 Basic Function

Logic Sum
OR Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: input 1
IN2: input 2
OR
Input variables extend up to 8.
BOOL EN ENO BOOL
ANY_BIT IN1 OUT ANY_BIT
ANY_BIT IN2 Output ENO: outputs EN value as it is
OUT: OR result

IN1, IN2, OUT must be of all the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○

■ Function

It performs a logical OR on the input variables by bit and produces output, OUT.
IN1 1111 ..... 0000
OR
IN2 1010 ..... 1010
OUT 1111 ..... 1010

6-74
Chapter6 Basic Function

■ Program Example

1. LD

2. ST
%QB0.0 := OR2_BYTE(EN:=%MX0, IN1:=%MB10, IN2:=ABC);

(1) If the transition condition (%MX0) is on, function OR executes.


(2) The result of a logic sum (OR) for %MB10 = 2#1100_1100 and ABC = 2#1111_0000 is produced in %QB0.0 =
2#1111_1100

6-75
Chapter6 Basic Function

REAL type conversion


REAL_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


REAL_TO_***
BOOL EN ENO BOOL IN: the REAL value to be converted
ANY_INT,DWORD Output ENO: without an error, it is 1.
REAL IN OUT
LREAL,STRING
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

It converts the IN type and outputs it as OUT.

Function Output Type Description


If integer part of input is -128 ∼ 127, normal conversion. Otherwise
REAL_TO_SINT SINT
an error occurs. (Decimals round-off)
If integer part of input is -32,768 ∼ 32,767, normal conversion.
REAL_TO_INT INT
Otherwise an error occurs. (Decimals round-off)
If integer part of input is -231 ∼ 231-1, normal conversion. Otherwise an
REAL_TO_DINT DINT
error occurs. (Decimals round-off)
If integer part of input is -263 ∼ 263-1, normal conversion. Otherwise an
REAL_TO_LINT LINT
error occurs. (Decimals round-off)
If integer part of input is 0 ∼ 255, normal conversion. Otherwise an
REAL_TO_USINT USINT
error occurs. (Decimals round-off)
If integer part of input is 0 ∼ 65,535, normal conversion. Otherwise
REAL_TO_UINT UINT
an error occurs. (Decimals round-off)
If integer part of input is 0 ∼ 232-1, normal conversion. Otherwise an
REAL_TO_UDINT UDINT
error occurs. (Decimals round-off)
If integer part of input is 0 ∼ 264-1, normal conversion. Otherwise an
REAL_TO_ULINT ULINT
error occurs. (Decimals round-off)
REAL_TO_DWORD DWORD Converts into DWORD type without changing the internal bit array.

6-76
Chapter6 Basic Function

Function Output Type Description


REAL_TO_LREAL LREAL Converts REAL into LREAL type normally.

■ Flag

Flag Description

If overflow occurs (input value is greater than the value to be stored in output type), _ERR, _LER flags
_ERR
are set. If an error occurs, the output is 0.

■ Program Example
1. LD
REAL_TO
%MX0 _***
EN ENO

REAL_VAR IN OUT DINT_VAR

2. ST

ST language doesn’t support REAL_TO_***


In case of REAL_TO_DINT

DINT_VAR := REAL_TO_DINT(EN:=%MX0, IN:=REAL_VAR);

(1) If the transition condition (%MX0) is on, function REAL_TO_*** executes.


(2) If REAL_VAL (REAL type) = 1.234E4, DINT_VAL (DINT) = 12,340.

INPUT (IN) : REAL_VAL (REAL) = 1.234E4


(REAL_TO_DINT)
OUTPUT (OUT) : DINT_VAL (DINT) = 12,340

6-77
Chapter6 Basic Function

Rotate to Left
ROL Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1

ROL IN: the value to be rotated


BOOL EN ENO BOOL N: bit number to rotate
*ANY_BIT IN OUT *ANY_BIT
INT N
Output ENO: outputs EN value as it is
OUT: the rotated value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT.

■ Function

It rotates input IN to the left as many as N bit number.

1 0 1 0 0 0 1 1

1 0 0 0 1 1 1 0 N (when N=2)

6-78
Chapter6 Basic Function

■ Program Example

This is the program that rotates the value of input data (2#1100_1100_1100_1100:16#CCCC) to the left by 3 bits if
input %IX0.0 is on.

1. LD

2. ST

OUT_VALUE := ROL(EN:=%IX0.0, IN:=IN_VALUE, N:=3);

(1) Set input variable IN_VALUE to rotate.


(2) Set the value to be rotated.
(3) Set output variable to output the rotated data value as OUT_VALUE.
(4) If the transition condition (%IX0.0) is on, function ROL executes and a data bit set as input variable is rotated to the
left by 3 bits and produces output, OUT_VALUE..

INPUT (IN) : IN_VALUE (WORD) = 16#CCCC 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0


(N) : 3 (ROL)

OUTPUT (OUT) :OUT_VALUE (WORD) =16#6666 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0

6-79
Chapter6 Basic Function

1.41. ROR

Rotate to right
ROR Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


ROR IN: the value to be rotated
BOOL EN ENO BOOL
*ANY_BIT IN OUT *ANY_BIT N: bit number to rotate
INT N
Output ENO: outputs EN value as it is
OUT: the rotated value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY type.

■ Function
It rotates input IN to the right as many as N bit number.

1 0 1 0 0 0 1 1

1 1 1 0 1 0 0 0
N

6-80
Chapter6 Basic Function

■ Program Example

This is the program that rotates input data value (2#1110_0011_0011_0001: 16#E331) to the right by 3 bits if
input %I0.0 is on.

1. LD

2. ST

OUT_VALUE := ROR(EN:=%IX0.0, IN:=IN_VALUE, N:=3);

(1) Set input variable of a data value to rotate as IN_VALUE.


(2) Insert bit number 3 into bit number input N.
(3) If the transition condition (%IX0.0) is on, function ROR (rotate Right) executes and data bit set as input variable is
rotated to the right by 3 bits and produces output ,OUT_VALUE.

INPUT (IN): IN_VALUE (WORD) = 16#E331 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1


(N) : 3 (ROR)

OUTPUT (OUT): OUT_VALUE (WORD) = 16#3C66 0 0 1 1 1 1 0 0 0 1 1 0 0 1 1 0

6-81
Chapter6 Basic Function

1.42. SEL

1.43. SHL

Shift Left
SHL Availability XGF-M32E
Flags

Function Description

Input EN: If EN is 1, function is executes.


IN: bit string to be shifted
SHL
BOOL EN ENO BOOL N: bit number to be shifted
*ANY_BIT IN OUT *ANY_BIT
INT N
Output ENO: outputs EN value as it is
OUT: the shifted value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT.

■ Function

1. It shifts input IN to the left as many as N bit number.


2. N number bit on the rightmost of input IN is filled with 0.

1 0 1 0 0 0 1 1

1 0 0 0 1 1 0 0
N will be filled with 0

6-82
Chapter6 Basic Function

■ Program Example

This is the program that shifts input data value (2#1100_1100_1100_1100:16#CCCC) to the left by 3 bits if
input %IX0.0 is on

1. LD

2. ST

OUT_VALLUE := SHL(EN:=%IX0.0, IN:=IN_VALUE, N:=3);

(1) Set the input variable IN_VALUE (2#1100_1100_1100_1100: 16#CCCC).


(2) Insert bit number 3 into N.
(3) If the transition condition (%IX0.0.0) is on, function SHL (shift Left) executes and data bit set as input variable
shifts to the left by 3 bits and produces output, OUT_VALUE.

INPUT (IN) : IN_VALUE (WORD) = 16#CCCC 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0


(N) : 3 (ROL)

OUTPUT (OUT) : OUT_VALUE (WORD) = 16#6660 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 0

6-83
Chapter6 Basic Function

1.44. SHR

Shift Right
SHR Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1

SHR IN: bit string to be shifted


BOOL EN ENO BOOL N: bit number to be shifted
*ANY_BIT IN OUT *ANY_BIT
INT N
Output ENO: outputs EN value as it is
OUT: the shifted value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT.

■ Function

1. It shifts input IN to the right as many as N bit number.


2. N number bit on the leftmost of input IN is filled with 0.

1 0 1 0 0 0 1 1

0 0 1 0 1 0 0 0
N will be filled with 0

6-84
Chapter6 Basic Function

■ Program Example

1. LD

%MX0 SHR
EN ENO

IN_VALUE IN OUT OUT_VALUE


3 N

2. ST

OUT_VALUE := SHR(EN:=%MX0, IN:=IN_VALUE, N:=3);

(1) If the transition condition (%MX0) is on, function SHL (Shift Left) executes.
(2) Data bit set as input variable shift to the right by 3 bits and produces outputs, OUT_VALUE.

INPUT (IN) : IN_VALUE (WORD) = 16#E331 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1


(ROR
(N) : 3
)
OUTPUT (OUT) : OUT_VALUE (WORD) = 16#1C66 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0

6-85
Chapter6 Basic Function

1.45. SIN

Sine operation
SIN Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: input value of Sine operation (radian)
SIN
BOOL EN ENO BOOL
Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: Sine operation result value

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

Finds the Sine operation value of IN and produces output, OUT.


OUT = SIN (IN)

■ Program Example

1. LD

6-86
Chapter6 Basic Function

2. ST

RESULT := SIN(EN:=IX0.0, IN:=INPUT);

(1) If the transition condition (%IX0.0) is on, function SIN (Sine operation) executes.
(2) If the value of input variable INPUT is 1.0471 .. . (π/3 rad = 60°), RESULT declared as output variable is 0.8660 ....

( 3 /2 ). SIN(π/3) = 3 /2 = 0.8660

INPUT (IN) : INPUT (REAL) = 1.0471


(SIN)
OUTPUT (OUT) : RESULT (REAL) = 8.65976572E-01

6-87
Chapter6 Basic Function

SINT type conversion


SINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


SINT_TO_*** IN: short Integer value
BOOL EN ENO BOOL
SINT IN OUT *ANY
Output ENO: without an error, it is 1.
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude SINT, TIME, DATE, TOD and DT from ANY type.

■ Function

It converts the IN type and outputs it as OUT.

Function Output type Description


SINT_TO_INT INT Converts into INT type normally.
SINT_TO_DINT DINT Converts into DINT type normally.
SINT_TO_LINT LINT Converts into LINT type normally.
SINT_TO_USINT USINT If input is 0 ∼ 127, normal conversion. Otherwise an error occurs.
SINT_TO_UINT UINT If input is 0 ∼ 127, normal conversion. Otherwise an error occurs.
SINT_TO_UDINT UDINT If input is 0 ∼ 127, normal conversion. Otherwise an error occurs.
SINT_TO_ULINT ULINT If input is 0 ∼ 127, normal conversion. Otherwise an error occurs.
SINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
SINT_TO_BYTE BYTE Converts into BYTE type without changing the internal bit array.
SINT_TO_WORD WORD Converts into WORD type filling the upper bits with 0.
SINT_TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
SINT_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
SINT_TO_REAL REAL Converts SINT into REAL type normally.
SINT_TO_LREAL LREAL Converts SINT into LREAL type normally.

6-88
Chapter6 Basic Function

■ Flag

Flag Description

If a conversion error occurs, _ERR and _LER flags are set. If an error occurs, take the lower bits
_ERR
as many as bit number of output type and output it without changing the internal bit array.

■ Program Example

1. LD
%MX0 SINT_TO_***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support SINT_TO_***


In case of SINT_TO_BYTE

OUT_VAL := SINT_TO_BYTE(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function SINT_TO_*** executes.


(2) If input variable IN_VAL (SINT type) = 64 (2#0100_0000), output variable OUT_VAL (BYTE type) = 16#40
(2#0100_0000).

INPUT (IN) : IN_VAL (SINT) = 64(16#40) 0 1 0 0 0 0 0 0


(SINT_TO_BYTE)

OUTPUT (OUT) : OUT_VAL (BYTE) = 16#64(16#64) 0 1 1 0 0 1 0 0

6-89
Chapter6 Basic Function

1.46. SQRT

Square root operation


SQRT Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input value of square root operation
SQRT
BOOL EN ENO BOOL
ANY_REAL IN OUT ANY_REAL Output ENO: without an error, it is 1.
OUT: square root value

IN, OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It finds the square root value of IN and output it as OUT.

OUT = IN

■ Flag

Flag Description
_ERR If the value of IN is a negative number, _ERR and _LER flag are set.

■ Program Example

1. LD
%MX0 SQRT
EN ENO

INPUT IN OUT RESULT

6-90
Chapter6 Basic Function

2. ST

RESULT := SQRT(EN:=%MX0, IN:=INPUT);

(1) If the transition condition (%MX0) is on, function SQRT (square root operation) executes.
(2) If the value of input variable declared as INPUT is 9.0, RESULT declared as output variable is 3.0.

9.0 = 3.0

INPUT (IN) : INPUT (REAL) = 9.0

(SQRT)

OUTPUT (OUT) : RESULT (REAL) = 3.0

6-91
Chapter6 Basic Function

1.47. STRING_

1.48. SUB

Subtraction
SUB Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: the value to be subtracted
SUB
BOOL EN ENO BOOL IN2: the value to subtract

ANY_NUM IN1 OUT ANY_NUM


Output ENO: without an error, it is 1.
ANY_NUM IN2 OUT: the subtracted result value

The variables connected to IN1, IN2 and OUT must be of all


the same data type.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

It subtracts IN2 from IN1 and outputs it as OUT.


OUT = IN1 ― IN2

■ Flag

Flag Description
_ERR If output value is out of range of related data type, _ERR and _LER flags are set.

☆ If LREAL type operation exceeds the maximum or minimum value in the middle of operation because it performs
operation serially from IN1 to IN8, _ERR,_LER flag is set and the result is an unlimited or abnormal value.
(1.#INF000000000000e+000, 1.#SNAN00000000000e+000, 1.#QNAN00000000000e+000)

6-92
Chapter6 Basic Function

■ Program Example
1. LD

%MX0 SUB
EN ENO

VALUE1 IN1 OUT OUT_VAL


VALUE2 IN2

2. ST

OUT_VAL := SUB(EN:=%MX0, IN1:=VALUE1, IN2:=VALUE2);

(1) If the transition condition (%MX0) is on, function SUB executes.


(2) If input variables VALUE1 = 300, VALUE2 = 200, OUT_VAL is 100 after the operation.

INPUT (IN1) : VALUE1 (INT) = 300(16#012C) 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0


-(SUB)

(IN2) : VALUE2(INT) = 200(16#00C8) 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0

OUTPUT (OUT) : OUT_VAL (INT) = 100(16#0064) 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0

6-93
Chapter6 Basic Function

1.49. SUB_DATE

Date subtraction
SUB_DATE Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN1: standard date
SUB_DATE
IN2: the date to subtract
BOOL EN ENO BOOL
DATE IN1 OUT TIME
DATE IN2 Output ENO: without an error, it is 1.
OUT: produces the difference between two dates as
time data.

■ Function

It subtracts IN2 (specific date) from IN1 (standard date) and outputs the difference between two dates as OUT.

■ Flag

Flag Description

If output value is out of range (TIME data type), _ERR and _LER flags are set.
_ERR An error occurs: 1) when date difference exceeds the range of TIME data type
(T#49D17H2M47S295MS); 2) the result of date operation is a negative number.

■ Program Example
1. LD

6-94
Chapter6 Basic Function

2. ST

WORK_DAY := SUB_DATE(EN:=%IX0.0, IN1:=CURRENT_DATE, IN2:=START_DATE);

(1) If the transition condition (%IX0.0) is on, function SUB_DATE executes.


(2) If input variable CURRENT_DATE is D#1995-12-15 and START_DATE is D#1995-11-1, the working days
declared as output variable WORK_DAY is T#44D.

INPUT (IN1) : CURRENT_DATE (DATE) = D#1995-12-15


(SUB_DATE)
(IN2) : START_DATE(DATE) = D#1995-11-1

OUTPUT (OUT) : WORK_DAY (TIME) = T#44D

6-95
Chapter6 Basic Function

1.50. SUB_DT

Date and Time subtraction


SUB_DT Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1

SUB_DT IN: standard date and time of day


BOOL EN ENO BOOL IN2: date and time of day to subtract
DATE_AND_TIME IN1 OUT TIME
DATE_AND_TIME IN2
Output ENO: without an error, it is 1.
OUT: the subtracted result time

■ Function

It subtracts IN2 (specific date and time of day) from IN1 (standard date and time of day) and outputs the time difference as
OUT.

■ Flag

Flag Description

If output value is out of range of TIME data type, _ERR and _LER flags are set.
_ERR
If the result of date and time of day subtraction operation is a negative number, an error occurs.

■ Program Example
1. LD

%MX0 SUB_DT
EN ENO

CURRENT_DT IN1 OUT WORK_TIME


START_DT IN2

6-96
Chapter6 Basic Function

2. ST

WORK_TIME := SUB_DT(EN:=%MX0, IN1:=CURRNET_DT, IN2:=START_DT);

(1) If the transition condition (%MX0) is on, function SUB_DT (Time and Date subtraction) executes.
(2) If the current date and time of day CURRENT_DT is DT#1995-12-15-14:30:00 and the starting date and the time of
day to work START_DT is DT#1995-12-13-12:00:00, the continuous working time declared as output variable
WORK_TIME is T#2D2H30M.

INPUT (IN1) : CURRENT_DT (DT) = DT#1995-12-15-14:30:00


(SUB_DATE)
(IN2) : START_DT(DT) = DT#1995-12-13-12:00:00

OUTPUT (OUT) : WORK_TIME (TIME) = T#2D2H30M

6-97
Chapter6 Basic Function

1.51. SUB_TIME

Time subtraction
SUB_TIME Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1

SUB_TIME
IN1: standard time of day
BOOL EN ENO BOOL IN2: the time to subtract
TIME,TOD,DT IN1 OUT TIME,TOD,DT Output ENO: without an error, it is 1.
TIME IN2 OUT: the subtracted result time or time of day

OUT data type is the same as the input IN1 type.


That is, if IN1 type is TIME, OUT type must be TIME.
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN1 ○ ○ ○
OUT ○ ○ ○

■ Function

1. If IN1 is TIME, it subtracts the time from the standard time and produces OUT (time difference).
2. If IN1 is TIME_OF_DAY, it subtracts the time from the standard time of day and outputs the time of a day as OUT.
3. If IN1 is DATE_AND_TIME, it subtracts the time from the standard date and the time of day and produces the date
and the time of day as OUT.

■ Flag

Flag Description

If the output value is out of range of related data type, _ERR and _LER flags are set.
_ERR If the result subtracting the time from the standard time is a negative number or the result subtracting
the time from the time of day is a negative number, an error occurs.

6-98
Chapter6 Basic Function

■ Program Example
1. LD

2. ST

TIME_TO_GO := SUB_TIME(EN:=%IX0.0, IN1:=TARGET_TIME, IN2:=ELABSED_TIME);

(1) If the transition condition (%IX0.0) is on, function SUB_TIME (time subtraction) executes.
(2) If total working time declared as input variable TARGET_TIME is T#2H30M, the elapsed time ELAPSED_TIME is
T#1H10M30S300MS, the remaining working time declared as output variable TIME_TO_GO is
T#1H19M29S700MS.

INPUT (IN1) : TARGET_TIME (TIME) = T#2H30M


(SUB_DATE)
(IN2) : ELAPSED_TIME(TIME) = T#1H10M30S300MS

OUTPUT (OUT) : TIME_TO_GO (TIME) = T#1H19M29S700MS

6-99
Chapter6 Basic Function

1.52. SUB_TOD

TOD Subtraction
SUB_TOD Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1

SUB_TOD IN1: standard time of day


BOOL EN ENO BOOL IN2: the time of day to subtract
TIME_OF_DAY IN1 OUT TIME
TIME_OF_DAY IN2
Output ENO: without an error, it is 1
OUT: the subtracted result time

■ Function

It subtracts the IN2 (specific time of day) from IN1 (standard time of day) and outputs the time difference as OUT.

■ Flag

Flag Description
_ERR If the result subtracting the time of day from the time of day is a negative number, an error occurs.

■ Program Example

1. LD

6-100
Chapter6 Basic Function

2. ST

WORK_TIME := SUB_TOD(EN:=%IX0.0, IN1:=END_TIME, IN2:=START_TIME);

(1) If the transition condition (%IX0.0) is on, function SUB_TOD (time of day subtraction) executes.
(2) If END_TIME declared as input variable is TOD#14:20:30.500 and the starting time to work, START_TIME is
TOD#12:00:00, the required time to work, WORK_TIME declared as output variable is T#2H20M30S500MS.

INPUT (IN1) : END_TIME (TOD) = TOD#14:20:30.500


(SUB_TOD)
(IN2) : START_TIME(TOD) = TOD#12:00:00

OUTPUT (OUT) : WORK_TIME (TIME) = T#2H20M30S500MS

6-101
Chapter6 Basic Function

1.53. TAN

Tangent Operation
TAN Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: tangent input value (radian)
TAN
BOOL EN ENO BOOL
Output ENO: outputs EN value as it is
ANY_REAL IN OUT ANY_REAL
OUT: the result value of Tangent operation

IN, OUT must be of the same data type


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It performs Tangent operation of IN and produces output, OUT.


OUT = TAN(IN)

■ Program Example

1. LD
%MX0 TAN
EN ENO

INPUT IN OUT RESULT

6-102
Chapter6 Basic Function

2. ST

RESULT := TAN(EN:=%MX0, IN:=INPUT);

(1) If the transition condition (%MX0) is on, function TAN (Tangent operation) executes.
(2) If the value of input variable declared as INPUT is 0.7853... (π/4 rad = 45°), RESULT declared as output variable is
1.0000.

TAN(π/4) = 1

INPUT (IN) : INPUT (REAL) = 0.7853

(TAN)

OUTPUT (OUT) : RESULT (REAL) = 9.99803722E-01

6-103
Chapter6 Basic Function

1.54. ***

TIME type conversion


TIME_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


TIME_TO_***
IN: time data to be converted
BOOL EN ENO BOOL

DWORD,UDINT
TIME IN OUT Output ENO: outputs EN value as it is
STRING
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○

■ Function

It converts the IN type and produces OUT.

Function Output type Description


Converts TIME into UDINT type. It converts only data type without
TIME_TO_UDINT UDINT
changing the data (internal bit array state).
Converts TIME into DWORD type. It converts only data type without
TIME_TO_DWORD DWORD
changing the data (internal bit array state).

6-104
Chapter6 Basic Function

■ Program Example
1. LD
TIME_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support TIME_TO_***


In case of TIME_TO_UDINT

OUT_VAL := TIME_TO_UDINT(EN:=%MX0, IN:=IN_VAL);

(1) If the transition condition (%MX0) is on, function TIME_TO_*** executes.


(2) If input variable IN_VAL (TIME) = T#120MS, output variable OUT_VAL (UDINT) = 120.

INPUT (IN) : IN_VAL (TIME) = T#120MS(16#78) 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0


(TIME_TO_UDINT)

OUTPUT (OUT) : OUT_VAL (UDINT) = 120(16#78) 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0

6-105
Chapter6 Basic Function

1.55. TOD_TO_***

TOD type conversion


TOD_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


TOD_TO_***
IN: time of a day data to be converted
BOOL EN ENO BOOL
DWORD,UDINT
TIME 0F DAY IN OUT
STRING Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○

■ Function

It converts the IN type and outputs it as OUT.

Output
Function Description
type
Converts TOD into UDINT type.
TOD_TO_UDINT UDINT
Converts only data type without changing a data (internal bit array state).
Converts TOD into DWORD type.
TOD_TO_DWORD DWORD
Converts only data type without changing a data (internal bit array state).

6-106
Chapter6 Basic Function

■ Program Example

1. LD
TOD_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support TIME_TO_***


In case of TIME_TO_UDINT

OUT_VAL := TOD_TO_ (EN:=%MX0, IN:=IN_VAL);

(1) If the transition condition (%MX0) is on, function TOD_TO_*** executes.


(2) If input variable IN_VAL (TOD) = TOD#12:00:00, output variable OUT_VAL = ‘TOD#12:00:00’.

INPUT (IN) : IN_VAL (TOD) = TOD#12:00:00

(TOD_TO_STRING)

OUTPUT (OUT) : OUT_VAL (STRING) = 'TOD#12:00:00'

6-107
Chapter6 Basic Function

RUNC

UDINT type conversion


UDINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


UDINT_TO_*** IN: Unsigned Double Integer value to be converted
BOOL EN ENO BOOL
UDINT IN OUT *ANY Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude UDINT, DATE and DT from ANY type.

■ Function

It converts the IN type and outputs it as OUT.

Output
Function Description
type
UDINT_TO_SINT SINT If input is 0~127, normal conversion. Otherwise an error occurs.
UDINT_TO_INT INT If input is 0~32,767, normal conversion. Otherwise an error occurs.
If input is 0~2,147,483,647, normal conversion. Otherwise an error
UDINT_TO_DINT DINT
occurs.
UDINT_TO_LINT LINT Converts UDINT into LINT type normally.
UDINT_TO_USINT USINT If input is 0~255, normal conversion. Otherwise an error occurs.
UDINT_TO_UINT UINT If input is 0~65,535, normal conversion. Otherwise an error occurs.
UDINT_TO_ULINT ULINT Converts UDINT into ULINT type normally.
UDINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
UDINT_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
UDINT_TO_WORD WORD Takes the lower 16 bits and converts into WORD type.
UDINT_TO_DWORD DWORD Converts into DWORD type without changing the internal bit array.
UDINT_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.

6-108
Chapter6 Basic Function

Output
Function Description
type
Converts UDINT into REAL type.
UDINT_TO_REAL REAL
During the conversion, an error caused by the precision may occur.

Converts UDINT into LREAL type.


UDINT_TO_LREAL LREAL
During the conversion, an error caused by the precision may occur.
Converts into TOD type without changing the internal bit array. However,
UDINT_TO_TOD TOD with a value out of TOD range (TOD#23:59:59.999), _ERR, _LER flags
are set and it is alternately converted within the range of TOD.
UDINT_TO_TIME TIME Converts into TIME type without changing the internal bit array.

■ Flag

Flag Description
If a conversion error occurs, _ERR and _LER flags are set. If an error occurs, take the lower bits
_ERR as many as a bit number of an output data type and produces the output without changing the
internal bit array.

■ Program Example
1. LD
UDINT_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support UDINT_TO_***


In case of UDINT_TO_TIME

OUT_VAL := UDINT_TO_TIME(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function UDINT_TO_*** will be executed.
(2) If input variable IN_VAL (UDINT) = 123, output variable OUT_VAL (TIME) = T#123MS.

INPUT (IN) : IN_VAL (UDINT) = 123

OUTPUT (OUT) : OUT_VAL (TIME) = T#123MS

6-109
Chapter6 Basic Function

1.56. UINT_TO_***

UINT type conversion


UINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


UINT_TO_*** IN: Unsigned Integer value to be converted
BOOL EN ENO BOOL
UINT IN OUT *ANY
Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude UINT, TIME, TOD and DT from ANY type.

■ Function

It converts the IN type and outputs it as OUT.

Function Output type Description


UINT_TO_SINT SINT If input is 0~127, normal conversion. Otherwise an error occurs.
UINT_TO_INT INT If input is 0~32,767, normal conversion. Otherwise an error occurs.
UINT_TO_DINT DINT Converts UINT into UDINT type normally.
UINT_TO_LINT LINT Converts UINT into ULINT type normally.
UINT_TO_USINT USINT If input is 0~255, normal conversion. Otherwise an error occurs.
UINT_TO_UDINT UDINT Converts UINT into UDINT type normally.
UINT_TO_ULINT ULINT Converts UINT into ULINT type.
UINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
UINT_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.
UINT_TO_WORD WORD Converts into WORD type without changing the internal bit array.
UINT_TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
UINT_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
UINT_TO_REAL REAL Converts UINT into REAL type.
UINT_TO_LREAL LREAL Converts UINT into LREAL type.
UINT_TO_DATE DATE Converts into DATE type without changing the internal bit array.

6-110
Chapter6 Basic Function

■ Flag

Flag Description

If a conversion error occurs, _ERR and _LER flags are set. If error occurs, it takes as many
_ERR lower bits as a bit number of output type and produces an output without changing its internal bit
array.

■ Program Example
1. LD
UINT_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support UINT_TO_***


In case of UINT_TO_WORD

OUT_VAL := UINT_TO_WORD(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function UINT_TO_*** executes.


(2) If input variable IN_VAL (UINT) = 255 (2#0000_0000_1111_1111), output variable OUT_VAL (WORD) =
2#0000_0000_1111_1111.

INPUT (IN) : IN_VAL (UINT) = 255 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1


(UINT_TO_WORD)

OUTPUT (OUT) : OUT_VAL (WORD) = 16#FF 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

6-111
Chapter6 Basic Function

1.57. ULINT_TO_***

ULINT type conversion


ULINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


ULINT_TO_*** IN: Unsigned Long Integer value to be converted
BOOL EN ENO BOOL
ULINT IN OUT *ANY Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude UINT, TIME, TOD and DT from ANY type.

■ Function

It converts the IN type and outputs it as OUT.


Function Output type Description
ULINT_TO_SINT SINT If input is 0~127, normal conversion. Otherwise an error occurs.
ULINT_TO_INT INT If input is 0~32,767, normal conversion. Otherwise an error occurs.

ULINT_TO_DINT DINT If input is 0~231-1, normal conversion. Otherwise an error occurs.

ULINT_TO_LINT LINT If input is 0~263-1, normal conversion. Otherwise an error occurs.


ULINT_TO_USINT USINT If input is 0~255, normal conversion. Otherwise an error occurs.
ULINT_TO_UINT UINT If input is 0~65,535, normal conversion. Otherwise an error occurs.

ULINT_TO_UDINT UDINT If input is 0~232-1, normal conversion. Otherwise an error occurs.

ULINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.

ULINT_TO_BYTE BYTE Takes the lower 8 bits and converts into BYTE type.

ULINT_TO_WORD WORD Takes the lower 16 bits and converts into WORD type.

ULINT_TO_DWORD DWORD Takes the lower 32 bits and converts into DWORD type.

ULINT_TO_LWORD LWORD Converts into LWORD type without changing the internal bit array.

Converts ULINT into REAL type.


ULINT_TO_REAL REAL
During the conversion, an error caused by the precision may occur.
Converts ULINT into LREAL type.
ULINT_TO_LREAL LREAL
During the conversion, an error caused by the precision may occur.

6-112
Chapter6 Basic Function

■ Flag

Flag Description

If a conversion error occurs, _ERR and _LER flags are set. If error occurs, it takes as many lower
_ERR
bits as a bit number of output type and produces an output without changing its internal bit array

■ Program Example
1. LD
ULINT_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support ULINT_TO_***


In case of ULINT_TO_LINT

OUT_VAL := ULINT_TO_LINT(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function ULINT_TO_*** executes.


(2) If input variable IN_VAL (ULINT) = 123,567,899, then output variable OUT_VAL (LINT) = 123,567,899.

INPUT (IN) : IN_VAL (ULINT) = 123,567,899

(ULINT_TO_LINT)

OUTPUT (OUT) : OUT_VAL (LINT) = 123,567,899

6-113
Chapter6 Basic Function

1.58. USINT_TO_***

USINT type conversion


USINT_TO_*** Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


USINT_TO_***
IN: To convert Unsigned Short Integer value.
BOOL EN ENO BOOL
USINT IN OUT *ANY
Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude USINT, TIME, DATE, TOD and DT from ANY type.

■ Function

It converts the IN type and outputs it as OUT.


Function Output type Description
USINT_TO_SINT SINT If input is 0~127, normal conversion. Otherwise an error occurs.
USINT_TO_INT INT Converts USINT into INT type normally.
USINT_TO_DINT DINT Converts USINT into DINT type normally.
USINT_TO_LINT LINT Converts USINT into LINT type normally.
USINT_TO_UINT UINT Converts USINT into UINT type normally.
USINT_TO_UDINT UDINT Converts USINT into UDINT type normally.
USINT_TO_ULINT ULINT Converts USINT into ULINT type normally.
USINT_TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
USINT_TO_BYTE BYTE Converts into BYTE type without changing the internal bit array.
USINT_TO_WORD WORD Converts into WORD type filling the upper bits with 0.
USINT_TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
USINT_TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
USINT_TO_REAL REAL Converts USINT into REAL type.
USINT_TO_LREAL LREAL Converts USINT into LREAL type.

6-114
Chapter6 Basic Function

■ Flag

Flag Description

If a conversion error occurs, _ERR and _LER flags are set. If error occurs, it takes as many lower
_ERR
bits as a bit number of output type and produces an output without changing its internal bit array.

■ Program Example

1. LD

USINT_TO
%MX0 _***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support USINT_TO_***


In case of USINT_TO_SINT

OUT_VAL := USINT_TO_SINT(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function ULINT_TO_*** executes.


(2) If input variable IN_VAL (USINT) = 123, output variable OUT_VAL (SINT) = 123.

INPUT (IN) : IN_VAL (USINT) = 123(16#7B) 0 1 1 1 1 0 1 1


(UINT_TO_SINT)

OUTPUT (OUT) : OUT_VAL (SINT) = 123(16#7B) 0 1 1 1 1 0 1 1

6-115
Chapter6 Basic Function

1.59. WDT_RST

1.60. WORD_TO_***

WORD type conversion


WORD_TO_*** Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


WORD_TO_*** IN: Bit string to be converted (16 bit)
BOOL EN ENO BOOL
WORD IN OUT *ANY
Output ENO: outputs EN value as it is
OUT: type-converted data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable

OUT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
*ANY: exclude WORD, REAL, LREAL, TIME, TOD and DT from ANY type.

■ Function
It converts the IN type and outputs it as OUT.
Function Output type Description
WORD _TO_SINT SINT Takes the lower 8 bits and converts into SINT type.
WORD _TO_INT INT Converts into INT type without changing the internal bit array.
WORD _TO_DINT DINT Converts into DINT type filling the upper bits with 0.
WORD _TO_LINT LINT Converts into LINT type filling the upper bits with 0.
WORD _TO_USINT USINT Takes the lower 8 bits and converts into SINT type.
WORD _TO_UINT UINT Converts into INT type without changing the internal bit array.
WORD _TO_UDINT UDINT Converts into DINT type filling the upper bits with 0.
WORD _TO_ULINT ULINT Converts into LINT type filling the upper bits with 0.
WORD _TO_BOOL BOOL Takes the lower 1 bit and converts into BOOL type.
WORD _TO_BYTE BYTE Takes the lower 8 bits and converts into SINT type.
WORD _TO_DWORD DWORD Converts into DWORD type filling the upper bits with 0.
WORD _TO_LWORD LWORD Converts into LWORD type filling the upper bits with 0.
WORD _TO_DATE DATE Converts into DATE type without changing the internal bit array.

6-116
Chapter6 Basic Function

■ Program Example
1. LD
%MX0 WORD_TO_***
EN ENO

IN_VAL IN OUT OUT_VAL

2. ST

ST language doesn’t support WORD_TO_***


In case of WORD_TO_INT

OUT_VAL := WORD_TO_INT(EN:=%MX0, IN:=IN_VAL);

(1) If the input condition (%MX0) is on, function WORD-TO-*** executes.


(2) If input variable IN_VAL (WORD) = 2#0001_0001_0001_0001, output variable OUT_VAL (INT) = 4,096 + 256 +
16 + 1 = 4,369

INPUT (IN) : IN_VAL (WORD) = 16#1111 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1


(WORD_TO_INT)

OUTPUT (OUT) : OUT_VAL (INT) = 4,369 (16#1111) 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1

6-117
Chapter6 Basic Function

1.61. XOR

Exclusive OR
XOR Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN1: the value to be XOR
IN2: the value to be XOR
XOR
BOOL EN ENO BOOL Input variable number can be extended up to 8.
ANY_BIT IN1 OUT ANY_BIT
ANY_BIT IN2
Output ENO: outputs EN value as it is
OUT: the result of XOR operation

IN1, IN2, OUT must be of all the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
ANY type variable
IN ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○

■ Function

1. Do XOR operation for IN1 and IN2 per bit and to produces OUT.
IN1 1111 ..... 0000
XOR
IN2 1010 ..... 1010
OUT 0101 ..... 1010

6-118
Chapter6 Basic Function

■ Program Example

1. LD

2. ST

ST language doesn’t support XOR


In case of XOR2_BYTE

%QB0.0 := XOR2_BYTE(EN:=%MX0, IN1:=%MB10, IN2:=ABC);

(1) If the transition condition (%MX0) is on, function XOR executes.


(2) If input variable %MB10 = 1100_1100, ABC = 1111_0000, the result of XOR operation for two inputs is %QB0.0 =
0011_1100.

INPUT (IN1) : %MB10 (BYTE) = 16#CC 1 1 0 0 1 1 0 0

XOR

(IN2) : ABC(BYTE) = 16#F0 1 1 1 1 0 0 0 0

OUTPUT (OUT) : %QB0.0.0 (BYTE) = 16#3C 0 0 1 1 1 1 0 0

6-119
Chapter6 Basic Function

6-120
Chapter7 Application Function

Chapter 7 Application Function


This chapter describes application functions unlike the basic functions described in the previous chapter

1.1. _BYT

Combines 8 bits into BYTE


BIT_BYTE Availability XGF-M32E
Flags

Function Description

BIT_BYTE
Input EN: executes the function in case of 1.
BOOL EN ENO BOOL
IN1 ~ IN8: Bit input
BOOL IN1 OUT BYTE
BOOL IN2 Output ENO: without an error, it is 1
BOOL IN3 OUT: Byte output
BOOL IN4
BOOL IN5
BOOL IN6
BOOL IN7
BOOL IN8

■ Function

It combines 8 bits into one byte.


IN8: MSB (Most Significant Bit), IN1: LSB (Least Significant Bit).

7-1
Chapter7 Application Function

■ Program Example

1. LD
%MX3 BIT_BYTE
EN ENO

INPUT1 IN1 OUT OUTPUT

INPUT2 IN2

INPUT3 IN3

INPUT4 IN4

INPUT5 IN5

INPUT6 IN6

INPUT7 IN7

INPUT8 IN8

2. ST

OUTPUT := BIT_BYTE(EN:=%MX3, IN1:=INPUT1, IN2:=INPUT2, IN3:=INPUT3, IN4:=INPUT4, IN5:=INPUT5,


IN6:=INPUT6,
IN7:=INPUT7, IN8:=INPUT8);

(1) If the transition condition (%MX3) is on, BIT_BYTE function executes.


(2) If 8 input are (from INPUT1 to INPUT 8) {0,1,1,0,1,1,0,0}, OUTPUT (BYTE) = 2#0110_1100.

7-2
Chapter7 Application Function

BMOV

1.2. BSUM

Counts on-bit number of input


BSUM Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1.


IN: input data to detect on bit

Output ENO: outputs EN value as it is


OUT: Result data (sum of on-bit number)
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable

IN ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. If EN is 1, it counts bit number of 1 among IN bit string and produces output, OUT.
2. Input data types are BYTE, WORD, DWORD and LWORD.

Function IN type Description


BSUM BYTE
BSUM WORD
You can select one of these functions according to input data.
BSUM DWORD
BSUM LWORD

7-3
Chapter7 Application Function

■ Program Example
1. LD

2. ST

ON_COUNT := BSUM(EN:=%MX0, IN:=SWITCHS);

(1) If the transition condition (%MX0) is on, BSUM function executes.


(2) If input SWITCHS (WORD) = 2#0000_0100_0010_1000, then it counts on-bit number, 3. So the output
ON_COUNT (INT) = 3.

7-4
Chapter7 Application Function

1.3. BIT
Divides byte into 8 bits
BYTE_BIT Availability XGF-M32E
Flags

Function Description

BYTE_BIT Input EN: executes the function in case of 1.


BOOL EN ENO BOOL IN: BYTE input
BYTE IN Q01 BOOL
Q02 BOOL Output ENO: outputs EN value as it is
QO1~8: bit output
Q03 BOOL
Q04 BOOL
Q05 BOOL
Q06 BOOL
Q07 BOOL
Q08 BOOL

■ Function

1. It divides one byte into 8 bits (QO1~QO2).


2. QO8: MSB (Most Significant Bit), QO1: LSB (Least Significant Bit)

7-5
Chapter7 Application Function

■ Program Example
1. LD
%MX0 BYTE_BIT
EN ENO

INPUT IN Q01 BIT1

Q02 BIT2

Q03 BIT3

Q04 BIT4

Q05 BIT5

Q06 BIT6

Q07 BIT7

Q08 BIT8

2. ST

BYTE_BIT(EN:=%MX0, IN:= INPUT, Q01=> BIT1, Q02=> BIT2, Q03=> BIT3, Q04=> BIT4, Q05=> BIT5, Q06=> BIT6, Q07=>
BIT7, Q08=> BIT8);

(1) If the execution condition (%MX0) is on, BYTE_BIT function executes.


(2) If INPUT = 16#AC = 2#1010_1100, it distributes INPUT from Q01 to Q08 in order. The order is 2#{0, 0, 1, 1, 0, 1, 0, 1}.

7-6
Chapter7 Application Function

1.4. BYTE_TO_

1.5. BYTE_WORD

Combines 2 bytes into WORD


BYTE_WORD Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1.


LOW: lower BYTE input
HIGH: upper BYTE input

Output ENO: outputs EN value as it is


OUT: WORD output

■ Function

It combines two bytes into one word.


LOW: lower BYTE input, HIGH: upper BYTE input

■ Program Example
1. LD

%MX3 BYTE_WORD
EN ENO

BYTE_IN1 LOW OUT OUTPUT


BYTE_IN2 HIGH

2. ST

OUTPUT := BYTE_WORD(EN:=%MX3, LOW:=BYTE_IN1, HIGH:=BYTE_IN2);

(1) If the transition condition (%MX3) is on, BYTE_WORD function executes.


(2) If input BYTE_IN1 = 16#56 and BYTE_IN2 = 16#AD, output variable OUTPUT = 16#AD56.

7-7
Chapter7 Application Function

1.6.

1.7. DEC

Decrease IN data by 1 bit


DEC Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1.


IN: input data to decrease

Output ENO: outputs EN value as it is


OUT: result data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. If EN is 1, it produces an output after decreasing bit-string data of IN by 1.


2. Even though the underflow occurs, an error won’t occur and if the result is 16#0000, then the output result data is
16#FFFF.
3. Input data types are BYTE, WORD, DWORD and LWORD.

FUNCTION IN/OUT type Description


DEC BYTE
DEC WORD
You can select one of these functions according to in/out data type.
DEC DWORD
DEC LWORD

7-8
Chapter7 Application Function

■ Program Example

1. LD

2. ST

%MW20 := DEC(EN:=%MX0, IN:=%MW100);

(1) If the transition condition (%MX0) is on, DEC function executes.


(2) If input variable %MW100 = 16#0007 (2#0000_0000_0000_0111), output variable %MW20 = 16#0006
(2#0000_0000_0000_0110).

7-9
Chapter7 Application Function

1.8. DECO

Decodes the designated bit position


DECO Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1.


IN: input data for Decoding

Output ENO: without an error, it is 1


OUT: Decoding result data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. If EN is 1, it turns on ‘the designated position bit of output bit-string data’ according to the value of IN, and produces
an output.
2. Output data types are BYTE, WORD, DWORD and LWORD.

FUNCTION OUT type Description


DECO BYTE
DECO WORD
You can select one of these functions according to output data type.
DECO DWORD
DECO LWORD

■ Flag

Flag Description

If input data is a negative number or bit position data is out of output-type range, (in case of
_ERR
DECO_WORD, it’s more than 16), then OUT is 0 and _ERR/_LER flags are set.

7-10
Chapter7 Application Function

■ Program Example

1. LD

2. ST

RELAYS := DECO(EN:=%MX0, IN:=ON_POSITION);

(1) If the transition condition (%MX0) is on, DECO function executes.


(2) Since the only 5th bit of output is on if ON_POSITON(INT) = 5 as declared as input variable, RELAYS(WORD
type) = 2#0000_0000_0010_0000.

7-11
Chapter7 Application Function

1.9. DEG

Converts radian into degree


DEG Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1.


DEG IN: radian input

BOOL EN ENO BOOL Output ENO: outputs EN value as it is


ANY_REAL IN OUT ANY_REAL OUT: degree output
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

It converts radian input into degree output.

Function Input type Output type Description


DEG REAL REAL
It converts input (radian) into output (degree).
DEG LREAL LREAL

■ Program Example

1. LD

2. ST

DEG_VAL := DEG(EN:=%MX0, IN:=RAD_VAL);

(1) If the transition condition (%M0) is on, DEG function executes.


(2) If input variable RAD_VAL = 1.0, then output variable DEG_VAL = 5.7295779513078550e+001.

7-12
Chapter7 Application Function

1.10. DI

1.11. DWORD_LWORD

Combines two DWORD data into LWORD


DWORD_LWORD Availability XGF-M32E
Flags

Function Description

DWORD_LWORD Input EN: executes the function in case of 1.


LOW: lower DWORD Input
BOOL EN ENO BOOL HIGH: upper DWORD Input
DWORD LOW OUT LWORD
DWORD HIGH Output ENO: outputs EN value as it is
OUT: LWORD Output

■ Function

It combines 2 DWORD data into one LWORD data.


LOW: lower DWORD Input, HIGH: upper DWORD Input

■ Program Example

1. LD

%MX11 DWORD_LWORD
EN ENO

INPUT1 LOW OUT RESULT


INPUT2 HIGH

2. ST

RESULT := DWORD_LWORD(EN:=%MX11, LOW:=INPUT1, HIGH:=INPUT2);

(1) If the transition condition (%MX11) is on, DWORD_LWORD function executes.


(2) If input variable INPUT1 = 16#1A2A_3A4A and INPUT2 = 16#8C7C_6C5C, then, output variable RESULT =
16#8C7C_6C5C_1A2A_3A4A.

7-13
Chapter7 Application Function

1.12. DWORD_LWORD

Divides DWORD into 2 WORD data


DWORD_WORD Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


DWORD_WORD
IN: DWORD Input
BOOL EN ENO BOOL
DWORD IN LOW WORD Output ENO: outputs EN value as it is
HIGH WORD LOW: lower WORD Output
HIGH: upper WORD Output

■ Function

It divides one DWORD into two WORD data.


LOW: lower WORD Output, HIGH: upper WORD Output

■ Program Example
1. LD

%MX5 DWORD_WORD
EN ENO

INPUT IN LOW WORD_OUT1


HIGH WORD_OUT2

2. ST

DWORD_WORD(EN:=%MX5, IN:=INPUT, LOW=>WORD_OUT1, HIGH=>WORD_OUT2);

(1) If the transition condition (%MX5) is on, DWORD_WORD function executes.


(2) If input variable INPUT = 16#1122_AABB, then, WORD_OUT1 = 16#AABB and WORD_OUT2= 16#1122.

7-14
Chapter7 Application Function

ENCO

Produces On bit position as number


ENCO Availability XGF-M32E
Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input data to encode

Output ENO: without an error, it is 1


OUT: Encoding result data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. If EN is 1, it produces the most priority bit position among bits of 1 to OUT.


2. Input data types are B(BYTE), W(WORD), D(DWORD) and L(LWORD).

FUNCTION IN type Description


ENCO BYTE
ENCO WORD
Uses a desirable ENCO function type depending on input variable type.
ENCO DWORD
ENCO LWORD

■ Flag

Flag Description
_ERR OUT is -1 if no bit among input data is 1; _ERR and _LER flags are set.

7-15
Chapter7 Application Function

■ Program Example
1. LD

2. ST

ON_POSITION := ENCO(EN:=%MX0, IN:=SWITCHS);

(1) If the execution condition (%MX0) is on, ENCO function executes.


(2) If SWITCHS (WORD type) = 2#0000_1000_0000_0010, it produces the positions of 2 bits with on, that is, ‘11’
out of ‘11’ and ‘1’, so that ‘11’ is saved into ON_POSITION(INT Type).

7-16
Chapter7 Application Function

1.13. NIC

Increase IN data by 1
INC Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


IN: Input data to increase

Output ENO: outputs EN value as it is


OUT: result data after increase
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. If EN is 1, it increases IN bit string data by 1 and produces an output.


2. An error does not occur when there’s an overflow; the result is 16#0000 in case of 16#FFFF.
3. Input data types are BYTE, WORD, DWORD and LWORD.

FUNCTION IN/OUT type Description


INC BYTE
INC WORD
You can select one of these functions according to the in/out data type.
INC DWORD
INC LWORD

7-17
Chapter7 Application Function

■ Program Example

1. LD

2. ST

%MW100 := INC(EN:=%MX0, IN:=%MW10);

(1) If the transition condition (%MX0) is on, INC function executes.


(2) If input variable %MW10 = 16#0007 (2#0000_0000_0000_0111), then output variable %MW100 =16#0008
(2#0000_0000_0000_1000).

7-18
Chapter7 Application Function

1.14. LWORD_DWORD

Divides LWORD into two DWORD data


LWORD_DWORD Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1


LWORD_DWORD IN: LWORD Input
BOOL EN ENO BOOL
LWORD IN LOW DWORD Output ENO: outputs EN value as it is
HIGH DWORD LOW: lower DWORD Output
HIGH: upper DWORD Output

■ Function

1. It divides one LWORD into two DWORD data.


LOW: lower DWORD Output, HIGH: upper DWORD Output

■ Program Example
1. LD

%MX10 LWORD_DWORD
EN ENO

INPUT IN LOW WORD_OUT1


HIGH WORD_OUT2

2. ST

LWORD_DWORD(EN:=%MX10, IN:=INPUT, LOW=>DWORD_OUT1, HIGH=>DWORD_OUT2);

(1) If the transition condition (%MX10) is on, LWORD_DWORD function executes.


(2) If the input variable INPUT = 16#AAAA_BBBB_CCCC_DDDD, then
DWORD_OUT1 = 16#CCCC_DDDD
DWORD_OUT2 = 16#AAAA_BBBB.

7-19
Chapter7 Application Function

1.15. RAD

Converts degree into radian


RAD Availability XGF-M32E
Flags

Function Description

Input EN: executes the function in case of 1.


IN: degree Input

Output ENO: outputs EN value as it is


OUT: radian output
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○
OUT ○ ○

■ Function

1. It converts a degree value ( ) into a radian value.


2. If the degree is over 360, it converts normally.
For example, if input is 370, output is radian value corresponding to 370 - 360 = 10.

Function Input type Output type Description


RAD REAL REAL
It converts a degree value ( ) into a radian value.
RAD LREAL LREAL

■ Program Example
1. LD

2. ST

RAD_VAL := RAD(EN:=%MX0, IN:= DEG_VAL);

(1) If the transition condition (%MX0) is on, RAD_REAL function executes.


(2) If input variable DEG_VAL = 127( ), its output RAD_VAL = 2.21656823.

7-20
Chapter7 Application Function

1.16. ROTATE_

1.17. SWAP

Swaps upper data for lower data

SWAP Availability XGF-M32E

Flags

Function Description

Input EN: executes the function in case of 1.


IN: Input

Output ENO: outputs EN value as it is


OUT: swapped data
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

It swaps upper data for lower data.

Function Input type Description


SWAP BYTE Swaps upper nibble for lower nibble data.
SWAP WORD Swaps upper byte for lower byte data.
SWAP DWORD Swaps upper word for lower word data.
SWAP LWORD Swaps upper double word for lower double word data.

■ Program Example
1. LD

2. ST

RESULT := SWAP(EN:=%MX0, IN:=INPUT);

(1) If the transition condition (%MX0) is on, SWAP function executes.


(2) If INPUT (BYTE) = 16#5F, RESULT (BYTE) = 16#F5.

7-21
Chapter7 Application Function

UNI

Unites data

UNI Availability XGF-M32E

Flags _ERR, _LER

Function Description

Input EN: executes the function in case of 1


IN: input data array
SEG: bit-number-designate array to united data

Output ENO: without an error, it is 1


OUT: united data output
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
IN ○ ○ ○ ○
OUT ○ ○ ○ ○
*ANY_BIT: exclude BOOL from ANY_BIT type.

■ Function

1. It unites an input data array from the lower bit to a configured bit set by SEG and produces an output.

Function Input type Output type Description


UNI BYTE BYTE
UNI WORD WORD It cuts an input array into bit data set by SET and produces
UNI DWORD DWORD an output (united data) with the same array type of input.
UNI LWORD LWORD

7-22
Chapter7 Application Function

After
Combination

If the sum of value set by SEG exceeds the bit number of input data type, _ERR and _LER flags are set.

■ Flag

Flag Description

If the sum of value set by SEG exceeds the bit number of input data type, _ERR and _LER flags are set. If
_ERR
the number of arrays of IN and SEG is different, output OUT is 0 and _ERR and _LER flags are set.

■ Program Example
1. LD

%MX0 UNI
EN ENO

IN_ARY IN OUT RESULT

SEG_ARY SEG

2. ST

RESULT := UNI(EN:=%MX0, IN:=IN_ARY, SEG:=SEG_ARY);

(1) If the transition condition (%MX0) is on, UNI function executes.

7-23
Chapter7 Application Function

(2) If input IN_ARY and SEG_ARY are as below

IN_ARY[0] A3B5 SEG_ARY[0] 3


IN_ARY[1] B4C6 SEG_ARY[1] 4
IN_ARY[2] C5D7 SEG_ARY[2] 7
IN_ARY[3] D6E8 SEG_ARY[3] 2

output RESULT = 2#0010_1011_1011_0101 = 16#2BB5.

IN_ARY[0] 2#1010 0011 1011 0101 SEG_ARY[0] 3


IN_ARY[1] 2#1011 0100 1100 0110 SEG_ARY[1] 4
IN_ARY[2] 2#1100 0101 1101 0111 SEG_ARY[2] 7
IN_ARY[3] 2#1101 0110 1110 1000 SEG_ARY[3] 2

RESULT : 2#00 1010111 0110 101

7-24
Chapter7 Application Function

1.18. WORD_BYTE

Divides WORD into two bytes

WORD_BYTE Availability XGF-M32E

Flags

Function Description

Input EN: executes the function in case of 1


WORD_BYTE IN: WORD Input
BOOL EN ENO BOOL
WORD IN LOW BYTE Output ENO: outputs EN value as it is
HIGH BYTE LOW: lower BYTE output
HIGH: upper BYTE output

■ Function

1. It divides one word data into two byte data.


LOW: lower byte output, HIGH: upper byte output

■ Program Example
1. LD

%MX3 WORD_BYTE
EN ENO

INPUT IN LOW BYTE_OUT1


HIGH BYTE_OUT2

2. ST

WORD_BYTE(EN:=%MX3, IN:=INPUT, LOW=>BYTE_OUT1, HIGH=>BYTE_OUT2);

(1) If the transition condition (%MX3) is on, WORD_BYTE function executes.


(2) If input variable INPUT is 16#ABCD, then BYTE_OUT1 = 16#CD and BYTE_OUT2 = 16#AB.

7-25
Chapter7 Application Function

1.19. WORD_DWORD

Combines two WORD data into DWORD

WORD_DWORD Availability XGF-M32E

Flags

Function Description

Input EN: executes the function in case of 1.


WORD_DWORD
LOW: lower WORD input
BOOL EN ENO BOOL HIGH: upper WORD input
WORD LOW OUT DWORD
WORD HIGH Output ENO: outputs EN value as it is
OUT: DWORD output

■ Function

It combines two WORD data into one DWORD.


LOW: lower WORD input, HIGH: upper WORD input.

■ Program Example

1. LD

2. ST

RESULT := WORD_DWORD(EN:=%IX0.0, LOW:=INPUT1, HIGH:=INPUT2);

(1) If the transition condition (%IX0.0) is on, WORD_DWORD function executes.


(2) If input variable INPUT1 = 16#1020 and INPUT2 = 16#A0B0, output variable RESULT=16#A0B0_1020.

7-26
Chapter7 Application Function

1.20. XCHG

Exchanges two input data

XCHG Availability XGF-M32E

Flags

Function Description

Input EN: executes the function in case of 1

Output ENO: outputs EN value as it is

In/Out SRC1: In/Output 1


SRC2: In/Output 2
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

Variable

DT
ANY type variable
SRC1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
SRC2 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

■ Function

1. Exchanges input1 data with input2 data.


Function In/Out type Description

XCHG BOOL Exchanges two BOOL input data.

XCHG BYTE Exchanges two BYTE input data.

XCHG WORD Exchanges two WORD input data.

XCHG DWORD Exchanges two DWORD input data.

XCHG LWORD Exchanges two LWORD input data.

XCHG SINT Exchanges two SINT input data.

XCHG INT Exchanges two INT input

XCHG DINT Exchanges two DINT input data.

XCHG LINT Exchanges two LINT input data.

XCHG USINT Exchanges two USINT input data.

XCHG UINT Exchanges two UINT input data.

XCHG UDINT Exchanges two UDINT input data.

XCHG ULINT Exchanges two ULINT input data.

XCHG REAL Exchanges two REAL input data.

XCHG LREAL Exchanges two LREAL input data.

7-27
Chapter7 Application Function

Function In/Out type Description

XCHG TIME Exchanges two TIME input data.

XCHG DATE Exchanges two DATE input data.

XCHG TOD Exchanges two TOD input data.

XCHG DT Exchanges two DT input data.

■ Program Example

1. LD

2. ST

XCHG(EN:=%MX0, SRC1:=INPUT1, SRC2:=INPUT2);

(1) If the transition condition (%MX0) is on, XCHG function executes.


(2) If INPUT1 = 0 and INPUT2 = 1, it will exchange two input data. After the function execution, INPUT1 = 1 and INPUT2 = 0.

7-28
Chapter7 Application Function

1.21. XNR

Exclusive Logical AND

XNR Availability XGF-M32E

Flags

Function Description

Input EN: executes the function in case of 1


IN1: XNR-to-be value
IN2: XNR-to-be value
XNR
Input variables can be extended up to 8.
BOOL EN ENO BOOL
ANY_BIT IN1 OUT ANY_BIT
ANY_BIT IN2 Output ENO: outputs EN value as it is
OUT: XNR result

IN1, IN2, and OUT must be of the same data type.


DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
BYTE

REAL

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable

ANY type variable


IN1 ○ ○ ○ ○ ○
IN2 ○ ○ ○ ○ ○
OUT ○ ○ ○ ○ ○

■ Function

1. It performs XNR operation on the input variables by bit and produces output, OUT.
IN1 1111 ..... 0000
XNR
IN2 1010 ..... 1010
OUT 1010 ..... 0101

7-29
Chapter7 Application Function

■ Program Example
1. LD

2. ST

%QB0.0 := XNR(EN:=%MX0, IN1:=%MB10, IN2:=ABC);

(1) If the transition condition (%MX0) is on, XNR function executes.


(2) If %MB10 = 16#F0 = 2#1111_0000 and ABC(BYTE type) = 16#AA = 2#1010_1010, the result of XNR is shown
in OUT (%QB0.0.0 = 16#A5 = 2#1010_0101).

7-30
Chapter8 Basic Function Block

Chapter 8 Basic Function Block


This chapter describes basic function block library.

Down Counter (function block)

CTD Availability XGF-M32E

Flags

Function Block Description

Input CD: down counter pulse input

CTD LD: loads a preset value


BOOL CD Q BOOL PV: preset value
BOOL LD CV ANY
*ANY_INT PV
Output Q: down counter output
CV: current value
DWORD

LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
Any type variable
PV ○ ○ ○ ○ ○ ○
CV ○ ○ ○ ○ ○ ○
*ANY_INT: exclude SINT and USINT from ANY_INT type.

■ Function

1. Down counter function block CTD decreases the current value (CV) by 1 with every rising pulse input.
2. CV decreases only when CV is more than the minimum value of INT (-32768); after reaching it, CV does not
change its value.
3. When LD is 1, PV is loaded into CV (CV=PV).
4. Output Q is 1 when CV is 0 or a negative number.
Function Block PV Description
CTD_INT INT Decrease as much as the min INT(-32,768).
CTD_DINT DINT Decrease as much as the min DINT(-2,147,483,648).
CTD_LINT LINT Decrease as much as the min LINT(-9,223,372,036,854,775,808).
CTD_UINT UINT Decrease as much as the min UINT(0).
CTD_UDINT UDINT Decrease as much as the min UDINT(0).
CTD_ULINT ULINT Decrease as much as the min ULINT(0).

8-1
Chapter8 Basic Function Block

■ Time Chart

LD (preset value input)

CD (down counter input)


PV setting
CV (current value) 0
max. coefficient
Q (down counter output)

■ Program Example
1. LD

2. ST
INST_CTD_INT(CD:=%IX0.0, LD:=_10N, PV:=5, Q=>COUNT_Q, CV=>COUNT_CV);

%QX0.0 := COUNT_Q

This is the program that sets the output contact (%QX0.0) when the down counter pulse input enters the input contact
(%IX0.0) five times.

(1) Register the name of CTD function block (COUNT_D).


(2) Make the input contact (%IX0.0) attached to CD.
(3) Make the flag _10N (1 scan On contact) that loads PV into CV.
(4) Set the PV value as 5 in range of INT ((-32,768~32,767).
(5) Set the CV value as the random output variable (COUNT_CV).
(6) Set the Q value as the random output variable (COUNT_Q).
(7) Compile and write your program to the PLC after completing the program.
(8) After writing, change the PLC mode (Stop -> Run).
(9) If program runs, PV 5 will be loaded into CV (Count_CV).
(10) The current value CV (COUNT_CV) decreases by 1 when the pulse input enters the input contact (%IX0.0).

8-2
Chapter8 Basic Function Block

(11) When the down counter pulse input enters the input contact five times, CV (COUNT_CV) will be 0 and Q
(COUNT_CV) will be 1.
(12) If Q (COUNT_Q) is 1, the output contact (%Q0.0) will be set.

8-3
Chapter8 Basic Function Block

1.1. CTU

Up Counter (function block)

CTU Availability XGF-M32E

Flags

Function Block Description

Input CU: up counter pulse input


CTU R: reset input
BOOL CU Q BOOL PV: loads a preset value
BOOL R CV *ANY_INT
*ANY_INT PV
Output Q: increase counter output
CV: current value
DWORD

STRING
LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
Any type variable
PV ○ ○ ○ ○ ○ ○
CV ○ ○ ○ ○ ○ ○
*ANY_INT: exclude SINT and USINT from ANY_INT type.

■ Function
1. Up counter function block CTU increases the current value (CV) by 1 with every rising pulse input.
2. CV increases only when CV is less than the maximum value of INT (32767); after reaching it, CV does not change
its value.
3. When the reset input (R) is 1, CV is cleared (0).
4. Output Q is 1 when CV is equal to or more than PV.
5. PV value reloads the preset value and operate it when CTU function block executes.

Function Block PV Description


CTU_INT INT Increase as much as the max INT (32767).
CTU_DINT DINT Increase as much as the max DINT (2147483647).
CTU_LINT LINT Increase as much as the max LINT (9223372036854775807).
CTU_UINT UINT Increase as much as the max UINT (0).
CTU_UDINT UDINT Increase as much as the max UDINT (0).
CTU_ULINT ULINT Increase as much as the max ULINT (0).

8-4
Chapter8 Basic Function Block

■ Time Chart

R (reset input)

CU (up counter input)


max.
preset
coefficient
value
CV (current value)

Q (up counter output)

■ Program Example

1. This is the program that sets the output contact (%QX0.0) when the increase counter pulse input enters the input
contact (%IX0.0) ten times

1. LD

2. ST

INST_CTU_INT(CU:=%IX0.0, R:=%IX0.1, PV:=10, Q=>COUNT_Q, CV=>COUNT_CV);

%QX0.0 := COUNT_Q;

(1) Register the name of CTU function block (COUNT_U).


(2) Make the input contact %IX0.0 attach to CU.
(3) Set the PV value as 10.
(4) Assign input contact %IX0.1 to the reset input R.
(5) Set the CV value as the random output variable (COUNT_CV).
(6) Set the Q value as the random output variable (COUNT_Q).
(7) Compile and write your program to the PLC after completing the program.

8-5
Chapter8 Basic Function Block

(8) After writing, change the PLC mode (Stop  Run).


(9) The current value CV (COUNT_CV) increases by 1 when the pulse input enters the input contact (%IX0.1.15).
(10) When the up counter pulse input enters the input contact ten times, CV (COUNT_CV) is 10 and Q (COUNT_Q) is 1.
(11) If Q (COUNT_Q) is 1, the output contact (%QX0.0) is set.

8-6
Chapter8 Basic Function Block

Up/Down Counter (function block)

CTUD Availability XGF-M32E

Flags

Function Block Description

Input CU: up counter pulse input


CD: down counter pulse input
CTUD
BOOL CU QU BOOL R: reset
BOOL CD QD BOOL LD: loads a preset value
BOOL R CV *ANY_INT
PV: preset value
BOOL LD
*ANY_INT PV Output QU: up counter output
QD: down counter output
CV: current value
DWORD

STRING
LWORD
WORD

LREAL
UDINT
USINT

ULINT
BOOL

DATE
REAL
BYTE

TIME
DINT

UINT
SINT

LINT

TOD
INT

DT
Variable
Any type variable
PV ○ ○ ○ ○ ○ ○
CV ○ ○ ○ ○ ○ ○
*ANY_INT: excluding SINT and USINT from ANY_INT types

■ Function
1. Up/Down counter function block CTUD increases the current value (CV) by 1 with every rising up-counter pulse
input (CU) and decreases CV by 1 with every rising down-counter pulse input (CD).
2. Note that CV is between -32768 and 32767 (INT).
3. When LD is 1, PV is loaded into CV (CV=PV).
4. When the reset input R is 1, CV is cleared (0).
5. When CV reaches PV, the output QU is 1; when CV is 0 or a negative integer, the output QD is 1.
6. The operation for each input signal executes in order of R > LD > CU > CD. Note that if the input signals are fed to
the input (CU, CD, R, and LD) of CTUD at the same time, the operation of CTU follows the above priority.

Function Block PV Description


CTUD_INT INT Increase/decrease as much as INT(-32768 ~ 32767)
CTUD_DINT DINT Increase/decrease as much as DINT(0 ~ 231-1)
CTUD_LINT LINT Increase/decrease as much as LINT(0 ~ 263-1)
CTUD_UINT UINT Increase/decrease as much as UINT(0 ~ 65535)
CTUD_UDINT UDINT Increase/decrease as much as UDINT(0 ∼ 232-1)
CTUD_ULINT ULINT Increase/decrease as much as ULINT(0 ∼ 263-1)

8-7
Chapter8 Basic Function Block

■ Time Chart

LD (preset value input)

R (reset input)

CU (CTU input)

CD (down counter input)

PV (PV setting)
CV (current value)
0

Q (CTU output)

QD (down counter output)

■ Program Example
1. LD

2. ST

INST_CTUD_INT(CU:=%IX0.0, CD:=%IX0.1, R:=%MX0, LD:=%MX1, PV:=STACK_MAX, QU=>STACK_FULL,


QD=>STACK_EMPTY, CV=>STORED_NUMBER);

Conditions are: the temporary loading part STACK_MAX is 100; IN is 1 with every material-input signal while OUT is 1
with every material-output signal. If the material input process is faster than the material-output one and every material
is loaded so that the STACK_MAX is equal to or more than 100, then QU is 1 (STACK_FULL = 1); if there's no material
left in the loading part, QD is 1 (STACK_EMPTY = 1). At the STORED_NUMBER, the number of remaining material in
the loading part is shown.

8-8
Chapter8 Basic Function Block

%MX1

%MX0

%IX0.1.0

%IX1.1.0

STACK_MAX(100)
STORED_
0
NUMBER
STACK
_FULL
STACK_
EMPTY

8-9
Chapter8 Basic Function Block

1.2. FF

Reverse output bit

FF Availability XGF-M32E

Flags

Function Block Description

FF Input CLK : input signal

BOOL CLK Q BOOL Output Q : reverse output by instruction

■ Function
FF reverses output Q as the input status connected to CLK is changed from 0 to 1.

■ Time Chart

CLK

■ Program Example
1. LD

2. ST

INST_FF(CLK:=%IX0.0, Q=>DETECT);

(1) By watching the status of input variable, %IX0.0, when the input is changed from 0 to 1, the DETECT is reversed.

8-10
Chapter8 Basic Function Block

1.3. F_TRIG

Falling Edge Detection (function block)

F_TRIG Availability XGF-M32E

Flags

Function Block Description

F_TRIG
Input CLK: input signal
BOOL CLK Q BOOL
Output Q: falling edge detection result

■ Function

1. The output Q of function block F_TRIG is 1 with the falling pulse input to CLK. And 1 scan later, without further falling
pulse input, the output Q is 0 ever after.

■ Time Chart

CLK

Q
(1 scan or F_TRIG execution time)

■ Program Example
1. LD

2. ST

INST_F_TRIG(CLK:=%IX0.0, Q=>FALL_DETECT);

(1) If the input variable (%IX0.0) changes from 1 to 0, while detecting its state, the output variable FALL_DETECT
is 1. And 1 scan later, the output variable FALL_DETECT is 0.

8-11
Chapter8 Basic Function Block

1.4. RS

Reset Priority Bistable (function block)

RS Availability XGF-M32E

Flags

Function Block Description

Input R_1: Reset condition


RS
RS S: Set condition
BOOL
BOOL S Q1
Q1 BOOL
BOOL
BOOL
BOOL R1
R_1 Output Q1: operation result

■ Function

R_1R1 Q1
&

SS ≥1
Q1
Q1

If R1 is 1, output Q1 is 0 regardless of the state of S. The output variable Q1 is 1 when it maintains the previous state,
R1 is 0, and S is 1, it is 1. The initial state of Q1 is 0.

■ Time Chart

R1
R_1

SS

Q1
Q1

8-12
Chapter8 Basic Function Block

■ Program Example

1. LD

SET1
SET1 RS
RS
SS Q1
Q1 RESULT
RESULT

RESET1
RESET1 R1
R_1

2. ST

INST_RS(S:=SET1, R_1:=RESET1, Q=>RESULT);

It outputs the operation results with RESET1 as Reset condition and SET1 as Set condition to RESULT.
Replace the operation conditions; as the above time chart, R_1 to RESET1, S to SET1 and Q1 to RESULT.

(1) If SET1 declared as input variable is on, output variable RESULT is 1.


(2) If RESET1 declared as output variable is on, output variable declared as RESULT is 0.
(3) If SET1 and RESET1 declared as input variables are on, the output variable RESULT is 0.

8-13
Chapter8 Basic Function Block

1.5. RTC_SET

1.6. R_TRIG

Rising Edge Detection (function block)

R_TRIG Availability XGF-M32E

Flags

Function Block Description

Input CLK: input signal


R_TRIG
BOOL CLK Q BOOL
Output Q: rising edge detection result

■ Function

The output Q of function block R_TRIG is 1 with the rising pulse input to CLK. And 1 scan later, without further rising
pulse input, the output Q is 0.

■ Time Chart

CLK

Q
(1 scan or R_TRIG execution time)

■ Program Example

1. LD
IN_SINGAL R_TRIG
CLK Q RISE_DETECT

2. ST

INST_R_TRIG(CLK:=IN_SIGNAL, Q=>RISE_DETECT);

If the input variable IN_SIGNAL changes from 0 to 1, while detecting its state, the output variable RISE_DETECT is 1.
And 1 scan later, the output variable RISE_DETECT is 0.

8-14
Chapter8 Basic Function Block

1.7. SR

Set Priority Bistable (function block)

SR Availability XGF-M32E

Flags

Function Block Description

Input S1: set condition


SR
SR R: reset condition
BOOL
BOOL S_1
S1 Q1
Q1 BOOL
BOOL
BOOL
BOOL RR
Output Q1: operation result

■ Function

S1
S_1 Q1
Q1
≥1

R &
Q1
Q1

1. If S1 is 1, output Q1 is 1 regardless of the state of R.


2. The output variable Q1 is 0 and it maintains the previous state when S1 is 0, and R is 1.
3. The initial state of Q1 is 0.

■ Time Chart

S_1
S1

RR

Q1
Q1

8-15
Chapter8 Basic Function Block

■ Program Example

1. LD

SET1
SET1 SR
SR
S1
S_1 Q1
Q1 RESULT
RESULT

RESET1
RESET1 RR

2. ST

INST_SR(S_1:=SET1, R:=RESET1, Q=>RESULT);

(1) If input variable SET1 becomes on, output variable RESULT is 1.


(2) The output variable RESULT becomes 0 when input variable SET1 becomes off and RESET on.

8-16
Chapter8 Basic Function Block

1.8. TOF

Off Delay Timer (function block)

TOF Availability XGF-M32E

Flags

Function Block Description

Input IN: timer operation condition


TOF PT: preset time
BOOL IN Q BOOL
TIME PT ET TIME Output Q: timer output
ET: elapsed time

■ Function

1. If IN is 1, Q is 1. And after IN becomes 0 and the preset time (PT) of TOF passes, Q becomes 0.
2. After IN becomes 0, the elapsed time (ET) is shown.
3. If IN becomes 1 before ET reaches the preset time, ET is 0 again.

■ Time Chart

IN

Q PT

Setting (PT)
Time

ET

8-17
Chapter8 Basic Function Block

■ Program Example

1. LD

TOF
T_OFF
IN Q TIMER_OK

T#10S PT ET ET_TIME

2. ST

INST_TOF(IN:=T_OFF, PT:=T#10S, Q=>TIMER_OK, ET=>ET_TIME);

T_OFF

TIMER_OK
10S 10S
Setting Time
(10S)

ET_TIME

(1) Output variable TIMER_OK is 1 when input variable T_OFF becomes 1. TIMER_OK is 0 only if 10 seconds
passes after T_OFF becomes 0.
(2) If T_OFF becomes 1 again in 10 seconds after it turned off, TOF is initialized (TIMER_OK is 1).
(3) After T_OFF becomes 0, the elapsed time (ET_TIME) is measured and shown.

8-18
Chapter8 Basic Function Block

1.9. TON

On Delay Timer (function block)

TON Availability XGF-M32E

Flags

Function Block Description

Input IN: timer operation condition


TON
PT: preset time
BOOL IN Q BOOL
TIME PT ET TIME
Output Q: timer output
ET: elapsed Time

■ Function

1. Elapsed time (ET) is measured and shown after IN becomes 1.


2. When IN becomes 0 before ET reaches the preset time, ET is 0.
3. If IN becomes 0 after Q is 1, Q is 0.

■ Time Chart

IN
PT PT

Q
Setting
Time (PT)

ET

8-19
Chapter8 Basic Function Block

■ Program Example

1. LD
TON
T_ON
IN Q TIMER_OK

T#10S PT ET ET_TIME

2. ST

INST_TON(IN:=T_ON, PT:=T#10S, Q=>TIMER_OK, ET=>ET_TIME);

TON
10s 10s
TIMER_OK

Setting Time
10S

ET_TIME

(1) The output TIMER_OK = 1 ten seconds later after the input T_ON is asserted (T_ON = 1).
(2) After input variable T_ON is 1, the elapsed time is output to output variable, ET_TIME.
(3) When T_ON = 0 before ET_TIME reaches the preset time (10s), ET_TIME is 0.
(4) If T_ON = 0 after TIMER_OK = 1, then TIMER_OK = 0 and ET_TIME = 0.

8-20
Chapter8 Basic Function Block

1.10. TP

Pulse timer (function block)

TP Availability XGF-M32E

Flags

Function Block Description

Input IN: timer operation condition


TP
PT: preset time
BOOL IN Q BOOL
TIME PT ET TIME
Output Q: timer output
ET: elapsed Time

■ Function

1. If IN = 1, Q is 1 only during the preset time PT; if ET reaches PT, Q is 0.


2. If IN = 1, elapsed time ET starts to be measured and maintains its value after when it reaches PT; if IN = 0 after ET
reaches PT, ET = 0.
3. The state of IN doesn't matter while ET is measured (increased).

■ Time Chart

IN

Q PT PT
PT
Setting
(PT)
Time

ET

8-21
Chapter8 Basic Function Block

■ Program Example

1. LD

TP
T_TP
IN Q TIMER_OK

T#10S PT ET ET_TIME

2. ST

INST_TP(IN:=T_TP, PT:=T#10S, Q=>TIMER_OK, ET=>ET_TIME);

T_TP

TIMER_OK 10s 10s 10s

Setting (10S)
Time

ET_TIME

(1) TIMER_OK is 1 during 10 seconds after input T_TP was asserted (T_TP = 1). While ET_TIME increases during
10 seconds, the state of input T_TP doesn't affect TIMER_OK.
(2) ET_TIME increases when it reaches T#10S and then it becomes 0 when T_TP = 0.

☆ Note
TP function block keeps operating until its operation is complete even if the contact is changed from on to off. In case
of a variable using array index, array index error occurs only when the contact is on. Therefore, TP function block
does not produce any array index error as long as the contact is off although function block is operating.

8-22
Chapter9 Application Function Block

Chapter 9 Application Function Block


This chapter describes the basic function block library mentioned in the previous chapter and other application function block
library

Ring Counter

CTR Availability XGF-M32E

Flags

Function Block Description

Input CD: pulse input of Ring Counter


PV: preset value
CTR
BOOL CD Q BOOL RST: reset
INT PV CV INT Output Q: Ring Counter output
BOOL RST CV: current value

■ Function

1. CTR function block (Ring Counter) functions: current value (CV) increases with the rising pulse input (CD) and if, after CV
reaches PV, CD becomes 1, then CV is 1.
2. When CV reaches PV, output Q is 1.
3. If CV is less than PV or reset input (RST) is 1, output Q is 0.

■ Time Chart

9-1
Chapter9 Application Function Block

■ Program Example

Output %QX0.0 is on with 10-time rising pulse input of %IX0.0 is depicted as follows:

1. LD

2. ST

INST_CTR(CD:=%IX0.0, PV:=10, RST:=%IX0.1, Q=>COUNT_Q, CV=>COUNT_NUM);


%QX0.0 := COUNT_Q;

(1) Define CTR function block as INS_CTR.


(2) Set %IX0.0 to the input contact of CD referring to the above.
(3) Set 10 to PV.
(4) Set %IX0.1 to RST resetting CV.
(5) Set random variable COUNT_NUM to CV
(6) Set random output variable COUNT_Q to Q.
(7) After a program is complete, compile and write it to PLC.
(8) When ‘Write’ is complete, do ‘Mode Change’ (Stop  Run).
(9) CV (COUNT_NUM) increases by 1 in number with the rising input pulse of %IX0.0.
(10) With 10-time rising input pulse of input contact, CV is 10 which is the same as PV and output variable
COUNT_Q is 1.
(11) If Q (COUNT_Q) is 1, output contact %QX0.0 is on
(12) If the rising input pulse is loaded into input contact %IX1.1.0, then Q (COUNT_Q) is 0 and output
contact %QX0.0 is off.

9-2
Chapter9 Application Function Block

1.1. DUTYTMR

Integration Timer

TMR Availability XGF-M32E

Flags
TMR
Function Block Description

TMR Input IN: operation condition for Timer


PT: preset time
BOOL IN Q BOOL RST: reset
TIME PT ET TIME
BOOL RST Output Q: timer output
ET: elapsed time

■ Function

1. When IN is 1, elapsed time is produced at ET.


2. Even if IN is 0 before ET reaches PT, ET keeps its value. If IN is 1 again, elapsed time is produced at ET integrating its
previous value.
3. If ET reaches PT, Q is 1.
4. If RST is 1, Q and ET are 0.

■ Time Chart

9-3
Chapter9 Application Function Block

■ Program Example

1. LD

2. ST
INST_TMR(IN:=T_TMR, PT:=T#10S, RST:=%IX1.1.12, Q=>TIMER_OK, ET=>ET_TIME);

(1) If 10 seconds passes after input variable T_TMR is 1, output variable TIMER_OK is 1.

(2) Elapsed time is produced at ET_TIME after T_TMR is 1.

(3) ET_TIME keeps its value even if T_TMR is 0 before ET_TIME reaches its preset time 10 seconds.

(4) If T_TMR is 1, elapsed time is produced at ET_TIME integrating its previous value.
(5) If input contact %IX0.0 is 1, elapsed time ET_TIME and output variable TIMER_OK are all cleared.

9-4
Chapter9 Application Function Block

1.2. TMR_FLK

TMR with Flicker

TMR_FLK Availability XGF-M32E

Flags
FLK
Function Block Description

TMR_FLK Input IN: operation condition for Timer


ON: on setting time of timer
BOOL IN Q BOOL OFF: off setting time of timer
TIME ON ET TIME RST: reset
TIME OFF
Output Q: Timer output
BOOL RST
ET: elapsed time

■ Function

1. As soon as IN gets 1, Q becomes 1 and Q maintains its value during on setting time.
2. After setting time which is set by on, Q is 0 during the time which is set by off.
3. If IN is 0, it stops its function of either on or off operation and keeps its time. If IN is 1 again, it executes with its previous data.
4. Output Q is 0 while IN is 0.
5. If ON is 0, output Q is always 0.

■ Time Chart

IN

ON ON TIME
ON TIME
OFF TIME

OFF
OFF TIME

9-5
Chapter9 Application Function Block

■ Program Example

1. LD

2. ST

INST_TMR_FLK(IN:=T_TMR_FLK, ON:=T#5S, OFF:=T#2S, RST:=%IX0.0, Q=>%QX0.0, ET=>ET_TIME);

(1) If input variable T_TMR_FLK is 1, TMR_FLK function block executes.


(2) Output contact %QX0.0 is 1 during 5 seconds set by on after input variable T_TMR_FLK is 1.
(3) Output contact %QX0.0 is 0 during 2 seconds set by off after 5 seconds set by on.
(4) TON time (On) when Q is 1 and TOF time (Off) when Q is 0 are produced at ET_TIME by turns while T_TMR_FLK
is 1.
(5) If input variable T_TMR_FLK is 0, then it keeps its time and output contact %QX0.0 is 0. If T_TMR_FLK is 1, it
executes again.
(6) If input %IX0.0 is 1, elapsed time ET_TIME and output contact %QX0.0 are all cleared.

9-6
Chapter9 Application Function Block

1.3. TMR_UINT

TMR with Integer setting

TMR_UINT Availability XGF-M32E

Flags

Function Block Description

TMR_UINT Input IN: operation condition for Timer


Q BOOL PT: preset time
BOOL IN UNIT: time unit of setting time
UINT PT ET UDINT
RST: reset input
UINT UNIT
BOOL RST Output Q: timer output
ET: elapsed time

■ Function

1. Elapsed time is produced at ET after IN is 1.


2. Even if IN is 0 before ET reaches PT, ET keeps its value. If IN is 1 again, elapsed time is increased.
3. Q is 1 when elapsed time reaches preset time.
4. If RST is 1, Q and ET are 0.
5. Setting time is PT x UNIT (ms).

■ Time Chart

9-7
Chapter9 Application Function Block

■ Program Example

1. LD

2. ST
INST_TMR_UINT(IN:=T_TMR, PT:=10, UNIT:=1000, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) Setting time is PT x UNIT[ms] = 10 x 1000[ms] = 10[s].


(2) Output variable TIMER_OK is 1, if 10 seconds passes after input variable T_TMR is 1.
(3) Elapsed time is produced at ET_TIME after input variable T_TMR is 1.
(4) Even if T_TMR is 0 before ET_TIME reaches preset time ,10 seconds, ET_TIME keeps its value.
(5) If input variable T_TMR is 1 again, elapsed time is produced at ET integrating its previous value.
(6) If input contact %IX0.0 is 1, elapsed time ET_TIME and output contact TIMER_OK are all cleared.

T_TMR

%IX1.1.5
Setting Time
(10,000ms)
ET_TIME

10 * 1000
TIMER_OK

9-8
Chapter9 Application Function Block

1.4. TOF_RST

Delay Timer is able to output Off in operation

TOF_RST Availability XGF-M32E

Flags

Function Block Description

Input IN: operation condition for Timer


TOF_RST PT: preset time
BOOL IN Q BOOL RST: reset
TIME PT ET TIME
Output Q: Timer output
BOOL RST ET: elapsed time

■ Function

1. Q is 1 when IN is 1 and Q is 0 when preset time (PT) elapses after IN became 0.


2. Elapsed time is produced at ET after IN is 0.
3. Elapsed time is 0 if IN is 1 before ET reaches PT.
4. If RST is 1, Q and ET are 0.

■ Time Chart

9-9
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TOF_RST(IN:=T_TOF_RST, PT:=T#10S, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) If input variable T_TOF_RST is 1, output variable TIMER_OK is 1. And TIMER_OK is 0 when 10 seconds elapse
after T_TOF_RST became 0.
(2) If T_TOF_RST is 1 within 10 seconds after it turns off, TOF_RST is initialized.
(3) Elapsed time is produced at ET_TIME.
(4) If input contact %IX0.0 is 1, elapsed time ET_TIME and output contact TIMER_OK are all cleared.

☆ Note

TOF_RST Function Block keeps operating after the contact is on until its operation is complete. In case of a variable
using array index, array index error occurs only when the contact is on. Therefore, TOF_RST Function Block does not
produce any array index error as long as the contact is off ,although function block is operating.

9-10
Chapter9 Application Function Block

1.5. TOF_UINT

Off Timer of Integer setting

TOF_UINT Availability XGF-M32E

Flags

Function Block Description

TOF_UINT Input IN: operation condition for Timer


PT: preset time
BOOL IN Q BOOL
UNIT: time unit of setting time
UINT PT ET TIME RST: reset
UINT UNIT
BOOL RST Output Q: Timer output
ET: elapsed time

■ Function

1. Q is 1 when IN is 1. And Q is 0, if setting time (PT) passes after IN is 0.


2. Elapsed time is produced at ET after IN is 0.
3. If IN is 1 before ET reaches PT, ET becomes 0 again.
4. If RST is 1, Q and ET are 0.
5. Setting time is PT x UNIT (ms).

■ Time Chart

9-11
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TOF_UINT(IN:=T_TOF, PT:=10, UNIT:=1000, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) Preset time PT x UNIT[ms] = 10 x 1000[ms] = 10[s].


(2) If input variable T_TOF is 1, output variable TIMER_OK is 1. TIMER_OK is 0, if 10 seconds passes after T_TOF
is 0.
(3) If T_TOF becomes 1 again within 10 seconds, TOF_UINT initializes.
(4) Elapsed time is produced at ET_TIME.
(5) If input contact %IX0.0 is 1, TIMER_OK and ET_TIME are all cleared

☆ Note

TOF_UINT Function Block keeps operating after the contact is on until its operation is complete. In case of a
variable using array index, array index error occurs only when the contact is on. Therefore, TOF_UINT Function
Block does not produce any array index error as long as the contact is off although function block is operating.

9-12
Chapter9 Application Function Block

1.6. TON_UINT

On Timer of Integer setting

TON_UINT Availability XGF-M32E

Flags

Function Block Description

TON_UINT Input IN: operation condition for Timer


PT: preset time
BOOL IN Q BOOL UNIT: time unit of setting time
UINT PT ET TIME
UINT UNIT Output Q: timer output
ET: elapsed time

■ Function

1. Elapsed time is produced at ET after IN is 1.


2. Elapsed time ET is 0, if IN is 0 before ET reaches PT.
3. Q is 0, if IN is 0 after Q is 1.
4. Preset time is PT x UNIT[ms].

■ Time Chart

9-13
Chapter9 Application Function Block

■ Program Example

1. LD

T_TON TON_UINT
IN Q TIMER_OK

10 PT ET ET_TIME
1000 UINT

2. ST
INST_TON_UINT(IN:=T_TON, PT:=10, UNIT:=1000, Q=>TIMER_OK, ET=>ET_TIME);

(1) Preset time is PT x UNIT[ms] = 10 x 1000[ms] = 10[s].


(2) If 10 seconds passes after input variable T_TON is on, output variable TIMER_OK is 1.
(3) Elapsed time is produced at ET_TIME after input variable T_TON is on.
(4) If T_TON is 0 before elapsed time ET_TIME reaches 10 seconds, ET_TIME is 0.
(5) If T_TON is 0 after TIMER_OK is 1, TIMER_OK and ET_TIME are 0.

TP_RST

9-14
Chapter9 Application Function Block

1.7. TP_RST

Pulse timer is able to Off output of contact.

TP_RST Availability XGF-M32E

Flags

Function Block Description

Input IN: operation condition for Timer


TP_RST PT: preset time
BOOL IN Q BOOL RST: reset
TIME PT ET TIME
Output Q: timer output
BOOL RST ET: elapsed time

■ Function

1. If IN is 1, Q is 1. And if elapsed time reaches preset time, timer output Q is 0.


2. ET increases its value from when IN is 1, keeps its value at PT and is cleared when IN is 0.
3. It doesn't matter whether IN changes its state or not while timer output Q is 1 (during a pulse output).
4. If RST is 1, output Q and ET are 0.

■ Time Chart

9-15
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TP_RST(IN:=T_TP_RST, PT:=T#10S, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) If input variable T_TP_RST is 1, output variable TIMER_OK is 1. And 10 seconds later, TIMER_OK is 0. Once
TP_RST timer executes, input T_TP_RST doesn't matter during 10 seconds.
(2) ET_TIME value increases and stops at 10S. And if T_TP_RST is 0, ET_TIME becomes 0.
(3) If input contact %IX0.0 is 1, TIIMER_OK and ET_TIME are all cleared.

☆ Note

TP_RST Function Block keeps operating after the contact is on until its operation is complete. In case of a variable
using array index, array index error occurs only when the contact is on. Therefore, TP_RST Function Block does not
produce any array index error as long as the contact is off although function block is operating.

9-16
Chapter9 Application Function Block

1.8. TP_UINT

Pulse Timer with Integer setting

TP_UINT Availability XGF-M32E

Flags

Function Block Description

TP_UINT Input IN: operation condition for Timer


PT: preset time
BOOL IN Q BOOL UNIT: time unit of setting time
UINT PT ET TIME RST: reset
UINT UNIT
Output Q: timer output
BOOL RST
ET: elapsed time

■ Function

(1) If IN is 1, Q is 1. And if elapsed time reaches preset time, timer output Q is 0.


(2) ET increases its value from when IN is 1, keeps its value at PT and is cleared when IN is 0.
(3) It does not matter whether IN changes its state or not while timer output Q is 1 (during a pulse output).
(4) If RST is 1, output Q and ET are 0.
(5) Preset time is PT x UNIT[ms].

■ Time Chart

IN

RST
Setting Time
(PT*UNIT)

ET PT*UNIT

9-17
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TP_UINT(IN:=T_TP, PT:=10, UNIT:=100, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) Preset time is PT x UNIT[s] = 10 x 100[ms] = 1[s].


(2) If input variable T_TP is 1, output variable TIMER_OK is 1. And 10 seconds later, TIMER_OK is 0. Once
TP_UINT timer executes, input T_TP does not matter.
(3) ET_TIME value increases and stops at 1,000. And if T_TP is 0, it is 0.
(4) If input contact %IX0.0 is 1, TIMER_OK and ET_TIME are all cleared.

☆ Note

TP_UINT Function Block keeps operating after the contact is on until its operation is complete. In case of a variable
using array index, array index error occurs only when the contact is on. Therefore, TP_UINT Function Block does not
produce any array index error as long as the contact is off although function block is operating.

9-18
Chapter9 Application Function Block

1.9. TRTG

Retriggerable Timer

TRTG Availability XGF-M32E

Flags

Function Block Description

Input IN: operation condition for Timer


PT: preset time
RST: reset

Output Q: timer output


ET: elapsed time

■ Function

1. Q is 1 as soon as IN becomes 1. And if elapsed time reaches preset time, timer output Q is 0.
2. If IN turns on again before elapsed time reaches preset time, then elapsed time is set as 0 and increased again. And if it reaches
PT, Q is 0.
3. If RST is 1, timer output Q and elapsed time ET are 0.

■ Time Chart

9-19
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TRTG(IN:=T_TRTG, PT:=10, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) TIMER_OK is 1 during 10 seconds after input variable T_TRTG becomes 1 from 0. If T_TRTG becomes 1 from 0
after timer executes, ET_TIME is set as 0 and increased again.
(2) TIMER_OK is 1 during 10 seconds even when T_TRTG becomes 0 from 1.
(3) ET_TIME value increases and stops at T#10S. And it is 0 when T_TRTG is 0.
(4) If input contact %IX0.0 is 1, TIMER_OK and ET_TIME are all cleared.

☆ Note

TRTG Function Block keeps operating after the contact is on until its operation is complete. In case of a variable
using array index, array index error occurs only when the contact is on. Therefore, TRTG Function Block does not
produce any array index error as long as the contact is off although function block is operating.

9-20
Chapter9 Application Function Block

1.10. TRTG_UINT

Retriggerable Timer with Integer setting

TRTG_UINT Availability XGF-M32E

Flags

Function Block Description

Input IN: operation condition for Timer


PT: preset time
UNIT: time unit of setting time
RST: reset

Output Q: timer output


ET: elapsed time

■ Function

1. Q is 1 as soon as IN becomes 1. And if elapsed time reaches preset time, timer output Q is 0.
2. If IN turns on again before elapsed time reaches preset time, then elapsed time is set as 0 and increased again. And if it
reaches PT, Q is 0.
3. If RST is 1, timer output Q and elapsed time ET are 0.
4. Preset time is PT x UNIT[ms].

■ Time Chart

9-21
Chapter9 Application Function Block

■ Program Example
1. LD

2. ST
INST_TRTG_UINT(IN:=T_TRTG, PT:=10, UNIT:=100, RST:=%IX0.0, Q=>TIMER_OK, ET=>ET_TIME);

(1) Preset time is PT x UNIT[ms] = 10 x 1000[ms] = 10[s].


(2) TIMER_OK is 1 during 10 seconds after input variable T_TRTG becomes 1 from 0. If T_TRTG becomes 1 from 0
after timer executes, ET_TIME is set as 0 and increased again.
(3) TIMER_OK is 1 during 10 seconds even when T_TRTG becomes 0 from 1.
(4) ET_TIME value increases and stops at 10000. And it is 0 when T_TRTG is 0.
(5) If input contact %IX0.0 is 1, TIMER_OK and ET_TIME are all cleared.

☆ Note

TRTG_UINT Function Block keeps operating after the contact is on until its operation is complete. In case of a variable
using array index, array index error occurs only when the contact is on. Therefore, TRTG_UINT Function Block does
not produce any array index error as long as the contact is off, although function block is operating.

9-22
Chapter10 Motion Function Block

Chapter 10 Motion Function Blocks


This chapter describes the basic function block library mentioned in the previous chapter and other application function block
library.

10.1 Common Elements of Motion Function Blocks

10.1.1 The State of axis


Each axis in the motion control module is changed to the relevant state depending on the situation and command. The
changing structure of each situation is shown in the figure below.

MC_GearIn (Sub Axis)


MC_GearInPos (Sub Axis)
MC_CamIn (Sub Axis)
Synchronized
MC_MoveAbsolute Motion MC_MoveVelocity
MC_MoveRelative MC_TorqueControl
MC_MoveAdditive MC_MoveContinousAbsolute
MC_Halt MC_MoveContinousRelative
Continuous
Discrete Motion
Motion

MC_Stop

Done Stopping

ErrorStop *1
*6

*4 *3
MC_Home

Homing Done Standstill *5 Disabled *2

*1 ErrorStop: in case axis error occurs regardless of the current state of axis
*2 Disabled: in case MC_Power.Enable input is Off when axis error does not occur
*3 ErrorStop  Disabled: in case MC_Reset command has issued when MC_Power.Status output is Off
*4 ErrorStop  Standstill: in case MC_Reset command has issued when MC_Power.Status output is on and
MC_Power.Enable input is On
*5 Disabled  Standstill: in case of turning On MC_Power.Enable input when MC_Power.Status output is On
*6 Stopping  Standstill: in case of turning Off MC_Stop.Execute input when MC_Stop.Done output is On

10-1
Chapter10 Motion Function Block

The state of axis Description

Disabled state indicates the state in which no command is given to a single axis, and no
error occurs. In case there is no motion control module at the time of first operation, each
axis begins in the disabled state. Afterwards, axis status is changed to standstill state in
case servo-on status emerges when Enable input of servo On/Off (MC_Power) motion
Disabled
function block is On. The axis becomes disabled state when Enable input of serve On/Off
(MC_Power) motion function block is Off in case of not being in ErrorStop state. In case
there is motion function block which is currently being performed, the command is
interrupted.(The CommandAborted output of the motion block function is On)

No matter which state the current axis is in, it is changed to ErrorStop state when axis error
occurs, and the axis decelerates to stop. In the state where error occurs, ErrorStop state is
ErrorStop maintained even though servo On/Off (MC_Power) motion function block is executed. The
motion axis which is in ErrorStop state maintains stationary state, and any command
except for error reset is not executed.

When the power of axis is activated, there is no error in the axis and any command is not
StandStill
made, the axis state indicates StandStill state.

Homing Homing state indicates the axis is in homing operation.

In case emergency stop (MC_Stop) function block is executed, the axis state is changed
to stopping state. When the axis is in stopping state, other motion commands cannot be
Stopping
given to the axis until the Stop is completed (until Done output is activated). If Done output
is On, and Execute input is On, the state is switched to Standstill status.

It indicates state where operation continues until the current axis becomes operation stop
Continuous Motion
status.

Discrete Motion It indicates reduced operating status with target position.

Synchronized Motion Synchronized motion indicates axis is in synchronized operation.

10-2
Chapter10 Motion Function Block

10.1.2 The State of Group


Each group in motion control module is changed to the relevant state depending on the situation and command.
The changing structure of each state is shown in the figure below.

*1
MC_GroupHalt

GroupMoving MC
_G *2
rou
MC_GroupStop pS
top

Error GroupStopping
GroupHoming Error

Done Error
MC Done
_G *1 op
ro
up pSt *3 GroupErrorStop
Ho r ou
me G
C_
M Error
et
MC_GroupEnable R es *2
ro up
GroupDisabled GroupStandby _G
MC_GroupDisable MC
MC_UngroupAllAxes
MC_RemoveAxisFromFroup
MC_AddAxisToGroup *4 MC_AddAxisToGroup
MC_RemoveAxisFromGroup MC_RemoveAxisFromGroup
MC_UngroupAllAxes *5

*1 GroupMoving: in case of performing the motion function block of general group operation
*2 GroupStopping, GroupErrorStop: The relevant motion function block is not performed when different motion function
block is performed in GroupStopping or GroupErrorStop state, and when MC_GroupReset function block is performed
in GroupErrorStop state, the state of the relevant group is changed to GroupStandby.
*3 GroupStopping -> GroupStandby: when MC_GroupStop.DONE output is On and MC_SroupStop.EXECUTE input
is Off
*4 GroupStandby -> GroupDisabled: in case there is no axis belonging to the group when performing the axis remove
command (MC_RemoveAxisFromGroup, MC_UnGroupAllAxes)
*5 GroupStandby: in case more than one axis belongs to the group when performing the axis add or remove command
in group (MC_AddAxisToGroup, MC_RemoveAxisFromGroup)
*6 GroupDisabled: When performing MC_GroupDisable or MC_UnGroupAllDisable function block, the relevant group is
changed to GroupDisabled state regardless of its current state.

10-3
Chapter10 Motion Function Block

10.1.3 Basic I/O Variable


Edge operation motion function block
Relationships of the basic I/O parameter in the Edge operation motion function block are as below.

Execute

Busy

Active

Done

Error

CommandAborted

(a) (b) (c) (a) (d) (e) (a) (f) (g) (a) (h)

Variable Description
This is an input to run the relevant function block in Edge operation function block.
Execute
Function block is executed in the rising Edge. (Figure a state)
This is an output to indicate the relevant motion function block is currently running (= not
completed), and this indicates the output of motion function block can be changed.
Busy Busy output is On in the rising Edge of Execute input (Figure a state), and it is Off when
Done output is On (Figure b state), CommandAborted output is On (Figure d state), or
Error output is On (Figure f state).
This indicates the relevant motion function block is actually controlling axis.
When running many motion function block to one axis (in case only one motion function
Active block is controlling and other notion function blocks are Buffered), Active output is On in
only one motion function block which is controlling, and in motion function blocks which
are Buffered, Busy output is On.
This is an output to indicate operation of the relevant motion function block has been
successfully completed.
Done If Done output is On, Busy and Active output is Off. (Figure d state)
Done output is Off when Execute input is Off (Figure e state), if Execute output was Off
when Done output became On, it remains On only during 1 scan (Figure h state).
This is an output to indicate an error occurs while running motion function block.
Error Error output is Off when Execute input is Off (Figure f state). If Execute output was Off
when Error output became On, it remains On only during 1 scan (Figure h state).
This outputs error code regarding the relevant error when an error occurs while running
ErrorID
motion function block. ErrorID output and elimination time are same with Error output.

10-4
Chapter10 Motion Function Block

This indicates the relevant motion function block is interrupted by the other motion
function block. CommandAborted output is Off when Execute input is Off (Figure g
CommandAborted
state). If Execute output was Off when Done output became On, it remains On only
during one scan.
※ When Execute input is On in Edge operation(Execute input) motion function block, depending on
the state of axis, one output in Busy, Done, Error, and CommandAborted output is On. Busy, Done,
Error, and CommandAborted output are available to be On one at a time, and if one output in four is
On, other three outputs become Off.

■ Motion function block for level motion

Enable

Busy

Vaild

Error

(a) (b) (c) (d) (e) (f) (g)

Variable Description
This is an input to run function block for level operation motion.
Enable This runs motion function block in the rising Edge (Figure a state), and stops it in the falling
Edge(Figure b state).
This is an output to indicate the relevant motion function block is currently running ((= not
completed), and it indicates the output of motion function block can be changed. Busy output is On
Busy
in the rising Edge of Enable input (Figure b state), and it remains on while motion function is in
operation.
This is an output to indicate the relevant motion function block is successfully performed and output
Valid & motion are valid.
Valid output is Off when Enable input is Off (Figure b state).
This is an output to indicate an error occurs while running motion function block.
If an error which cannot be automatically restored occurs while motion function block is in operation,
Error output is On, Busy & Valid output is Off (Figure d state), and motion function block stops
operating.
Error Error output is Off when Enable input is Off (Figure e state).
If an error which can be automatically restored occurs while function block is in operation, Error
output is On and Valid input is Off (Figure f state).
When the error in the relevant motion function block is restored, Error output is Off, and operation is
resumed (Figure g state).
※ Valid and Error outputs are not On at the same time.

10-5
Chapter10 Motion Function Block

■ Axis input
Each motion function block can be specified by Axis input to the axis which is subject to the relevant command.
Motion control module can control 1-32 actual axes and 37~40 virtual axes, and 41-41 encoders can be used as
main axis depending on motion function block. Therefore, values of 1~32, 37~40, and 41~42 can be input in Axis
input depending on motion function block. When it is out of the range which is available to set in each motion function
block, "error 0x0006”occurs.

10.1.4 BufferMode Input


This is an input which can specify whether to wait until the existing command is completed or to cancel the existing motion
function block and execute the command in case the axis is already running other motion function block when running
motion function block in a certain axis. The number between 0-5 can be specified, and if it is out of the range, "error
0x101A” occurs in the axis command and "error 0x201A” occurs in the axis group command. The values which are
available to be set in BufferMode are as below.
Number Buffer Mode Explanation
0 mcAborting Execute the command immediately. The existing command in operation is interrupted.
1 mcBuffered Execute the command after the existing command in operation is completed.
Do combined operation to combine the speeds of the existing command and
2 mcBlendingLow
command issuing to the low speed by comparing.
3 mcBlendingPrevious Do combined operation to combine the speeds of the existing command.
4 mcBlendingNext Do combined operation to combine the speeds of the command issuing.
Do combined operation to combine the speeds of the existing command and
5 mcBlendingHigh
command giving to the high speed by comparing.

10.1.5 Changes in Parameters during Execution of Motion Function Block


The parameter of the relevant command can be changed at the time motion function block is running, and the detailed
operations are as below.
- When executing Edge operation motion function block in the Off state of ContinuousUpdate input (turn On the
Execute input), the relevant motion function block is operated by application of the parameter at the time when
Execute input was On (rising Edge). In this case, the change of the parameter input value in the middle of execution of
motion function block does not affect operation.
- When wanting to change the parameter while the relevant motion function block is in operation, change the parameter
and turn On Execute input again.
- When executing Edge operation motion function block in the On state of ContinuousUpdate input (turn On the
Execute input), the parameter of the time when Execute input was On (rising Edge) is applied at first.
- When changing the parameter while ContinuousUpdate input is On, the relevant motion function block operates
reflecting the every change in parameter.
But, if you change the parameter at the completion or after the stop of the operation of the relevant motion function
block (Busy output is Off), the change is not reflected any more. (Parameter changing operation using
ContinuousUpdate does not rerun the motion function block which is completed or interrupted, In other words,
ContinuousUpdate operation is applied only to the motion function block which is currently running.)
- As for level operation motion function block, it is operated by the application of the parameter at the time when Enable
input was On (rising Edge), and continuous change of parameter is available while Enable input is On.

10-6
Chapter10 Motion Function Block

10.1.6 Group Operation Route Change Settings


When the axis group of the current motion control module is executing a command, other command can be issued to the
relevant axis group. At this point, the path, which the next command will achieve, can specify how the existing command
will be connected to the existing path. The parameter of connection track is specified in TransitionParameter input.

Number TRANSITION Mode Explanation


0 TMNone Do not generate a connection track.
Generate a connection track which specifies the corner distance of a
3 TMCornerDistance connection track and draws circular arcs at the specified corner
distance.

■ TransitionMode “TMNone”

Connection track is not generated. TransitionMode input is available only to “TMNone” in case BufferMode input of motion
function block is “Aborting” or “Buffered”.

The Figure below shows the case when running BufferMode of motion function block in the setting of ‘Aborting’. The
Figure in the left shows that motion function block ② is executed in the setting of ‘Aborting’ while motion function block ①
is running. Motion function block ① is forced to be terminated at 'end point ① / starting point ②' without reaching 'end point
①'. The Figure in the right shows that deceleration pause is performed at the moment of the execution of ‘Aborting’
function block, and the next motion function block is executed.

<In case BufferMode is specified as “Aborting”>

The Figure below shows that the case when running BufferMode of motion function block in the setting of ‘Buffered’. The
Figure in the left shows that motion function block ② is executed in the setting of 'Buffered’ while motion function block ①
is running. Motion function block ② is executed after motion function block ① has reached target position. The Figure in
the right shows that when ‘Buffered’ function block is executed, the next motion function block is executed after it reaches
original target position.

10-7
Chapter10 Motion Function Block

<In case BufferMode is specified as “Buffered”>

■ TransitionMode “TMCornerDistance”

The radius of a connection track is specified and the connection track which draws a circle having specified radius is
output. This mode is operated only when BufferMode is “BlendingXXXX”, and it is operated in “TMNone” when
BufferMode is “Aborting” or “Buffered”.
When drawing a connection track, the maximum speed of the path complies with the specified speed in BufferMode, and
the length of radius complies with the value specified in TransitionParameter.
The Figure below shows the generation of a connection track which draws radius circle in two linear interpolation
commands. The Figure in the left shows that motion function block ② is executed in the setting of “TMcornerDistance”
while motion function block ① is running. The original target position of motion function block ① was end point ① / starting
point ②, but straight-line motion is stopped and circular motion is started at the point ahead as far as radius 'd' (end point
①). Circular operation starts at end point ① and finishes at starting point ②, and executes motion function block ②.
The Figure in the right shows that the speed does not stop in the middle of two function blocks and continues.

<In case BufferMode is specified as “BlendingLow” and TransitionMode is specified as “TMCornerDistance”>

10-8
Chapter10 Motion Function Block

10.1.7 Motion Function Block Errors


Errors occurring in ErrorID variable of motion function block are as follows.
STAT Content Detailed Description
In case motion function block is normally executed, “O” is displayed on
0x0000 Normal
ErrorID.
The motion function block is not executed in the version of current
The current motion module does not
0x0005 module. Check the version in which the motion function block can be
support the motion function block.
executed.
Axis number of motion function block Check the axis that can implement allocation by motion function block,
0x0006
(Axisinput) exceeded allowable range. and set axis number to the areas of 1~32 and 37~40.
Axis group number of motion function
0x0007 block (AxisGroup input) exceeded Set axis group number to a value between 1 and 16.
allowable range.
Internal execution error of motion function
0x0012 block occurred during the execution of the Check the version of XG-PM and XGF-M32E.
motion function block.
Motion response error occurred during the
0x0013 Check the version of XG-PM and XGF-M32E.
execution of motion function block.
0x0020
It indicates a common error of the motion control module.
:
For more details, refer to ‘error information and measures in APPENDIX 1’.
0x0FFF
0x1000
It indicates error that occurs in relation to axis control of motion control module.
:
For more details, refer to ‘error information and measures in APPENDIX 1’.
0x1FFF
0x2000
It indicates error that occurs in relation to axis control of motion control module.
:
For more details, refer to ‘error information and measures in APPENDIX ‘.
0x2FFF

10-9
Chapter10 Motion Function Block

10.2 Motion Function Block

MC_Power Availability

Servo On/OFF XGF-M32E

Motion Function Block

MC_Power
BOOL Enable Status BOOL
UINT Axis Axis UINT
Vaild BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Enable Servo motor of the relevant axis is servo On while input is activated.
Output
BOOL Status Indicate the power permission status of the relevant axis.
BOOL Valid Indicate the validity of motion function block output. (same with Status output here)
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give servo On/Off command to the relevant axis.
(2) When Enable input is On, Servo On command is given to the relevant axis, and when it is Off, servo Off command is
given.
(3) If servo On command is executed when the axis is in 'Disable' state, the axis state is 'StandStill', and failure in servo
On brings 'ErrorStop' state.

10-10
Chapter10 Motion Function Block

MC_Home Availability

Perform the search home XGF-M32E

Motion Function Block

MC_Home
BOOL Execute Done BOOL
UINT Axis Axis UINT
LREAL Position Busy BOOL
UINT BufferMode Active BOOL
CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Start the homing operation in rising Edge.
LREAL Position Specify the absolute position of axis when reference signal is detected.
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate the completion state of motion function block.
BOOL Busy Indicate that execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted by other command.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give a homing command to the relevant axis.
(2) Homing method is operated as specified in the operation parameter of the relevant axis in advance.
(3) As for Position input, absolute position of axis is specified when Reference Signal is detected or homing is completed.
(4) While this motion function block is running, the axis is 'Homing' state, and when the command is completed, it is
switched to 'Standstill'.

10-11
Chapter10 Motion Function Block

MC_STOP Availability

Stop immediately XGF-M32E

Motion Function Block

MC_Stop
BOOL Execute Done BOOL
UINT Axis Axis UINT
LREAL Deceleration Busy BOOL
LREAL Jerk CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Give immediate stop command to the relevant axis in the rising Edge.
LREAL Deceleration Specify deceleration in time of stop. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Output
BOOL Done Indicate that the speed of the relevant axis reaches 0.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give an emergency stop command to the relevant axis.
(2) When executing immediate stop (MC_Stop) motion function block, the existing motion function block being executed
in the relevant axis is stopped, and the axis state changed to 'Stopping'. When the relevant axis is in 'Stopping’ state,
other motion function block cannot be executed in the relevant axis until the stopping is completed (until the Done
output is activated).
(3) CommandAborted output indicates that the current motion function block is interrupted while it is running. Other motion
function block cannot interrupt immediate stop (MC_Stop) motion function block while immediate stop (MC_Stop)
motion function block is running, therefore, CommandAborted output is On in general when the power of servo is
blocked or servo Off command is executed.
(4) If Execute input is On or the speed of axis is not 0, the axis is in 'Stopping' state, and when Done output is On and
Execute input is Off, it is switched to 'Standstill' state.

10-12
Chapter10 Motion Function Block

MC_Halt Availability

Stop XGF-M32E

Motion Function Block

MC_Halt
BOOL Execute Done BOOL
UINT Axis Axis UINT
LREAL Deceleration Busy BOOL
LREAL Jerk Active BOOL
UINT BufferMode CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Give stop command to the relevant axis in the rising Edge.
LREAL Deceleration Specify deceleration in time of stop. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate that the speed of the relevant axis reaches 0.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give a stop command to the relevant axis.
(2) The axis is 'DiscreteMotion' state while this motion function block is running, and when the speed of the relevant axis is
0, ‘Done’ output is On and changed to 'Standstill' state.

10-13
Chapter10 Motion Function Block

MC_MoveAbsolute Availability

Absolute positioning operation XGF-M32E

Motion Function Block

MC_MoveAbsolute
BOOL Execute Done BOOL
UINT Axis Axis UINT
BOOL ContinuousUpdate Busy BOOL
LREAL Position Active BOOL
LREAL Velocity CommandAborted BOOL
LREAL Acceleration Error BOOL
LREAL Deceleration ErrorID WORD
LREAL Jerk
UINT Direction
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Position Specify the target position.
LREAL Velocity Specify the maximum speed. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the operation direction.
UINT Direction (0~4: 0-Not specified, 1-Forward direction, 2-Shortest distance, 3-Reverse
direction, 4-Current direction)
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)

10-14
Chapter10 Motion Function Block

Output
BOOL Done Indicate whether to reach the specified distance.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give the relevant absolute position operation commands.
(2) Operation direction of the axis in Infinite length repetition operation is set in Direction input, and if Infinite length
repetition operation is set to Prohibited, Direction input is ignored. When Direction input is the shortest distance(=2),
the relevant axis doing Infinite length repetition operation automatically selects the direction which allows the shortest
distance. The available range is 0-4 (0-Not specified, 1-Forward direction, 2-Shortest distance, 3-Reverse direction,
4-Current direction), and "error 0x1017” occurs in case of excess of the range.
(3) On condition that there is no motion function block is on standby after the current motion function block, If the speed
is 0 after reaching the target point, operation is completed and Done output is On.
(4) The axis is in 'DiscreteMotion' state while this motion function block is running, and it is switched to 'Standstill' state
when operation is completed.

10-15
Chapter10 Motion Function Block

MC_MoveRelative Availability

Relative positioning operation XGF-M32E

Motion Function Block

MC_MoveRelative
BOOL Execute Done BOOL
UINT Axis Axis UINT
BOOL ContinuousUpdate Busy BOOL
LREAL Distance Active BOOL
LREAL Velocity CommandAborted BOOL
LREAL Acceleration Error BOOL
LREAL Deceleration ErrorID WORD
LREAL Jerk
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Distance Specify the target distance.
LREAL Velocity Specify the maximum speed. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate whether to reach the specified distance.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.

10-16
Chapter10 Motion Function Block

BOOL Error Indicate whether an error occurs or not.


WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give relative position operation command to the relevant axis.
(2) Relative position motion (MC_MoveRelative) is the motion function block which moves as far as the target distance
specified in Distance input from the current position.
(3) Moving direction is decided depending on the sign of the target distance specified in Distance input, and positive (+ or
No sign) moving direction leads to the forward direction, and negative (-) moving direction leads to the reverse direction.
(4) If there is no motion function block is on standby after the current motion function block and the speed is 0 after moving
to the target distance, operation is completed and Done output is On.
(5) The axis is in "DiscreteMotion" state when this motion function block is running, and it is switched to "StandStill" state
when operation is completed.

10-17
Chapter10 Motion Function Block

MC_MoveAdditive Availability

Additive positioning operation XGF-M32E

Motion Function Block

MC_MoveAdditive
BOOL Execute Done BOOL
UINT Axis Axis UINT
BOOL ContinousUpdate Busy BOOL
LREAL Distance Active BOOL
LREAL Velocity CommandAborted BOOL
LREAL Acceleration Error BOOL
LREAL Deceleration ErrorID WORD
LREAL Jerk
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Distance Specify the target distance.
LREAL Velocity Specify the maximum speed. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate whether to reach the specified distance.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.

10-18
Chapter10 Motion Function Block

BOOL Error Indicate whether an error occurs or not.


WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give the relevant additive position operation commands.
(2) Additive position motion (MC_MoveAdditive) is the motion function block which additionally moves as far as the
position specified in Distance input from the final target position of the currently running motion function block or the
latest motion function block executed in 'DiscreteMotion' state. If the current axis is executing motion function block
‘ContinuousMotion’ state, it executes operation based on the position where additive position motion
(MC_MoveAdditve) is executing.
(3) Moving direction is decided depending on the sign of the specified target distance in Distance input, and positive (+
or No sign) moving direction leads to forward direction, and negative (-) moving direction leads to reverse direction.
(4) When reaching the target position without motion function block on standby after the current motion function block,
'Done' output is On.
(5) The axis is in 'DiscreteMotion' state while this motion function block is running, and it is switched to 'Standstill' state
when operation is completed.

10-19
Chapter10 Motion Function Block

MC_MoveVelocity Availability

Specified velocity operation XGF-M32E

Motion Function Block

MC_MoveVelocity
BOOL Execute InVelocity BOOL
UINT Axis Axis UINT
BOOL ContinuousUpdate Busy BOOL
LREAL Velocity Active BOOL
LREAL Acceleration CommandAborted BOOL
LREAL Deceleration Error BOOL
LREAL Jerk ErrorID WORD
UINT Direction
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Velocity Specify the maximum speed. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the operation speed. (1 ~ 3 : 1-Forward direction, 2-Reverse direction,
UINT Direction
3-Current direction)
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL InVelocity Indicate whether to reach the specified speed.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.

10-20
Chapter10 Motion Function Block

BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give specified velocity operation command to the relevant axis.
(2) Giving a stop command or execution of other motion function block allow to interrupt specified velocity motion.
(3) Specify the operation speed in Velocity input. Positive sign (+ or No sign) of the operation speed value leads to
forward direction, and negative (-) sign leads to reverse direction.
(4) Specify the operation direction in Direction input. But, the operation direction is affected by the sign of the specified
speed value by Velocity input. For example, if you specify the negative number for the Velocity value and reverse
direction for Direction input, the relevant axis lastly does forward direction operation.
(5) Output InVelocity is On when the relevant axis reaches the specified speed, and it is Off when the specified speed
operation is interrupted.
(6) The axis is in 'ContinuousMotion' state when this motion function block is running.

10-21
Chapter10 Motion Function Block

MC_MoveContinuousAbsolute Availability

Absolute position operation ending with specified velocity operation XGF-M32E

Motion Function Block

MC_MoveContinousAbsolute
BOOL Execute InEndVelocity BOOL
UINT Axis Axis UINT
BOOL ContinousUpdate Busy BOOL
LREAL Position Active BOOL
LREAL EndVelocity CommandAborted BOOL
LREAL Velocity Error BOOL
LREAL Acceleration ErrorID WORD
LREAL Deceleration
LREAL Jerk
UINT Direction
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL EndVelocity Specify the operation speed after reaching the target position. [u/s]
LREAL Velocity Specify the maximum speed to reach the target position. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the operation direction.
UINT Direction (0~4: 0-Not specified, 1-Forward direction, 2-Shortest distance, 3-Reverse
direction, 4-Current direction)
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)

10-22
Chapter10 Motion Function Block

Output
BOOL InEndVelocity Indicate the operation at the specified speed after reaching the target position.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give Specified velocity operation after relative position operation command to the
relevant axis.
(2) When executing MC_MoveContinuousAbsolute, the relevant axis moves to the position specified in Position and
operates at the specified speed in EndVelocity if there is no motion function block is on standby.
(3) Giving a stop command or execution of other motion function block allow to interrupt speed operation.
(4) Set the operation direction of the axis in infinite length repetition operation in Direction input, and if infinite length
repetition operation is set to Prohibited, Direction input is ignored. When Direction input is the shortest distance (=2),
the relevant axis selects the direction which allows the shortest distance and operates if it does infinite length
repetition operation. The range can be set to 0~4(0-No specified, 1-Forward direction, 2-Shortest distance, 3-
Reverse direction, 4-Current direction), if the value outside the range is set and motion function block is executed,
Error is On and “0x1017” occurs in ErrorID.
(5) Output InEndVelocity is on when the relevant axis starts speed operation after reaching the specified position, and
when the specified operation is interrupted, it is Off.
(6) The axis is in 'ContinuousMotion' state while this command is executing.

10-23
Chapter10 Motion Function Block

MC_MoveContinuousRelative Availability

Relative position operation ending with specified velocity operation XGF-M32E

Motion Function Block

MC_MoveContinousRelative
BOOL Execute InEndVelocity BOOL
UINT Axis Axis UINT
BOOL ContinousUpdate Busy BOOL
LREAL Distance Active BOOL
LREAL EndVelocity CommandAborted BOOL
LREAL Velocity Error BOOL
LREAL Acceleration ErrorID WORD
LREAL Deceleration
LREAL Jerk
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
Give an absolute position motion command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Distance Specify the target distance.
LREAL EndVelocity Specify the operation speed after reaching the target position. [u/s]
LREAL Velocity Specify the maximum speed to reach the target position. [u/s]
LREAL Acceleration Specify the acceleration. [u/s2]
LREAL Deceleration Specify the deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL InEndVelocity Indicate the operation at the specified speed after reaching the target position.
BOOL Busy Indicate that the execution of motion function block is not completed.

10-24
Chapter10 Motion Function Block

BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block gives MC_MoveContinuousRelative command to the relevant axis.
(2) When executing MC_MoveContinuousRelative, the relevant axis operates at the speed specified in EndVelocity
after moving the distance specified in Distance if there is no motion function block is on standby.
(3) Giving a stop command or operation of other motion function block allow to interrupt specified velocity motion.
(4) Output InEndVelocity is On when the relevant axis starts speed operation and reaches the specified speed after
moving the specified distance, and when specified velocity motion is interrupted, it is Off.
(5) The axis is in 'ContinuousMotion' state while this motion function block is running.

10-25
Chapter10 Motion Function Block

MC_TorqueControl Availability

Torque control XGF-M32E

Motion Function Block

MC_TorqueControl
BOOL Execute InTorque BOOL
UINT Axis Axis UINT
BOOL ContinousUpdate Busy BOOL
LREAL Torque Active BOOL
LREAL TorqueRamp CommandAborted BOOL
LREAL Velocity Error BOOL
LREAL Acceleration ErrorID WORD
LREAL Deceleration
LREAL Jerk
UINT Direction
UINT BufferMode

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis)
Input
Give an absolute position operation command to the relevant axis in the rising
BOOL Execute
Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL Torque Specify the target torque. [u]
LREAL TorqueRamp Specify the ascending slope of torque. [u/s]
LREAL Velocity Unused
LREAL Acceleration Unused
LREAL Deceleration Unused
LREAL Jerk Unused
Specify the operation direction.
UINT Direction
(1~2 : 1-Forward direction, 2-Reverse direction)
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)

10-26
Chapter10 Motion Function Block

Output
Indicate that the input torque value and currently operating torque value are
BOOL InTorque
same.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give torque control command to the relevant axis.
(2) When executing torque control (MC_Torque), the relevant axis performs the control to keep the torque value
specified in Torque input.
(3) Giving a stop command or operation of other motion function block allow to interrupt specified velocity motion.
(4) Specify the gradient to reach the target torque value in TorqueRamp input.
(5) Specify the maximum speed in torque control operation in Speed input, and the value in negative number is not
allowed. Rotation direction is decided depending on the size of load in torque and the relative axis.
(6) Specify the operation direction in Direction input. When setting the value outside the range and executing motion
function block, Error is On and “0x1017” occurs in ErrorID.
(7) Output InTorque is On when the relevant axis reaches the specified torque, and when torque control operation is
interrupted, it is Off.
(8) The axis is in 'ContinuousMotion' state when this motion function block is running.

10-27
Chapter10 Motion Function Block

MC_Setposition Availability

Setting the current position XGF-M32E

Motion Function Block

MC_SetPosition
BOOL Execute Done BOOL
UINT Axis Axis UINT
LREAL Position Busy BOOL
BOOL Relative Error BOOL
UINT ExcutionMode ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Specify the current position of the relevant axis in the rising Edge.
LREAL VelFactor Specify the override rate of speed.
LREAL AccFactor Specify the override rate of acceleration/deceleration.
LREAL JerkFactor Specify the override rate of the change rate of acceleration.
Output
BOOL Enabled Indicate that override rate is successfully applied.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to set the current position of the relevant axis.
(2) Specify the position in Position input. When executing motion function block, if Relative input is Off, the position
of the relevant axis is replaced by the value of Position input, and if Relative input is On, the value of Position input
is added to the current position of the relevant axis.
(3) ExcutionMode input specifies the setting point. 0 means to be set immediately after motion function block, and 1
means to be set at the same point with ‘Buffered’ in sequential operation setting. The value unable to be set
causes "error0x101B”.
0 (mcImmediately): Change the parameter value immediately after executing function block (rising Edge in Execute
input). If the relevant axis is in running, operation can be affected.
1 (mcQueued): Changed at the same point with ‘Buffered’ in Buffermode. (Error! Reference Source Not Found.
Refer to input)

10-28
Chapter10 Motion Function Block

MC_Setoverride Availability

Velocity/Acceleration override XGF-M32E

Motion Function Block

MC_SetOverride
BOOL Execute Enabled BOOL
UINT Axis Axis UINT
LREAL VelFactor Busy BOOL
LREAL AccFactor Error BOOL
LREAL JerkFactor ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Enable Execute override operation in the relevant axis while input is activated.
LREAL VelFactor Specify the override rate of speed.
LREAL AccFactor Specify the override rate of acceleration/deceleration.
LREAL JerkFactor Specify the override rate of the change rate of acceleration.
Output
BOOL Enabled Indicate that override rate is successfully applied.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to override the speed of the relevant axis, acceleration, and the change rate of
acceleration.
(2) Override rate which is applied to the relevant axis can be specified and changed while Enable input is On. If Enable
input is Off, override rate right before the Off is maintained.
(3) Speed override rate is specified in VelFactor input. If the specified value is 0.0, the relevant axis stops but it is not
changed to 'StandStill' state.
(4) Specify acceleration/deceleration and override rate of jerk (change rate of acceleration) in AccFactor and
JerkFactor input respectively.
(5) Negative number cannot be input in each Facotr, and if it is input, "error 0x10C1” occurs.
(6) Default of each override rate is 1.0, and it means 100% of the command speed of function block currently running.
(7) Override operation does not affect the serve axis of the relevant axis.

10-29
Chapter10 Motion Function Block

MC_ReadParameter Availability

Read Parameter XGF-M32E

Motion Function Block

MC_ReadParameter
BOOL Enable Vaild BOOL
UINT Axis Axis UINT
INT ParameterNumber Busy BOOL
Error BOOL
ErrorID WORD
Value LREAL

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Enable Execute override operation in the relevant axis while input is activated.
INT ParameterNumber Specify the number of parameter to read. (0 ~ 25)
Output
BOOL Vaild Indicate whether the output of the current motion function block is valid.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
LREAL Value Output the value of parameter.

(1) This command is a motion function block which outputs parameter of the relevant axis.
(2) The value of the relevant parameter is continuously output in Value while Enable input is On.
(3) Specify the number of parameter to read in ParameterNumber input.
(4) The numbers of parameter are as below.

10-30
Chapter10 Motion Function Block

번호 파라미터 항목 비고
0 Unit 0:pulse,1:mm,2:inch,3:degree
1 Purses per rotation 1 ~ 4,294,967,295 [pulse]
2 Travel per rotation 0.000000001 ~ 4,294,967,295 [Unit]
3 Speed command unit 0:Unit/Time, 1:rpm
LREAL Positive number [Unit/s, rpm]
4 Basic Speed limit (Change according to Unit, Pulses per rotation,
Parameter Travel per rotation, Speed command unit)
5 Emergency stop deceleration 0 or LREAL Positive number [Unit/s2]
6 Encoder select 0:Incremental Encoder,1:Absolute Encoder
7 Gear ratio(Motor) 1 ~ 65,535
8 Gear ratio(Machine) 1 ~ 65,535
9 Operating mode of the reverse rotation 0:E.Stop, 1:Stop
10 S/W upper limit LREAL [Unit]
11 S/W lower limit LREAL [Unit]
12 Infinite running repeat position LREAL Positive number [Unit]
13 Infinite running repeat 0:Disable, 1:Enable
14 Command Inposition range 0 or LREAL Positive number [Unit]
15 Tracking error over-range value 0 or LREAL Positive number [Unit]
16 Current position compensation amount 0 or LREAL Positive number [Unit]
17 Current speed filter time constant 0 ~ 100
18 Extented Error reset monitoring time 1 ~ 1000 [ms]
19 Parameter S/W limit during speed control 0:Don’t detect, 1:Detect
20 Tracking error level 0:Warning, 1:Alarm
LREAL Positive number [Unit]
21 JOG high Speed
(Jog low speed ~speed limit ) [Unit/s]
LREAL Positive number [Unit]
22 JOG low Speed
( < Jog high speed) [Unit/s]
23 JOG acceleration 0 or LREAL Positive number [Unit/ s2]
24 JOG deceleration 0 or LREAL Positive number [Unit/ s2]
25 JOG jerk 0 or LREAL Positive number [Unit/ s2]

10-31
Chapter10 Motion Function Block

MC_Write Parameter Availability

Write Parameter XGF-M32E

Motion Function Block

MC_WriteParameter
BOOL Execute Vaild BOOL
UINT Axis Axis UINT
INT ParameterNumber Busy BOOL
LREAL Value Error BOOL
UINT ExcutionMode ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Rising Edge corresponding parameters of input is written. .
INT ParameterNumber Specify the number of parameter to write. (0 ~ 25)
LREAL Value Specify the value of parameter to write.
UINT ExecutionMode Specify the time when parameter is written.
Output
BOOL Vaild Indicate whether parameter is successfully written.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to write the value specified in parameter of the relevant axis.
(2) Parameter is written in the rising Edge of Execute input.
(3) Specify the number of parameter to write in ParameterNumber input. The value unable to be set causes "error
0x10F0”.
(4) Specify the value to write in parameter for Value input.
(5) In ExecutionMode, correct the time when parameter is written and the values below can be set. The value unable
to be set causes "error 0x101B".
0 (mcImmediately): Change the parameter value immediately after executing function block (rising Edge in Execute
input). If the relevant axis is in running, operation can be affected.
1 (mcQueued): Changed at the same point with ‘Buffered’ in Buffermode. (Error! Reference Source Not Found.
Refer to input )

10-32
Chapter10 Motion Function Block

(6) The numbers of parameter are as below.


번호 파라미터 항목 비고
0 Unit 0:pulse,1:mm,2:inch,3:degree
1 Purses per rotation 1 ~ 4,294,967,295 [pulse]
2 Travel per rotation 0.000000001 ~ 4,294,967,295 [Unit]
3 Speed command unit 0:Unit/Time, 1:rpm
LREAL Positive number [Unit/s, rpm]
4 Basic Speed limit (Change according to Unit, Pulses per rotation,
Parameter Travel per rotation, Speed command unit)
5 Emergency stop deceleration 0 or LREAL Positive number [Unit/s2]
6 Encoder select 0:Incremental Encoder,1:Absolute Encoder
7 Gear ratio(Motor) 1 ~ 65,535
8 Gear ratio(Machine) 1 ~ 65,535
9 Operating mode of the reverse rotation 0:E.Stop, 1:Stop
10 S/W upper limit LREAL [Unit]
11 S/W lower limit LREAL [Unit]
12 Infinite running repeat position LREAL Positive number [Unit]
13 Infinite running repeat 0:Disable, 1:Enable
14 Command Inposition range 0 or LREAL Positive number [Unit]
15 Tracking error over-range value 0 or LREAL Positive number [Unit]
16 Current position compensation amount 0 or LREAL Positive number [Unit]
17 Current speed filter time constant 0 ~ 100
18 Extented Error reset monitoring time 1 ~ 1000 [ms]
19 Parameter S/W limit during speed control 0:Don’t detect, 1:Detect
20 Tracking error level 0:Warning, 1:Alarm
LREAL Positive number [Unit]
21 JOG high Speed
(Jog low speed ~speed limit ) [Unit/s]
LREAL Positive number [Unit]
22 JOG low Speed
( < Jog high speed) [Unit/s]
23 JOG acceleration 0 or LREAL Positive number [Unit/ s2]
24 JOG deceleration 0 or LREAL Positive number [Unit/ s2]
25 JOG jerk 0 or LREAL Positive number [Unit/ s2]

10-33
Chapter10 Motion Function Block

MC_Reset Availability

Reset axis error XGF-M32E

Motion Function Block

MC_Reset
BOOL Execute Done BOOL
UINT Axis Axis UINT
BOOL ErrorType Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis, 37~40: virtual axis)
Input
BOOL Execute Reset the axis error in the rising Edge of input.
BOOL ErrorType The types of error to be reset (0: Axis error, 1: Common error)
Output
BOOL Done Indicate whether the axis error is successfully reset.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to reset the error of the relevant axis. When setting ErrorType to '0' and executing motion
function block in case the relevant axis is in ' ErrorStop' state, every axis error is reset and the axis state is switched to
'StandStill' or 'Disabled' state.
(2) If ErrorType is set to ‘1’ and motion function block is executed, common error occurred in the relevant module is reset.
(3) Motion function block is executed in the rising Edge of Execute input.

10-34
Chapter10 Motion Function Block

MC_TouchProbe Availability

Touch probe XGF-M32E

Motion Function Block

MC_TouchProbe
BOOL Execute Done BOOL
UINT Axis Axis UINT
UINT TriggerInput TriggerInput UINT
BOOL WindowOnly Busy BOOL
LREAL FirstPosition CommandAborted BOOL
LREAL LastPosition Error BOOL
ErrorID WORD
RecordedPosition LREAL

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis)
UINT TriggerInput Specify the signal to be used as a trigger. (0: TouchProbe 1, 1: TouchProbe 2)
Input
BOOL Execute TouchProbe function starts at the rising Edge of input.
BOOL WindowOnly Activate the window mode.
LREAL FirstPosition Specify the starting position of allowable area in the window mode.
LREAL LastPosition Specify the end position of allowable area in the window mode.
Output
BOOL Done Indicate that the trigger signal is successfully recorded.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL CommandAborted Indicate that the current motion function block is interrupted by other command.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
REAL RecordedPosition Output the axis position where the trigger occurs.
(1) This motion function block is to execute 'TouchProbe' function which records the axis position at the time when the
trigger event occurs.
(2) TouchProbe function starts at the rising Edge of Execute input.
(3) Specify the signal to be used as a trigger in TriggerInput. The value unable to be set causes "error 0x10E1”.
(4) When activating the window mode, allowable area where accepts the trigger signal of axis can be set. Operation
timing of each signal when the window mode is activated is as below.

10-35
Chapter10 Motion Function Block

< In case TouchProbe function is the window mode, Operation timing >

10-36
Chapter10 Motion Function Block

MC_AbortTrigger Availability

Abort trigger events XGF-M32E

Motion Function Block

MC_AbortTrigger
BOOL Execute Done BOOL
UINT Axis Axis UINT
UINT TriggerInput TriggerInput USINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Axis Specify the axis to be commanded (1~32: real axis)
UINT TriggerInput Specify the trigger signal to be disengaged. (0: TouchProbe 1, 1: TouchProbe 2)
Input
BOOL Execute The trigger on standby in the relevant axis in the rising Edge is disengaged.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to disengage the trigger which is on standby in the relevant axis.
(2) Specify the trigger signal to be disengaged in TriggerInput. The value unable to be set causes "error 0x10E1”.

10-37
Chapter10 Motion Function Block

MC_CamIn Availability

Camming run XGF-M32E

Motion Function Block

MC_CamIn
BOOL Execute InSync BOOL
UINT Master Master UINT
UINT Slave Slave UINT
LREAL ContinousUpdate Busy BOOL
LREAL MasterOffset Active BOOL
LREAL SlaveOffset CommandAborted BOOL
LREAL MasterScaling Error BOOL
LREAL SlaveScaling ErrorID WORD
LREAL MasterStartDistance EndOfProfile BOOL
LREAL MasterSyncPosition
UINT StartMode
UINT MasterValueSource
UINT CamTableID
UINT BufferMode

Input-Output
UINT Master Set the main axis. (1~32: Actual axes, 37~40: Virtual axes, 41~42: Encoders)
UINT Slave Set the the serve axis. (1~32: Actual axes, 37~40: Virtual axes)
Input
BOOL Execute Give cam operation command to the relevant axis in the rising Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
LREAL MasterOffset Set the offset value of the main axis.
LREAL SlaveOffset Set the offset value of the the serve axis cam table.
LREAL MasterScaling Specify the magnification of the main axis.
LREAL SlaveScaling Specify the magnification of the serve axis cam table.
LREAL MasterStartDistance Specify the position of the main axis where cam operation of the slave.
LREAL MasterSyncPosition Specify the starting point at cam table when cam operation starts.
Set the cam operation mode.
0 : Cam table is applied as an absolute value (mcAbsolute)
UINT StartMode
1: Cam table is applied as a relative value based on the command starting point
(mcRelative)

10-38
Chapter10 Motion Function Block

Select the source of the main axis for cam operation.


UINT MasterValueSource 0 : Synchronized in the target value of the main axis.
1 : Synchronized in the current value of the serve axis.
UINT CamTableID Specify the cam table to operate.
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
Indicate that cam operation is normally being fulfilled.
BOOL InSync
(Indicate that the serve axis is following the cam table.)
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to operate the serve axis cam depending on the main axis.
(2) Cam operation command can be given to the serve axis even if the main axis is in stop state.
(3) You must give cam operation abort (MC_CamOut) command to the serve axis or operate other motion function
block to stop cam operation.
(4) The axis is in 'Synchronized Motion' while this motion function block is running.
(5) Set the offset of cam table to be applied in MasterOffset and SlaveOffset. MasterOffset sets the offset with the
starting point of the main axis, and SlaveOffset sets the offset with the starting point of the serve axis. Refer to the
Figure below.

10-39
Chapter10 Motion Function Block

(6) Set the magnification of cam data to be applied in MasterScaling and SlaveScaling. Set the magnification of the
main axis data in MasterScaling, and set the magnification of the the serve axis data. Refer to the Figure below.

SlaveScaling = 2.0

SlaveScaling = 1.0

MasterScaling = 1.0 MasterScaling = 2.0

(7) MasterSyncPosition input specifies the position of the main axis within the table where the synchronization of actual cam
operation is completed, and MasterStartDistane input specifies the relative position of the main axis where the
synchronization starts.

In case MasterScaling is 1.0

In case MasterScaling is 2.0


MasterSyncPosition position is based on the position within the cam table, and actual synchronization position is decided by
considering MasterOffset and MasterScale parameters.
The serve axis starts moving to the synchronization position from the distance of the input value away based on the position
where MasterSyncPosition is actually applied. If it is before starting moving, the serve axiss waits at the relevant position in
stop state, and if the serve axis is already in the section to move to the synchronization position at the beginning of the

10-40
Chapter10 Motion Function Block

command, take back the position of the synchronization starting point by the length of a table until it escapes the
MasterStartDistance range.
Actual synchronization position can vary depending on MasterScaling and SlaveScaling because MasterSyncPosition is a
value based on the inside of cam table, but MasterOffset and MasterStartDistance value remain unaffected.
(8) Once cam operation starts normally, InSync output is On, and EndOfProfile output is 1 scan On every time one cam table
operation is completed.

(9) Cam operation mode is set in StartMode. Setting range is 0 or 1, and the input value outside the setting range
causes an error.
(10) MasterValueSource selects the source of the main axis to be synchronized. If it is set to 0, the serve axis performs
cam operation based on the command position of the main axis which is calculated in motion control module, and
if it is set to 1, the serve axis performs cam operation based on the current position which is received by
communication in servo drive of main axis.
(11) CamTableID sets the number of cam table to be applied to cam operation. Setting range is 1~32 , and the input
value outside the setting range causes error "0x1115” in motion function block.
(12) The relevant axis is in "SynchronizedMotion" state while this motion function block is running.
6.4.2 Cam operation abort (MC_CamOut)

10-41
Chapter10 Motion Function Block

MC_CamOut Availability

Camming stop XGF-M32E

Motion Function Block

MC_CamOut
BOOL Execute Done BOOL
UINT Slave Slave UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Slave Set the the serve axis. (1~32: Actual axes, 37~40: Virtual axes)
Input
BOOL Execute Give cam operation stop command to the relevant axis in the rising Edge.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block immediately disengages cam operation running in the serve axis.
(2) If motion function block of which BufferMode is Aborting in the serve axis where cam operation is running, cam
operation is automatically disengaged and the relevant motion function block is executed. To execute cam
operation abort (MC_CamOut) motion function block, the relevant axis do operation which keeps the speed at the
time when cam operation is disengaged. If you want to completely stop the serve axis, use stop (MC_Halt) or
immediate stop (MC_Stop) motion function block.

10-42
Chapter10 Motion Function Block

MC_GearIn Availability

Electrical gearing run XGF-M32E

Motion Function Block

MC_GearIn
BOOL Execute InGear BOOL
UINT Master Master UINT
UINT Slave Slave UINT
BOOL ContinousUpdate Busy BOOL
INT RatioNumerator Active BOOL
UINT RatioDenominator CommandAborted BOOL
UINT MasterValueSource Error BOOL
LREAL Acceleration ErrorID WORD
LREAL Deceleration
LREAL Jerk
UINT BufferMode

Input-Output
UINT Master Set the main axis. (1~32: Actual axes, 37~40: Virtual axes, 41~42: Encoders)
UINT Slave Set the the serve axis. (1~32: Actual axes, 37~40: Virtual axes)
Input
BOOL Execute Give gear operation command to the relevant axis in the rising Edge.
Specify the update setting of input value.
BOOL ContinuousUpdate (Refer to 10.1.5.Changes in Parameters during Execution of Motion Function
Block)
INT RatioNumerator Specify the numerator of gear ratio. (-32768 ~ 32767)
UINT RatioDenominator Specify the denominator of gear ratio. (0 ~ 65535)
Select data of the main axis to be synchronized.
UINT MasterValueSource 0: Synchronize in the command position of the main axis.
1: Synchronize in the current position of the main axis.
LREAL Acceleration Specify the acceleration at the beginning of gear operation synchronization. [u/s2]
LREAL Deceleration Specify the deceleration at the beginning of gear operation synchronization. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)

10-43
Chapter10 Motion Function Block

Output
BOOL InGear Indicate that gear operation is running by applying gear ration.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is an operation to synchronize the speed of the main axis and the serve axis depending
on gear ratio which is set.
(2) Giving gear operation abort (MC_GearOut) commands to the relevant axis or execution of other motion function
block allow to disengage gear operation.
(3) RatioNumerator and RatioDenominator set the numerator and denominator to be applied to the serve axis
respectively. If the numerator is set to negative number, the rotation direction of the serve axis is the opposite of
the main axis.
(4) MasterValueSource select the data of the main axis which is a standard of synchronization. If it is set to 0,
synchronization operation is based on the command position of the main axis of motion control module, and if it is
set to 1, synchronization operation is based on the current position. Other values set besides these two make
Error of motion function block On and cause “0x1114” in ErrorID.
(5) When this motion function block is executed, the serve axis is synchronized with the main axis through
acceleration/deceleration at the speed in synch with the relevant gear ratio.
(6) The serve axis is in 'SynchronizedMotion' while this motion function block is running.

10-44
Chapter10 Motion Function Block

MC_GearOut Availability

Electrical gearing disengage XGF-M32E

Motion Function Block

MC_GearOut
BOOL Execute Done BOOL
UINT Slave Slave UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT Slave Set the the serve axis. (1~32: Actual axes, 37~40: Virtual axes)
Input
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block immediately disengages gear operation running in the spindle.
(2) If motion function block of which BufferMode is Aborting in the spindle where cam operation is running, gear
operation is automatically disengaged and the relevant motion function block is executed. If gear operation abort
(MC_GearOut) motion function block is only to be executed, the relevant axis performs operation to maintain the
speed at the time when gear operation is disengaged. To completely stop the spindle, use stop (MC_Halt) or
immediate stop (MC_Stop) motion function block.

10-45
Chapter10 Motion Function Block

MC_GearInPos Availability

Electrical gearing by specifying the position XGF-M32E

Motion Function Block

MC_GearInPos
BOOL Execute InSync UINT
UINT Master Master UINT
UINT Slave Slave BOOL
INT RatioNumerator StartSync BOOL
UINT RatioDenominator Busy BOOL
UINT MasterValueSource Active BOOL
LREAL MasterSyncPosition CommandAborted BOOL
LREAL SlaveSyncPosition Error BOOL
UINT SyncMode ErrorID WORD
LREAL MasterStartDistance
LREAL Velocity
LREAL Acceleration
LREAL Deceleration
LREAL Jerk
UINT BufferMode

Input-Output
UINT Master Set the main axis. (1~32: Actual axes, 37~40: Virtual axes, 41~42: Encoders)
UINT Slave Set the the serve axis. (1~32: Actual axes, 37~40: Virtual axes)
Input
BOOL Execute Give a gear operation command to the relevant axis in the rising Edge.
INT RatioNumerator Specify the numerator of gear ratio. (-32768~32767)
UINT RatioDenominator Specify the denominator of gear ratio. (0~65535)
Select the standard of the main axis value to be synchronized.
UINT MasterValueSource 0(mcSetValue): Synchronize in the target position of the main axis.
1(mcActualValue): Synchronize in the current position of the main axis.
LREAL MasterSyncPosition Specify the position of the main axis where gear operation starts.
LREAL SlaveSyncPosition Specify the position of the spindle where gear operation starts.
LREAL MasterStartDistance Specify the distance of the main axis where synchronization starts.
Specify the maximum speed of the spindle at the beginning of synchronization.
LREAL Velocity
[u/s]

10-46
Chapter10 Motion Function Block

Specify the maximum acceleration of the spindle at the beginning of


LREAL Acceleration
synchronization. [u/s2]
Specify the maximum deceleration of the spindle at the beginning of
LREAL Deceleration
synchronization. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
Indicate that gear operation is normally being fulfilled as the specified gear ratio is
BOOL InSync
applied.
BOOL StartSync Indicate synchronization is starting.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is an operation to synchronize the speed of the main axis and the spindle in the set
position depending on gear ratio which is set in the specific position.
(2) Giving gear operation abort (MC_GearOut) commands to the spindle or operation of other motion function block
allow to stop gear operation.
(3) RatioNumerator and RatioDenominator set the numerator and denominator of gear ratio to be applied to the
spindle respectively. If the numerator is set to negative number, the rotation direction of the spindle goes into
reverse of the main axis.
(4) MasterValueSource selects the source of the main axis to be synchronized. If it is set to 0 (mcSetValue),
synchronization is performed by putting the target position of the main axis in the current motion control period as a
source, and if it is set to 1(mcActualValue), synchronization is performed by putting the current position of the main
axis got feedback from the current motion control period as a source. Other values set besides these two cause
"error 0x10D1”.
(5) Input the positions of the main axis and the spindle where gear operation is completed synchronization in
MasterSyncPosition input and SlaveSyncPosition input respectively. Input the distance where the spindle starts
synchronization in MasterStartDistance input, and the spindle starts synchronization at the position away the
distance set in MasterStartDistance input from the position set in MasterSyncPosition input.
(6) Once synchronization starts, StartSync output is On. When synchronization is completed and gear operation starts,
StartSync output is Off and InSync output is On.
(7) The spindle is in 'SynchronizedMotion' while this motion function block is running.

10-47
Chapter10 Motion Function Block

10-48
Chapter10 Motion Function Block

10.3 Group Motion Function Blocks

MC_AddAxisToGroup Availability

Adds one axis to a group in a structure AxesGroup XGF-M32E

Motion Function Block

MC_AddAxisToGroup
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
UINT Axis Axis UINT
UINT IdentInGroup Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group where the relevant axis is added. (1 ~ 16 : Group 1 ~ Group 16)
Set the axis to be added to the relevant group. (1~32: Actual axes, 37~40: Virtual
UINT Axis
axes)
Input
BOOL Execute Give group axis addition command to the relevant axis in the rising Edge.
UINT IdentInGroup Set the ID of the relevant axis to be used in the relevant group. (1 ~ 4)
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block adds Axis specified axis to the axis group specified in AxesGroup input.
(2) ID in the axis group specified to IdentInGroup must have unique value for each axis. (ID of each axis must be
different.) Maximum 4 axes can be included in each axis group, axis ID can be specified in the range of 1-4. If the
specified axis number is outside the range, “error 0x0006” occurs, and if numbers in the axis group overlap, “error
0x2051” occurs.

10-49
Chapter10 Motion Function Block

MC_RemoveAxisFromGroup Availability

Removes one axis to a group in a structure AxesGroup XGF-M32E

Motion Function Block

MC_RemoveAxisFromGroup
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
UINT IdentInGroup Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group where the relevant axis is removed. (1 ~ 16 : Group1 ~ Group 16)
Input
BOOL Execute Give group axis exclusion command to the relevant group in the rising Edge.
Set the axis number in the relevant group to be removed from the relevant
UINT IdentInGroup
group.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block removes the axis which is specified to IdentInGroup in the axis group specified in
AxesGroup input.
(2) If the execution of group axis exclusion is tried when the axis group is not in GroupDisabled, GroupStandBy, and
GroupErrorStop state, "error 0x2003 or 0x2004 or 0x2005" occurs and the axis is not removed. In other words, the
axis cannot be removed when the axis group does not completely stop.

10-50
Chapter10 Motion Function Block

MC_UngroupAllAxes Availability

Removes all axes from the group AxesGroup XGF-M32E

Motion Function Block

MC_UngroupAllAxes
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group where every axis is to be removed. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give MC_UngroupAllAxes command to the relevant group in the rising Edge.
Set the axis number in the relevant group to be removed from the relevant
UINT IdentInGroup
group.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block removes every axis which belongs to the axis group specified in AxesGroup input.
(2) If this motion function block is executed when the axis group is not in GroupDisabled, GroupStandBy, and
GroupErrorStop state, "error 0x2003 or 0x2004 or 0x2005" occurs and the axis is not removed. In other words, the
axis cannot be removed when the axis group does not completely stop.
(3) When the axis which belongs to the group is successfully removed, the relevant group is switched to GroupDisabled
state.

10-51
Chapter10 Motion Function Block

MC_GroupEnable Availability

Changes the state for a group from GroupDisabled to GroupEnable XGF-M32E

Motion Function Block

MC_GroupEnable
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group to be activated. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group activation command to the relevant group in the rising Edge.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to activate the axis group specified in AxesGroup input.
(2) When giving this command to the axis group in GroupDisable state, the relevant axis group is switched to
GroupStandby state.
(3) This motion function block does not affect the power state of each axis in the relevant group.

10-52
Chapter10 Motion Function Block

MC_GroupDisable Availability

Changes the state for a group to GroupDisabled XGF-M32E

Motion Function Block

MC_GroupDisable
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group to be deactivated. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group disablement command to the relevant group in the rising Edge.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to deactivate the axis group specified in AxesGroup input.
(2) The axis group which executes this motion function block is switched to GroupDisabled.
(3) This motion function block does not affect the power state of each axis in the relevant group.

10-53
Chapter10 Motion Function Block

MC_GroupHome Availability

The AxesGroup to perform the search home sequence XGF-M32E

Motion Function Block

MC_GroupHome
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
LREAL[ ] Position Busy BOOL
UINT BufferMode Active BOOL
CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group returning to home. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group homing command to the relevant group in the rising Edge.
LREAL[ ] Position Specify the absolute position of each axis when reference signal is detected.
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give homing command to the axis group specified in AxesGroup input.
(2) Homing method is operated as specified in servo parameter of the relevant axis in advance.
(3) In Position input, specify the absolute position to the array to be set when homing is completed or Reference Signal
is detected. Values in the array and the axis in the group correspond in the order of [1, 2, 3, 4]. (1~4 are the axis ID in
the axis group)
(4) The axis group is in 'GroupHoming' state while this motion function block is running, and it is switched to
'GroupStandby' state when motion function block is completed.

10-54
Chapter10 Motion Function Block

MC_GroupSetPosition Availability

Sets the Position of all axes in a group without moving XGF-M32E

Motion Function Block

MC_GroupSetPosition
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
Position Busy BOOL
BOOL Relative Active BOOL
UINT ExecuteMode CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Select the group to set the current position. (1 ~ 16 : Group 1 ~ Group 16)
Input
Give group current position setting command to the relevant group in the rising
BOOL Execute
Edge.
LREAL[ ] Position Specify the position.
BOOL Relative 0: Position value=Absolute position, 1: Position value=Relative position
0: Immediately applied the position value,
UINT ExecuteMode
1: Applied at the same point with ‘Buffered’ of Buffermode
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block sets the current position of the relevant axis group.
(2) Specify the position of each axis in the group to the array. When executing this motion function block, if Relative
input is Off, the position of the relevant axis is replaced by the Position input value, and if Relative input is On, the
Position input value is added to the current position of the relevant axis. Values in the array and the axis in the group
correspond in the order of [1, 2, 3, 4]. (1~4 are the axis ID in the axis group)

10-55
Chapter10 Motion Function Block

(3) ExcutionMode input specifies the setting point. If it is 0, it is set immediately after the execution of a command, If it
is 1, it is set at the same point with ‘Buffered’ of sequential operation setting. The value unable to be set causes
"error 0x201B”.
0 (mcImmediately): Change the value of parameter immediately after the execution of motion function block (rising
Edge in Execute input). If the relevant axis is running, the operation can be affected.
1 (mcQueued): Changed at the same point of ‘Buffered’ of Buffermode ( Refer to 10.1.4 BufferMode).

10-56
Chapter10 Motion Function Block

MC_GroupStop Availability

Stop a Group immediately XGF-M32E

Motion Function Block

MC_GroupStop
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
LREAL Deceleration Busy BOOL
LREAL Jerk Active BOOL
CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group to stop immediately. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group immediate stop command to the relevant group in the rising Edge.
LREAL Deceleration Specify the deceleration in time of stop. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give an emergency stop command to the relevant axis group.
(2) The relevant axis group moves on the route which it was following until it completely stops.
(3) When executing group immediate stop (MC_GroupStop) motion function block, motion function block which the
relevant axis group is performing is interrupted, and the axis is changed to 'GroupStopping'. When the relevant axis
group is in ‘GroupStopping’ state, other motion function block cannot be given to the relevant axis until the stop is
completed (until Done output is On).

10-57
Chapter10 Motion Function Block

(4) CommandAborted output indicates that the current motion function block is interrupted while it was executed.
Because other motion function block cannot interrupt group immediate stop (MC_GroupStop) command while
group immediate stop (MC_GroupStop) command is being executed, CommandAborted output is On when the
power of servo is cut, servo Off command is executed, or servo connection is disconnected.
(5) If Execute input is On or the speed of the axis is not 0, the axis is in ' GroupStopping' state, and if Done output is On
and Execute input is Off, the axis is switched to ' GroupStandBy' state.

10-58
Chapter10 Motion Function Block

MC_GroupHalt Availability

Stop a Group XGF-M32E

Motion Function Block

MC_GroupHalt
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
LREAL Deceleration Busy BOOL
LREAL Jerk Active BOOL
UINT BufferMode CommandAborted BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group to stop. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group stop command to the relevant group in the rising Edge.
LREAL Deceleration Specify the deceleration in the time of stop. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give a stop command to the relevant axis.
(2) The relevant axis group moves on the route which it was following until it completely stops.
(3) The axis is in 'GroupMoving' state while this motion function block is running, and if the axis group completely stops,
'Done' output is On and the group state is changed to 'GroupStandBy' state.

10-59
Chapter10 Motion Function Block

MC_GroupReset Availability

Reset a group error XGF-M32E

Motion Function Block

MC_GroupReset
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
Busy BOOL
Error BOOL
ErrorID WORD

Input-Output
UINT AxesGroup Set the group to do error reset. (1 ~ 16 : Group 1 ~ Group 16)
Input
BOOL Execute Give group error reset command to the relevant group in the rising Edge.
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to reset the error of the relevant axis group. When the relevant axis is in
'GroupErrorStop', the execution of motion function block resets the error occurred in the current relevant axis and
switches the axis group to 'GroupStandBy' state.
(2) When executing this motion function block, every error occurred in each axis in the group is reset. (This has the
same effect with when executing the axis error reset (MC_Reset) command in each axis.)

10-60
Chapter10 Motion Function Block

MC_MoveLinearAbsolute Availability

Absolute positioning linear interpolation operation XGF-M32E

Motion Function Block

MC_MoveLinearAbsolute
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
LREAL[ ] Position Busy BOOL
LREAL Velocity Active BOOL
LREAL Acceleration CommandAborted BOOL
LREAL Deceleration Error BOOL
LREAL Jerk ErrorID WORD
UINT BufferMode
UINT TransitionMode
LREAL TransitionParameter

Input-Output
Set the group to perform absolute position linear interpolation operation. (1 ~ 16:
UINT AxesGroup
Group 1 ~ Group 16)
Input
Give absolute position linear interpolation operation command to the relevant group
BOOL Execute
in the rising Edge.
LREAL[ ] Position Specify the target position of each axis.
LREAL Velocity Specify the maximum speed of the route. [u/s]
LREAL Acceleration Specify the maximum acceleration. [u/s2]
LREAL Deceleration Specify the maximum deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Specify the route change mode of group operation.
UINT TransitionMode
(Refer to 10.1.6.TransitionMode )
Specify the parameter of the route change setting of group operation..
LREAL TransitionParameter
(Refer to 10.1.6.TransitionMode )
Output
BOOL Done Indicate whether to reach the specified position.
BOOL Busy Indicate that the execution of motion function block is not completed.

10-61
Chapter10 Motion Function Block

BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give an absolute position linear interpolation command to the axis group specified in
AxesGroup input.
(2) When this motion function block is executed, interpolation control is performed in a linear path from the current
position to the target position of each axis, and the moving direction is decided by the starting point and the target
point of each axis.
Beginning position < Target position: Forward direction operation
Beginning position > Target position: Reverse direction operation
(3) In Position input, specify the target position of each axis in the group as matrix. The values in the array and the axis
in the group correspond in the order of [1, 2, 3, 4]. (1~4 are axis ID in the axis group)
(4) Specify the speed, acceleration, deceleration, and the change rate of acceleration/deceleration of interpolation route
in Velocity, Acceleration, Deceleration, and Jerk inputs respectively.
(5) Velocity is to set the interpolation speed of the axis group, and it indicates the integrated speed of each axis.
Operation speeds of each configuration axis are calculated as follows.
Interpolation speed (F) = Target speed specified in the Velocity

Interpolation movement amount (S) = S1 + S 2 + S 3 + S 4


2 2 2 2

Configuration axis 1 movement amount (S1 )


Configuration axis 1 speed (V1 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 2 movement amount (S 2 )


Configuration axis 2 speed (V2 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 3 movement amount (S 3 )


Configuration axis 3 speed (V3 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 4 movement amount (S 4 )


Configuration axis 4 speed (V4 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

(6) Refer to linear interpolation control part in motion control module’s manual for more details.

10-62
Chapter10 Motion Function Block

MC_MoveLinearRelative Availability

Relative positioning linear interpolation operation XGF-M32E

Motion Function Block

MC_MoveLinearRelative
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
LREAL[ ] Distance Busy BOOL
LREAL Velocity Active BOOL
LREAL Acceleration CommandAborted BOOL
LREAL Deceleration Error BOOL
LREAL Jerk ErrorID WORD
UINT BufferMode
UINT TransitionMode
LREAL TransitionParameter

Input-Output
Set the group to do relative position linear interpolation operation. (1 ~ 16: Group 1
UINT AxesGroup
~ Group 16)
Input
Give relative position linear interpolation operation command to the relevant group
BOOL Execute
in the rising Edge.
LREAL[ ] Distance Set the target distance of each axis.
LREAL Velocity Specify the maximum speed of the route. [u/s]
LREAL Acceleration Specify the maximum acceleration. [u/s2]
LREAL Deceleration Specify the maximum deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)
Specify the route change mode of group operation.
UINT TransitionMode
(Refer to 10.1.6.TransitionMode )
Specify the parameter of the route change setting of group operation..
LREAL TransitionParameter
(Refer to 10.1.6.TransitionMode )
Output
BOOL Done Indicate whether to reach the specified position.
BOOL Busy Indicate that the execution of motion function block is not completed.

10-63
Chapter10 Motion Function Block

BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give a relative position linear interpolation command to the axis group specified in
AxesGroup input.
(2) When this motion function block is executed, interpolation control performed in a linear path from the current position
to the target position of each axis, and the moving direction is decided by the sign of the target distance of each axis.
Target distance > 0: Forward direction operation
Target distance < 0: Reverse direction operation
(3) In Distance input, specify the target distance of each axis in the group as array. The specified array and the axis in
the group correspond in the order of specified axis ID [ID1 target distance, ID2 target distance, …].
(4) Set the speed, acceleration, deceleration, and the change rate of acceleration/deceleration of interpolation route in
Velocity, Acceleration, Deceleration, and Jerk inputs respectively.
(5) Velocity is to set the interpolation speed of the axis group, and it indicates the integrated speed of each axis.
Operation speeds of each configuration axis are calculated as follows.
Interpolation speed (F) = Target speed specified in the Velocity

Interpolation movement amount (S) = S1 + S 2 + S 3 + S 4


2 2 2 2

Configuration axis 1 movement amount (S1 )


Configuration axis 1 speed (V1 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 2 movement amount (S 2 )


Configuration axis 2 speed (V2 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 3 movement amount (S 3 )


Configuration axis 3 speed (V3 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

Configuration axis 4 movement amount (S 4 )


Configuration axis 4 speed (V4 ) = Interpolation speed (F) ×
Interpolation movement amount (S)

(6) Refer to linear interpolation control part in motion control module’s manual for more details.

10-64
Chapter10 Motion Function Block

MC_MoveCircularAbsolute Availability

Absolute positioning circular interpolation operation XGF-M32E

Motion Function Block

MC_MoveCircularAbsolute
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
UINT CircMode Busy BOOL
LREAL[ ] AuxPoint Active BOOL
LREAL[ ] EndPoint CommandAborted BOOL
UINT PathChoice Error BOOL
LREAL Velocity ErrorID WORD
LREAL Acceleration
LREAL Deceleration
LREAL Jerk
UINT BufferMode
UINT TransitionMode
LREAL TransitionParameter

Input-Output
Set the group to do absolute position circular interpolation operation. (1 ~ 16: Group
UINT AxesGroup
1 ~ Group 16)
Input
Give absolute position circular interpolation operation command to the relevant
BOOL Execute
group in the rising Edge.
UINT CirMode Circular interpolation method setting [0: Midpoint, 1: Central point, 2: Radius]
Specify the position of auxiliary point depending on the circular interpolation
LREAL[ ] AuxPoint
method in an absolute coordinate.
LREAL[ ] EndPoint Specify the end point of circular arc in an absolute coordinate.
Circular route selection
BOOL PathChoice
0: Clockwise, 1: Counterclockwise
LREAL Velocity Specify the maximum speed of the route. [u/s]
LREAL Acceleration Specify the maximum acceleration. [u/s2]
LREAL Deceleration Specify the maximum deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]
Specify the sequential operation setting of motion function block.
UINT BufferMode
(Refer to 10.1.4.BufferMode)

10-65
Chapter10 Motion Function Block

UINT TransitionMode Unused


LREAL TransitionParameter Unused
Output
BOOL Done Indicate whether to reach the specified position.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give an absolute position circular interpolation command to the axis group specified in
AxesGroup input.
(2) When this motion function block starts, each axis performs circular path interpolation control which refers to the set
auxiliary point, and the movement direction is decided by PathChoice input. When setting PathChoice input to 0,
circular interpolation operation is done clockwise, and when setting it to 1, circular interpolation operation is done
counterclockwise.
(3) Specify the absolute position of the auxiliary point to refer when doing circular interpolation of each axis in AuxPoint and
EndPoint inputs as array. The entered array and the axis in the group correspond in the order of the specified axis ID [ID1,
ID2, ID3, ∙∙∙ ]. (The 3 LEAL type sized array should be entered in Position input as there are 3 axes which comprise the
group to give a circular interpolation operation command.)
(4) Specify the speed, acceleration, deceleration, and the change rate of acceleration of interpolation route in Velocity,
Acceleration, Deceleration, and Jerk inputs respectively.
(5) Set the circular interpolation method in CircMode input. The circular interpolation methods which are different from
the value specified in CircMode are as below.
 Circular interpolation of midpoint specifying method (BORDER, CircMode = 0)
In this method, operation starts at the starting point and it does circular interpolation through the specified
position of the central point to the target position. The Figure below shows that the coordinate of the axis
group at the beginning of a command corresponds to the starting point, the coordinate entered in AuxPoint
corresponds to the central point, and the coordinate entered in EndPoint corresponds to the target position in
an absolute value.

10-66
Chapter10 Motion Function Block

 Circular interpolation of central point specifying method


In this method, operation starts at the current position, and it does circular interpolation to the target position
along the circular path, which has a radius of the distance to the specified central position. The Figure below
shows that the coordinate of the axis group at the beginning of a command corresponds to the current
position, the coordinate entered in AuxPoint corresponds to the central point, and the coordinate entered in
EndPoint corresponds to the target point as an absolute value.

 Circular interpolation using the radius specifying method


In this method, operation starts at the current position, and it does circular interpolation to the target position
along the circular path which has a radius of the value specified in the radius. The Figure below shows that
the coordinate of the axis group at the beginning of a command corresponds to the current position, the value
entered in X-axis of AuxPoint corresponds to the radius, and the coordinate entered in EndPoint corresponds
to the target point in an absolute value.

(6) Refer to linear interpolation control part in motion control module’s manual for more details.

10-67
Chapter10 Motion Function Block

MC_MoveCircularRelative Availability

Relative positioning circular interpolation operation XGF-M32E

Motion Function Block

MC_MoveCircularRelative
BOOL Execute Done BOOL
UINT AxesGroup AxesGroup UINT
UINT CircMode Busy BOOL
LREAL[ ] AuxPoint Active BOOL
LREAL[ ] EndPoint CommandAborted BOOL
USINT PathChoice Error BOOL
LREAL Velocity ErrorID WORD
LREAL Acceleration
LREAL Deceleration
LREAL Jerk
UINT BufferMode
UINT TransitionMode
LREAL TransitionParameter

Input-Output
Set the group to do absolute position circular interpolation operation. (1 ~ 16: Group
UINT AxesGroup
1 ~ Group 16)
Input
Give relative position circular interpolation operation command to the relevant
BOOL Execute
group in the rising Edge.
UINT CirMode Circular interpolation method setting [0: Midpoint, 1: Central point, 2: Radius]
Specify the position of auxiliary point depending on the circular interpolation
LREAL[ ] AuxPoint
method as the relative coordinate based on the starting point.
Specify the end point of circular arc as the relative coordinate based on the starting
LREAL[ ] EndPoint
point.
Circular route selection
BOOL PathChoice
0: Clockwise, 1: Counterclockwise
LREAL Velocity Specify the maximum speed of the route. [u/s]
LREAL Acceleration Specify the maximum acceleration. [u/s2]
LREAL Deceleration Specify the maximum deceleration. [u/s2]
LREAL Jerk Specify the change rate of acceleration/deceleration. [u/s3]

10-68
Chapter10 Motion Function Block

Specify the sequential operation setting of motion function block.


UINT BufferMode
(Refer to 10.1.4.BufferMode)
UINT TransitionMode Unused
LREAL TransitionParameter Unused
Output
BOOL Done Indicate whether to reach the specified position.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Active Indicate that the current motion function block is controlling the relevant axis.
BOOL CommandAborted Indicate that the current motion function block is interrupted while it is running.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to give a relative position circular interpolation command to the axis group specified in
AxesGroup input.
(2) When this motion function block starts, each axis performs circular path interpolation control which refers to the set
auxiliary point, and the movement direction is decided by PathChoice input. When setting PathChoice input to 0,
circular interpolation operation is done clockwise, and when setting it to 1, circular interpolation operation is done
counterclockwise.
(3) Specify the relative position of the auxiliary point to refer when doing circular interpolation of each axis in AuxPoint and
EndPoint inputs as array. The entered array and the axis in the group correspond in the order of the specified axis ID [ID1,
ID2, ID3, ∙∙∙ ]. (The 3 LEAL type sized array should be entered in Position input as there are 3 axes which comprise the
group to give a circular interpolation operation command.)
(4) Specify the speed, acceleration, deceleration, and the change rate of acceleration of interpolation route in Velocity,
Acceleration, Deceleration, and Jerk inputs respectively.
(5) Set the circular interpolation method in CircMode input. The circular interpolation methods which are different from
the value specified in CircMode are as below.
● Circular interpolation of midpoint specifying method (BORDER, CircMode = 0)
In this method, operation starts at the current position and it does circular interpolation through the specified
position of the central point to the target position.
The Figure below shows that the coordinate of the axis group at the beginning of a command
corresponds to the current position, the coordinate entered in AuxPoint corresponds to the central point,
and the coordinate entered in EndPoint corresponds to the target position in a relative value.

10-69
Chapter10 Motion Function Block

● Circular interpolation of central point specifying method


In this method, operation starts at the current position, and it does circular interpolation to the target position
along the circular path, which has a radius of the distance to the specified central position. The Figure below
shows that the coordinate of the axis group at the beginning of a command corresponds to the current
position, the coordinate entered in AuxPoint corresponds to the central point, and the coordinate entered in
EndPoint corresponds to the target point as a relative value.

● Circular interpolation using the radius specifying method


In this method, operation starts at the current position, and it does circular interpolation to the target position
along the circular path which has a radius of the value specified in the radius. The Figure below shows that
the coordinate of the axis group at the beginning of a command corresponds to the current position, the value
entered in X-axis of AuxPoint corresponds to the radius, and the coordinate entered in EndPoint corresponds
to the target point in a relative value.

(6) Refer to linear interpolation control part in motion control module’s manual for more details.

10-70
Chapter10 Motion Function Block

10.4 Dedicated Function Blocks

LS_Connect Availability

Connect servo drives XGF-M32E

Motion Function Block

LS_Connect
BOOL Execute Done BOOL
Busy BOOL
Error BOOL
ErrorID WORD

Input
Give communication connection command to the relevant module in the rising
BOOL Execute
Edge.
Output
BOOL Done Indicate whether to complete communication connection.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to give a command to connect communication with servo drive or external input/output
apparatus to the module.
(2) When slave devicees are normally connected, Done is On and Busy is Off.
(3) If an error occurs during the communication connection, Error is On and error number is output in ErrorID according
to the cause.

10-71
Chapter10 Motion Function Block

LS_Disconnect Availability

Disconnect servo drives XGF-M32E

Motion Function Block

LS_Disonnect
BOOL Execute Done BOOL
Busy BOOL
Error BOOL
ErrorID WORD

Input
Give communication disconnection command to the relevant module in the rising
BOOL Execute
Edge.
Output
BOOL Done Indicate whether to complete communication disconnection.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block gives a command which orders the module to disconnect the communication with servo
drive or external input/output apparatuses.
(2) If communication slave is disconnected, Done is On and Busy is off.
(3) If an error occurs during the execution of communication disconnection, Error is On and error number is output in
ErrorID according to the error situation.

10-72
Chapter10 Motion Function Block

LS_ReadServoParameter Availability

Read servo parameters XGF-M32E

Motion Function Block

MC_ReadServoParameter
BOOL Execute Done BOOL
UINT Axis Axis UINT
UINT Index Busy BOOL
UINT SubIndex Error BOOL
UINT Length ErrorID WORD
Value DINT

Input-Output
UINT Axis Set the axis to be given a command. (1~32: Actual axes)
Input
BOOL Execute Give servo parameter reading command to the relevant axis in the rising Edge.
UINT Index Set the Index of servo parameter Object to be read. (0x0000~0x9FFF)
UINT SubIndex Set the SubIndex of servo parameter Object to be read. (0 ~ 255)
UINT Length Set the distance of servo parameter Object to be read by Byte. (1 ~ 4)
Output
BOOL Done Indicate that servo parameter is successfully read.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
LREAL Value Output the value of servo parameter.
(1) This motion function block is to read the parameter (CoE Object) value of servo drive in the relevant axis, and reads
the servo parameter value of the position specified in Index and SubIndex of the axis specified by Axis input as much
as the size of Length and indicates it on Value output.
(2) Value output is eliminated to 0 when motion function block is running, and it is output as the read value when the
running is completed (Done output is On).

10-73
Chapter10 Motion Function Block

(3) Index input can be set as below. If the value is set outside the range, "error 0x1F12” occurs.
Value Description
16#0000 ~ 16#0FFF Data Type Description
16#1000 ~ 16#1FFF Communication objects
16#2000 ~ 16#5FFF Manufacturer Specific Profile Area
16#6000 ~ 16#9FFF Standardized Device Profile Area

(4) The value between 0~255 can be entered in SubIndex, and if the value is set outside the range, "error 0x1F12”
occurs.
(5) The value between 1~4 can be set in Length, which means 1~4 Byte. If the value is set outside the range, “error
0x1F12” occurs.

10-74
Chapter10 Motion Function Block

LS_WriteServoParameter Availability

Write servo parameters XGF-M32E

Motion Function Block

MC_WriteServoParameter
BOOL Execute Done BOOL
UINT Axis Axis UINT
UINT Index Busy BOOL
UINT SubIndex Error BOOL
UINT Length ErrorID WORD
DINT Value
UINT ExecutionMode

Input-Output
UINT Axis Set the axis to be given a command. (1~32: Actual axes)
Input
BOOL Execute Give servo parameter writing command to the relevant axis in the rising Edge.
UINT Index Set the Index of servo parameter Object to be written. (0x0000~0x9FFF)
UINT SubIndex Set the SubIndex of servo parameter Object to be written. (0 ~ 255)
UINT Length Set the distance of servo parameter Object to be written by Byte. (1 ~ 4)
DINT Value Set the value to be written in servo parameter.
Specify the time when performing servo parameter writing.
UINT ExecuteMode 0: Immediately executed
1: Applied at the same time with ‘Buffered’ of BufferMode.
Output
BOOL Done Indicate that servo parameter is successfully read.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.
(1) This motion function block is to write the parameter (CoE Object) value of the relevant axis servo drive, and it writes
the value entered in Value as the size of the Length in servo parameter of the position specified as Index and
SubIndex of the axis specified in Axis input.
(2) Index input can be set as below. When it is set to the value besides the set value, “error 0x1F12” occurs.

10-75
Chapter10 Motion Function Block

Value Description
16#0000 ~ 16#0FFF Data Type Description
16#1000 ~ 16#1FFF Communication objects
16#2000 ~ 16#5FFF Manufacturer Specific Profile Area
16#6000 ~ 16#9FFF Standardized Device Profile Area

(3) The value between the range of 0~255 can be entered in SubIndex, and if the value outside the range is set, “error
0x1F12” occurs.
(4) The value between the range of 1~4 can be entered in Length, which means 1~4 Byte. If the value outside the range
is set, "error 0x1F12” occurs.
(5) The time when parameter is written is set in ExecutionMode, and values can be set as below. The value unable to
be set causes "error0x101B”.
0 (mcImmediately): Change the parameter value immediately after the execution of motion function block(rising
Edge in Execute input) If the relevant axis is running, operation can be affected.
1 (mcQueued): Changed at the same time with‘Buffered’of BufferMode. (Refer to 10.1.4. BufferMode input)

10-76
Chapter10 Motion Function Block

LS_EncoderPreset Availability

Encoder preset XGF-M32E

Motion Function Block

LS_EncoerPreset
BOOL Execute Done BOOL
UINT Encoder Busy BOOL
LREAL Position Error BOOL
BOOL Relative ErrorID WORD

Input
BOOL Execute Specify the position of the relevant encoder in the rising Edge.
UINT Encoder Set the encoder to set the position. (1~2: Encoder 1~Encoder 2)
LREAL Position Specify the position to set. [u]
0: Absolute coordinate position
BOOL Relative
1: Relative coordinate position
Output
BOOL Done Indicate the state of motion function block completion.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

10-77
Chapter10 Motion Function Block

LS_Jog Availability

JOG operation XGF-M32E

Motion Function Block

LS_Jog
BOOL Enable Enabled BOOL
UINT Axis Axis UINT
BOOL Direction Busy BOOL
BOOL Low/High Error BOOL
ErrorID WORD

Input-Output
UINT Axis Set the axis to be given a command. (1~32: Actual axes)
Input
BOOL Enable Give jog command to the relevant axis while input is On.
BOOL Direction Set the rotation direction in jog (0: Forward direction, 1: Reverse direction)
Set the jog speed in jog.
BOOL Low/High
(0: Jog low speed operation, 1: Jog high speed operation)
Output
BOOL Enabled Indicate that the relevant axis is in jog.
BOOL Busy Indicate that the execution of motion function block is not completed.
BOOL Error Indicate whether an error occurs or not.
WORD ErrorID Output the number of error occurred while motion function block is running.

(1) This motion function block is to make the relevant axis perform jog operation.
(2) Jog is a manual operation function for test and is used to confirm the position address for system operation, wiring
condition check, and teaching. Jog can be used by dividing the speed into high speed and low speed.
(3) When Enable input is On (in jog), if the value set in Low/High is changed, speed change occurs without stop in jog,
and if the value set in JOG_DIR is changed, Jog is continued by changing the direction after the deceleration
pause.

10-78
Chapter11 Expanded Function

Chapter 11 Expanded Function


This chapter describes each expanded function.. It is used for a specific processing (ex. FOR ~ NEXT, CALL, etc.) of a part of
program during user program run.

11-1
Chapter10 Expanded Function

1.1. FOR/NEXT/BREAK

LOOP command

FOR/NEXT/BREAK Availability XGF-M32E

Flags _ERR, _LER

Function Description

FOR N

Repeat a block of FOR ~ NEXT n times

NEXT

BREAK Escape a block of FOR ~ NEXT

■ Function

(1) PLC repeats FOR ~ NEXT command n times and then processes the next step of NEXT command.
(2) n is available 1 ~ 65,535.
(3) FOR ~ NEXT command is able to use 16 NESTINGs.
(4) REAK command is the instruction to escape FOR ~ NEXT loop.
(5) Keep the range of WDT value to avoid delaying the scan time.

■ Program Example

FOR 100
.
.
.

ON
BREAK
.
.
.

NEXT

(1) It operates FOR ~ NEXT loop 100 times repeatedly.


(2) To escape the loop during a repetition, turn the switch on and run the BREAK command.

11-2
Chapter11 Expanded Function

1.2. CALL/SBRT/RET

Command of function call

CALL/SBRT/RET Availability XGF-M32E

Flags

Function Description

CALL NAME Call a SBRT routine

SBRT NAME Assign a routine to be called by the CALL function

RET RETURN

■ Function

(1) With an input condition and the CALL n command, it operates a program among the SBRT n ~ RET command.
(2) Nested CALL n command is usable, and the program among SBRT n ~ RET must be placed after END command.
(3) A program which is in SBRT can call another SBRT. In this case, END command is impossible to use in the SBRT.
(4) A program can escape the FOR ~ NEXT loop with a BREAK command.

■ Program Example

CALL Motor Start


.
.
.
END

SBRT Motor Start


.
.
.
RET

(1) It calls a SBRT (Motor Start) if the program operates CALL command.
(2) SBRT command must be placed after the END command.
(3) When SBRT (Motor Start) is called, a program is run in the SBRT until RET command. It goes to the position again
where CALL command is called.

11-3
Chapter10 Expanded Function

1.3. JMP

JUMP command

JMP Availability XGF-M32E

Flags

Function Description

JMP LABLE Jump to a place of LABLE

■ Function

(1) If a switch of JMP (LABLE) command is on, it jumps to the next of the assigned LABLE. All the commands
between JMP and LABLE are not processed.
(2) LABLE must not be duplicated, but JMP can be repeated.
(3) It is recommended that the program which must not be run in a state of emergency is placed between JMP and
LABLE.

■ Program Example

(1) When %IX0.0 is on, it does not operate ABS function.

11-4
Chapter11 Expanded Function

1.4. INIT_

1.5. END

END command

END Availability XGF-M32E

Flags

Function Description

END Terminate a program

■ Function

(1) It indicates the end of a program.


(2) After the processing of the END command, the program goes to the beginning of itself and process again.

11-5
Chapter10 Expanded Function

11-6
Chapter12 ST (Strructured Text)

Chapter 12 ST (Structured Text)

12.1 General
▷ ST program can use all of text editor and has high portability.
▷ It can express complicated expression and algorithm well
▷ A person skilled at computer language can use easily.

12.2. Comments
There are two types in comments, one line comment and block comment.
- One line comment uses “//”, that line is used as comment line.
- Block comment considers text between “*” and “*”.
For example)

12-1
Chapter12 ST (Structured Text)

12.3 Expression
(1) Expression consists of operator and operand. Operand may be constant, character, character string, time character, defined
variable (named variable, direct variable), defined function (function, function block). Operator of ST is described in the follow
table. And also expression is calculated according to order of operator of ST language table.

(2) Expression is calculated according to order of operator in <Table 1>. Operator having highest priority is calculated first and
then operator having second highest priority is calculated. This is repeated until end of calculation.
Ex.) A+B*C: first, multiplies B by C and adds the result to A.

Number Operation Symbol Order


1 Parenthesis (Expression) High
2 Function Function name (Parameter list)
Ex.) ADD(X, Y)
3 not -
Complement NOT
4 Exponent **
5 Multiplication *
Division /
Remain MOD
6 Add +
Subtract -
7 Compare <, >, <=, >=
8 same =
Not same <>
9 Bool logical AND &
AND
10 Bool logical Exclusive OR XOR
Low
11 Bool logical OR OR
<Table 1> Operator of ST language

(3) Among same operations which have same order, operation in left of expression has higher order.
For example: A+B-C: first, adds A to B and subtracts C from result of A+B.
(4) If operator has two operands, left operand executes first.
For example: SIN(A)*COS(B): SIN(A) executes first and COS(B) executes last.

(5) When executing operation, the following condition is dealt with error.

12-2
Chapter12 ST (Strructured Text)

(a) Division by 0
For example: A/(B*C): in case result of B*C is 0, operation error occurs.
(b) Operand is not applicable data type for operation.
For example: ADD(1,2,3): unable to determine the data type of number so compile error occurs
(c) Result of arithmetic operation exceeds range of data type.
For example: B*C: When B, C are UINT type, result is higher than 65,535, operation error occurs.

12.3.1 + Operator

(1) + Operator is used to add two operands.


(2) Expression
result := expression1 + expression2

Items Description
Result Named variable or direct variable
expression1 ANY_NUM type
expression2 ANY_NUM type

Example Description
Val1 := 20; Adds Val1(20) to Val2(4) and inputs result
Val2 := 4; Value of Result becomes 24.
Result := Val1 + Val2; Constant and variable can be used as operands (Val1, Val2).

Note

ANY_NUM includes ANY_REAL type and ANY_INT. For more detail, refer to data type layer of ch.3.2.2

12.3.2 - Operator

(1) Subtracts right value from left value.


(2) Expression
result := expression1 - expression2

Items Description
result Named variable or direct variable
expression1 ANY_NUM
expression2 ANY_NUM

12-3
Chapter12 ST (Structured Text)

Example Description
Val1 := 20; Subtracts right value(Val2) from left value(Val1) and inputs result.
Val2 := 4; Value of result becomes 16
Result := Val1 - Val2; Constant and variable can be used as operands (Val1, Val2).

12.3.3 * Operator

(1) Multiplies two operands


(2) Expression
result := expression1 * expression2

Items Description
result Named variable or direct variable
expression1 ANY_NUM type
expression2 ANY_NUM type

Example Description
Multiplies 20 by In1(2) and inputs result.
In1 := 2 ;
Result := 20 * In1 ; Value of result becomes 40.
Constant and variable can be used as operands (Val1, Val2).

12.3.4 / Operator

(1) Divides left value by right value.


(2) Data type of result is different according to data type of operand. If operand is REAL type, result is also REAL type. If operand
is integer, result is also integer. If 5 (int) is divided by 3 (int), result is real but number less than decimal point is removed.

(3) Expression
result := expression1 / expression2
Item Description
result Named variable or direct variable
expression1 ANY_NUM type
expression2 ANY_NUM type

12-4
Chapter12 ST (Strructured Text)

Example Description
Divides 20 by 2(ln1) and inputs result.
In1 := 2 ;
Result becomes 10.
Result := 20 / In1 ; Constant and variable can be used as operands.

12-5
Chapter12 ST (Structured Text)

Notes

If some value is divided by 0, operation error flag (_ERR) is on and CPU is in RUN mode.

12.3.5 MOD operation

(1) Finds remain when dividing left value by right value


(2) Expression
result := expression1 MOD expression2
Item Description
result Named variable or direct variable
expression1 ANY_NUM type
expression2 ANY_NUM type

Example Description
Divides 12 by 10(ln1) and inputs remain into result
In1:= 10 ;
Constant and variable can be used as operands.
Result := 12 MOD In1 ;

Notes

If some value is divided by 0, operation error flag (_ERR) is on and CPU is in RUN mode.

12.3.6 ** Operator

(1) Exponential operator is used to multiply left number as many as right number times
(2) Expression
result := expression1 ** expression2
Items Description
result Named variable or direct variable
expression1 ANY_REAL type
expression2 ANY_REAL type

Example Description
Multiplies 10 as many as 3 times and inputs it to result.
In1 := 3 ;
Result becomes 1000.
Result := 10 ** In1 ; Constant and variable can be used as operands.

12-6
Chapter12 ST (Strructured Text)

12.3.7 AND or & Operator

(1) Executes logical bit AND operation.


(2) Expression
result := expression1 AND expression2 or result := expression1 & expression2

Item Description
result Named variable or direct variable
expression1 ANY_BIT type
expression2 ANY_BIT type

Result of logical bit AND operation is as follows.


expression1 expression2 result
0 0 0
0 1 0
1 0 0
1 1 1

Example Description
Result := 2#10010011 AND 2#00111101 ; Since first bit and 5th bit of two operands are both 1, result is
2#00010001.
Constant and variable can be used as operands.

12.3.8 OR operator

(1) Executes logical bit OR operation.


(2) Expression
result := expression1 OR expression2
Items Description
result Named variable or direct variable
expression1 ANY_BIT type
expression2 ANY_BIT type
Result of logical bit OR operation is as follows.
expression1 expression2 result
0 0 0
0 1 1
1 0 1
1 1 1

12-7
Chapter12 ST (Structured Text)

Example Description
Result := 2#10010011 OR 2#00111101 ; Since there are 1 except 7th bit in two operands, result is
2#10111111.

12.3.9 XOR operator

(1) If bits of two operands are different, result bit is 1.


(2) Expression
result := expression1 XOR expression2
Item Description
result Named variable or direct variable
expression1 ANY_BIT type
expression2 ANY_BIT type

Result of logical bit XOR operation is as follows.


expression1 expression2 result
0 0 0
0 1 1
1 0 1
1 1 0

Example Description
Result := 2#10010011 XOR 2#00111101; Since first bits of two operands are 1, first bit of result is 0.
Result is 2#10101110.

12.3.10 = Operator

(1) Compares two operands if they are same.


(2) Expression
result := expression1 = expression2
Item Description
result Named variable or direct variable
expression1 ANY type
expression2 ANY type

12-8
Chapter12 ST (Strructured Text)

Result of logical bit = operation is as follows.


expression1 expression2 result
0 0 1
0 1 0
1 0 0
1 1 1

Example Description
Val1 := 20; Compares Val1 and Val2 and output result.
Val2 := 20 ; Result is 1.
Result := Val1 = Val2 ;

12.3.11 <> operator

(1) Compares two operands if they are not same.


(2) Expression
result := expression1 <> expression2
Item Description
result Named variable or direct variable
expression1 ANY type
expression2 ANY type
Result of logical bit <> operation is as follows.
expression1 expression2 result
0 0 0
0 1 1
1 0 1
1 1 0

Example Description
Val1 := 20; Compares Val1 and Val2 and output result.
Val2 := 20 ; Result is 0.
Result := Val1 <> Val2 ;

12.3.12 > operator

(1) Compares two operands if left one is larger than right one.
(2) Expression
result := expression1 > expression2
Item Description

12-9
Chapter12 ST (Structured Text)

result Named variable or direct variable


expression1 ANY type
expression2 ANY type

Result of logical bit > operation is as follows.


expression1 expression2 result
0 0 0
0 1 0
1 0 1
1 1 0

Example Description
Val1 := 20; Compares two operands if left one is larger than right one.
Val2 := 10 ; Result is 1.
Result := Val1 > Val2 ;

12.3.13 < operator

(1) Compares two operands if left one is smaller than right one.
(2) Expression
result := expression1 < expression2
Item Description
result Named variable or direct variable
expression1 ANY type
expression2 ANY type

Result of logical bit < operation is as follows.


expression1 expression2 result
0 0 0
0 1 1
1 0 0
1 1 0

Example Description
Val1 := 20; Compares two operands if left one is smaller than right one.
Val2 := 10 ; Result is 0.
Result := Val1 < Val2 ;

12-10
Chapter12 ST (Strructured Text)

12.3.14 >= operator

(1) Compares two operands if left one is larger than right one or same.
(2) Expression
result := expression1 >= expression2
Item Description
result Named variable or direct variable
expression1 ANY type
expression2 ANY type

Result of logical bit >= operation is as follows.


expression1 expression2 result
0 0 1
0 1 0
1 0 1
1 1 1

Example Description
Val1 := 20; Compares two operands if left one is larger than right one or same.
Val2 := 20 ; Result is 1.
Result := Val1 >= Val2 ;

12.3.15 <= operator

(1) Compares two operands if left one is smaller than right one or same.
(2) Expression
result := expression1 <= expression2
Item Description
result Named variable or direct variable
expression1 ANY type
expression2 ANY type

Result of logical bit <= operation is as follows.


expression1 expression2 result
0 0 1
0 1 0
1 0 1
1 1 1

12-11
Chapter12 ST (Structured Text)

Example Description
Val1 := 2; Compares two operands if left one is smaller than right one or same.
Val2 := 20 ; Result is1.
Result := Val1 <= Val2 ;

12.3.16 NOT operator

(1) Changes bit value from 1 to 0 or from 0 to 1.


(2) Expression
result := NOT expression
Item Description
result Named variable or direct variable
expression ANY_BIT type

Example Description
Val1 = 2#1100; Changes Val1 and output Result.
Result:= NOT Val1 ; Result is 2#0011.

12.3.17 - operator

(1) Adds negative sign into value.


(2) Expression
result := - expression
item Description
result Named variable or direct variable
expression ANY_NUM type

Example Description
Val1 = 10; Adds negative sign into value and output is result.
Result:= - Val1 ; Result is -10.

12-12
Chapter12 ST (Strructured Text)

12.4 Statements
(1) Statements of ST language are summarized in <Table 2>.
(2) Statement is ended by semi colon(;).

12.4.1 Assignment statements

(1) Assignment statement consists of Variable, operator(:=) and expression.


Ex.) A := B + C ;
(2) It is available to assign return value of function.

12.4.2 Selection statements

(1) There are two types: IF and CASE.


(2) According to specific condition, selection statement executes one statement or one group of statements among diverse
statements.
(a) IF
1) If condition of Bool expression is 1, it executes a group of statements.
2) If condition is not 1, it does not execute group of statements. But there is ELSE, it executes a group of statements
following ELSE. If condition of ELSEIF is 1, a group of statements following ELEIF executes.
(b) CASE
1) It consists of list of groups of statements and expression that calculates variable of INT type.
2) Each group can be set as integer and range of integer.
3) A group of statements in range of Selector executes and if any value is not in range of Selector, a group of
statements following ELSE executes. If there is no ELSE, group of statements is not executed.

12.4.3 Iteration statements

(1) There are three types, FOR, WHILE and REPEAT.


(2) Some group executes repeatedly by iteration statement.
(a) FOR
1) It is used when number of repetition is already determined.
2) In FOR statement, a group of statements executes repeatedly until END_FOR and status of repetition is saved in
control variable of FOR loop.
3) Control variable, initial value and final value is expressed as integer type (SINT, INT, DINT) and does not change by
repeated statement. Checking the condition for the end executes at the start of each repetition. If initial value exceeds
the final value, a group of statements is not executed any more.
(b) WHILE and REPEAT
1) WHILE statement (ended by END_WHILE) executes repeatedly until Bool expression is 0.
2) REPEAT statement (ended by UNTIL) executes repeatedly until Bool expression is 1.

12-13
Chapter12 ST (Structured Text)

(A group of statements executes at least one time)


3) WHILE and REPEAT is not used for synchronizing process like “wait loop” which has the end condition determined
exteriorly.
4) EXIT statement is used to stop repetition before meeting the condition. When EXIT statement is used in overlapped
repetition statements, relevant EXIT is applied to the loop in which EXIT exists. So, statements after first loop
terminator (END_FOR, END_WHILE, END_REPEAT) are executed.
5) IF WHILE and REPEAT are executed in unlimited loop, error occurs.

Number Command Example


1 Assignment A:=B; CV:= CV+1; C:=SIN(X);
2 Recall of FB CMD_TMR(IN:=%IX0.0, PT:= T#300ms);
Using output of FB A:=CMD_TMR.Q;
3 RETURN RETURN;
4 IF D:=B*B -4*A*C;
IF D<1.0 THEN NROOTS :=0;
ELSIF D= 0.0 THEN
NROOTS := 1;
X1:= -B/(2.0*A);
ELSE
X1:= (-B+SQRT(D))/(2.0*A);
X2:= (-B-SQRT(D))/(2.0*A);
END_IF;
5 CASE TW := BCD_TO_INT(THUMBWHEEL);
TW_ERROR := 0;
CASE TW OF
1, 5: DISPLAY := OVEN_TEMP;
2: DISPLAY := MOTOR_SPEED;
3: DISPLAY := GROSS – TARE;
4,6..10: DISPLAY := STATUS(TW-4);
ELSE DISPLAY := 0;
TW_ERROR := 1;
END_CASE;
QW100 := INT_TO_BCD(DISPLAY);
6 FOR J := 101;
FOR I := 1 TO 100 BY 2 DO
IF WORDS[I] = ‘KEY’ THEN
J := I;

12-14
Chapter12 ST (Strructured Text)

Number Command Example


EXIT;
END_IF;
END_FOR ;
7 WHILE J := 1;
WHILE J <= 100 & WORDS[J] <> ‘KEY’ DO
J := J+2;
END_WHILE;

8 REPEAT J := -1;
REPEAT
J := J+2;
UNTIL J = 101 OR WORDS[J] = ‘KEY’
END_REPEAT ;
9 EXIT EXIT;
10 Null/Space command text ;
EXIT is used for all repetition texts (FOR, WHILE, REPEAT).
<Table 3> Command for ST

12.4.4 IF

(1) It is used for program to select more than one


(2) Expression
IF condition THEN statements [ELSE elsestatements ] END_IF

Or

IF condition THEN
statements
[ELSIF condition-n THEN
elseifstatements] . . .
[ELSE
elsestatements]
END_IF

Item Description
If condition is TRUE, a statement following THEN is executed.
condition
In case of FLASE, ELSIF or ELSE executes.
statements If condition is TRUE, a statement more than one executes.
condition-n N conditions can be used.
elseifstatements If condition-n is TRUE, a statement more than one executes.

12-15
Chapter12 ST (Structured Text)

Item Description
elsestatements If condition or condition-n is false, a statement more than one executes.

Example Description
IF Val1 <= 10 THEN
If condition (Val1 <= 10) is TRUE, 10 is assigned into result.
Result := 10;
END_IF;
IF Val1 <= 10 THEN
If condition (Val1 <= 10) is TRUE, 10 is assigned into result.
Result := 10;
ELSE If condition is FALSE, 20 is assigned into result.
Result := 20;
END_IF;
IF Val1 <= 10 THEN If condition (Val1 <= 10) is TRUE, 10 is assigned into result.
Result := 10; If condition is FALSE, ELSEIF executes. If second condition (Val <= 20) is
ELSIF Val1 <= 20 THEN TRUE, 20 is assigned into result. If second is FALSE, a statement under
Result := 20; ELSE executes. Namely, 30 is assigned into result.
ELSE
Result := 30;
END_IF;

12.4.5 CASE

(1) Diverges according to value of expression following CASE. Expression should be integer. When value of expression is not
included in case list, a statement after ELSE executes. If there is no ELSE, no statement list executes. If there is no branch
command, progresses flow of program executing other all statements.

(2) Expression
CASE expression OF
case_list : statement_list
{ case_list : statement_list}
[ELSE
statement_list]
END_CASE

Item Description
expression Only INT type is available.

case_list case_list_element {',' case_list_element}


There are diverse statement like above.
case_list_element Subrange or signed_integer are available

12-16
Chapter12 ST (Strructured Text)

Item Description
subrange signed_integer .. signed_integer type
statement_list Executes more than one statements

Example Description
CASE Val1 OF If value of Val1 is 1, 10 is assigned into result.
1 : Result := 10 ; If value of Val1 is 2~5, 20 is assigned into result.
2..5 : Result := 20 ; If value of Val1 is 7 or 10, 30 is assigned into result.
7, 10 : Result := 30 ; In case of other values, 40 is assigned into result.
ELSE
Result := 40 ;
END_CASE ;

12.4.6 FOR

(1) It is used to deal with repetition and uses three control statements. First, statement for initialization is necessary. If To
expression is TRUE (present counter value is less than end value), loop executes one time. Then counter values increases
as many as BY value and condition is checked again. In FOR statement, condition is checked first and loop executes later.
So no loop may be executed.
(2) Expression
FOR counter := start TO end [BY step] DO
statements
END_FOR

Item Description
counter Integer (SINT, INT, DINT) s
start, end, step should be the same type.
start Initial value of counter
end Last value of counter
step Indicates increment of count variable whenever loop executes. If this is not used,
increment is 1.
statements It executes according to three control texts.

Example Description
SUM := 0; Counter variable increases from 0 to 10 as many as 1. 1 is added

12-17
Chapter12 ST (Structured Text)

FOR counter := 0 TO 10 DO into SUM variable repeatedly. Final value of SUM is 11.
SUM := SUM + 1;
END_FOR ;
SUM := 0; Counter variable increases from 0 to 10 as many as 2. 1 is added
FOR counter = 0 TO 10 BY 2 DO into SUM variable repeatedly. Final value of SUM is 6.
SUM := SUM + 1;
END_FOR ;

Note

1) Because of long scan time, watch - dog may be on.


2) BY part can be skipped. In case of skip, it increases as many as 1.
3) If start is larger than end, FOR text is not executed.

12.4.7 WHILE

(1) It executes repeatedly until condition is 0. In WHILE statement, condition is checked first and loop is executed later. So no loop
executes.
(2) Expression
WHILE condition DO
statements
END_ WHILE

Item Description
condition If condition is TRUE, statements after DO executes.
In case of FLASE, it goes out from loop.
statements If condition is TRUE, statements more than one executes.

Example Description
Counter := 0
If condition that counter is less than 20 is TRUE, a statement executes.
WHILE Counter < 20 DO
Counter := Counter + 1; If condition is FALSE, it goes out from loop.
END_WHILE ;

Note

In WHILE statement, in case, condition does not become 0, it cannot go out from loop. In this case, due to long scan
time, watch-dog is on. So be careful so that condition is not always TRUE.

12.4.8 REPEAT

(1) Statement executes repeatedly until condition is TRUE. In REPEAT statement, loop executes first and condition is checked

12-18
Chapter12 ST (Strructured Text)

later. So loop executes at least one time.


(2) Expression
REPEAT
statements

UNTIL condition

END_REPEAT

Item Description
condition If condition is FALSE, it executes repeatedly and if TRUE, goes out from
loop.
statements Loop executes repeatedly until condition is TRUE.

Example Description
Counter := 0;
First, Counter variable is set to 1. If the condition that Counter variable is
REPEAT DO
Counter := Counter + 1; larger than 2 is met, it goes out from loop or it executes loop.
UNTIL Counter > 20 If Counter variable is 21, condition is TRUE and it goes out from loop.
END_REPEAT ;

Note

In REPEAT statement, in case condition doesn’t become 1, it cannot go out from loop. In this case, due to long scan
time, watch-dog is on. So be careful so that condition is not always FALSE.

12-19
Chapter12 ST (Structured Text)

12.4.9 EXIT

(1) It is used to go out from iteration statements (WHILE, FOR, REPEAT).


(2) If it is used outside iteration statements, error occurs.
(3) Expression
EXIT

Example Description
SUM := 0; Counter variable increases from 0 to 10 as many as1. But because of EXT,
FOR Counter := 0 TO 10 DO loop ends. Counter variable becomes 0 and SUM becomes 1.
SUM := SUM + 1;
EXIT;
END_FOR ;
Counter := 0;
Text executes repeatedly when Counter is less than 20 and if Counter is
WHILE Counter < 20 DO
Counter := Counter + 1 ; larger than 20, loop ends. But because of IF statement and EXIT statement,
IF Counter = 10 THEN loop ends when Counter is 10.
EXIT;
END_IF;
END_WHILE ;

Counter := 0;
Counter variable increase as many as 1. If Counter is larger than 20, loop
REPEAT DO
Counter := Counter + 1 ; ends otherwise loop executes repeatedly. But because of IF statement and
IF Counter = 10 THEN EXIT statement, loop ends when Counter is 10.
EXIT;
END_IF;
UNTIL Counter > 20
END_REPEAT ;

12-20
Chapter12 ST (Strructured Text)

12.5 Function and Function Block

12.5.1 How to use

(1) There are two types (Standard type, nonstandard type) for use of function and function block. Both are available according to
environment.

(a) Standard type:


It writes the input, output parameter name of function and function block

Parameter Function Function Block

Order of parameter does not matter. Order of parameter does not matter.
Q1 := LIMIT(MN := B, MX := 20, IN := 10) ; INST(IN := %IX0.0, PT := T#1s, Q => A, ET => E) ;
Q1 := LIMIT(MX := 20, MN := B, IN := 10) ; INST(PT := T#1s, IN := %IX0.0, Q => A, ET => E) ;
EN, ENO can be omitted.
Q1 := LIMIT(EN := A, MN := B, MX := 20, IN := 10,
ENO => Q2) ;

Common

Use“:=” for input parameter allocation. Use “:=” for input parameter allocation..
C := LIMIT(MN := B, MX := 20, IN := 10) ; INST(IN := %IX0.0, PT := T#1s, Q => A, ET => B) ;
Input

If output parameter name is OUT or Y (For user Use “=>” for out parameter allocation
defined function, function name), allocate as the Output parameter allocation can be omitted.
return value. INST(IN := %IX0.0, PT := T#1s, Q => A, ET => E) ;
Output For other output parameters, use“=>”.
Q1 := ARY_SCH(DATA := B, IN := C, P => Q2, N
=> Q3) ;

12-21
Chapter12 ST (Structured Text)

Parameter Function Function Block

INST(IN := %IX0.0.0, PT := T#1s) ;


T1 := INST.ET;

Not used output parameter can be omitted as


follows. (Q2, Q3 have been omitted)
Q1 := ARY_SCH(DATA := B, IN := C) ;

Note

To use the function block, write instance name of function block. Declare the function block as how to declare the
variable and write this variable name (instance name)
Ex.) Use of timer

INST_TON1(IN := TRUE, PT := T#100MS, Q => Q_OUT, ET => ET_OUT );

12-22
Chapter12 ST (Strructured Text)

(b) Nonstandard type


In this type, I/O parameter name of function and function block is omitted

Parameter Function Function Block

You cannot change the order of all You cannot change the order of all
parameters. parameters.
You cannot omit any parameter You cannot omit any parameter
Q1 := LIMIT(B, 20, 10) ; INST(%IX0.0, T#1s, A, E) ;

Common

You cannot use EN, ENO


You cannot change the order of input You cannot change the order of input

Input parameter. parameter.


C := LIMIT(B, 20, IN := 10) ; INST(%IX0.0, T#1s, A, E) ;

If output parameter name is OUT or Y (For For all output parameters, input in order of
user defined function, function name), position
allocate as the return value. INST(%IX0.0.0, T#1s, A, E) ;
For other output parameters, input in order
of position
Q1 := ARY_SCH(B, C, Q2, Q3) ;

Output

Note

12-23
Chapter12 ST (Structured Text)

For function whose parameter type is variable, input parameter type should be determined.
Example Description
INT1 := ADD(1, 2, 3); Error occurs while determining function type

For normal operation, choose one among below three examples

Example Description
INT1 := ADD(INT#1, 2, 3); Sets the type of constant
INT1 := ADD(B, 2, 3); Uses variable (B)
INT1 := ADD_INT(1, 2, 3); Uses the type-defined function

Note

- Input parameter EN is condition to execute the function. If you use the EN as follows, LIMIT function executes
when A is 1.
OUT := LIMIT(EN := A, MX := 20, MN := B, IN := 10) ;
ENO parameter becomes 1 when function executes without error. It cannot be used in ST and available in LD

Note

1. ST does not support the extension functions(BREAK, CALL, END, FOR, INIT_DONE, JMP, NEXT, RET, SBRT)
2. You cannot use the function whose name is same as operator name. (OR, XOR, AND, MOD, NOT)

12-24
Chapter12 ST (Strructured Text)

12.5.2 Example
(1) Function

Use of LD Use of ST

1) Standard type
EN used
OutValue := ADD(EN := A, IN1 := Value1, IN2 := Value2);
EN not used
OutValue := ADD(IN1 := Value1, IN2 := Value2);

2) Nonstandard type
OutValue := ADD(Value1, Value2);
EN, ENO cannot be used

(2) Function Block

Use of LD Use of ST

1) Standard type
INST(IN := A, PT := T#10S, Q => TimeOut);

2) Nonstandard type
INST(A, T#10S, TimeOut, TimeValue);
Output variable cannot be omitted. So you have to allocate the
applicable variable to output parameter ET. (TimeValue)

12-25
Chapter12 ST (Structured Text)

(3) Application

Use of LD Use of ST

INST1(CD := _T1S, PV := 10, RST := RESET, Q =>


COMPLETE,
CV => CURRENTVALUE);

%QX0.0 := Complete;

NOTENOUGH := LT(IN1 := CURRENTVALUE, IN2 := 5);

12-26
Appendix1 Numerical System and Data Structure

Appendix 1 Numerical System and Data Structure


A1.1 Numerical (data) Representation

Motion Control module remembers and processes every data as the states of on and off or ‘1’and ’0’. Therefore, any
numerical operation is processed by binary system (1 or 0). On the other hand, we conveniently use the decimal system, so
decimal or hexadecimal number systems must be converted to hexadecimal or decimal number systems, respectively in
order to write or read numerical data to/from PLC. This chapter describes the representation of decimal, binary, hexadecimal
and binary-coded decimal notation and the relations.

1. Decimal
Decimal number system means the “number expressing an order or size (volume) using 0~9.
And, followed by 0, 1, 2, 3, 4…9, it is carried to ‘10’ and keeps counting.
For instance, a decimal number, 153 can be expressed as follows in the view of line and “weight of line.”

153 = 100 + 50 + 3

=1*100 + 5*10 + 3*1


2 1 0
=1*10 + 5*10 + 3*10
Decimal number
system symbols
(0~9)

Weight of line

2. Binary
Binary numeral presents a numeral meaning an order and size by using two symbols, 0 and 1. Therefore, it is carried to
‘10’ followed by 0 and 1 and keeps counting. That is, a cipher of 0, 1 is called bit.

A1-1
Appendix1 Numerical System and Data Structure

Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
…… ……

For instance, let us think that the given binary numeral can be expressed in decimal number system.
“10011101”
As considering line number and the weight of line in decimal number system, try to attach bit number and bit weight from the
very right.

7 6 5 4 3 2 1 0 Bit number
binary numeral
1 0 0 1 1 1 0 1
7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2
...

...

...

...

...

...

...

...

128 64 32 16 8 4 2 1 weight of bit

How about summing the multiplication of weights of each bit code like decimal number system?
= 1 × 128 + 0 × 64 + 0 × 32 + 1 × 16 + 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1
= 128 + 16 + 8 + 4 + 1
= 157
That is, as the above, a binary numeral is converted to a decimal numeral by adding the weights of bits of which code is 1.

In general, 1 byte consists of 8 bits while 1 word consists of 16 bits (2 bytes).

A1-2
Appendix1 Numerical System and Data Structure

1 bit

1 0 0 1 1 1 0 1

1 byte

0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1

1 word (2 bytes)

3. Hexadecimal
Like decimal or binary numeral, hexadecimal numeral means the ‘number representing an order and size by using 0~9
and A~F.”
Then, followed by 0, 1, 2, …D, E, F, it is carried to ‘10’ and keeps counting.

Decimal Hexadecimal Binary


0 0 0
1 1 1
2 2 10
3 3 11
4 4 100
5 5 101
6 6 110
7 7 111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
16 10 10000
17 11 10001
18 12 10010

A1-3
Appendix1 Numerical System and Data Structure

1 9 1 0 1 4 A 9 D 0100 1010 1001 1101

3 2 1 0 Number of line
hexadecimal
4 A 9 D
numeral

= (4) × 163 + (A) × 162 + (9) × 161 + (D) × 160


= 4 × 4096 + 10 × 2568 + 9 × 16 + 13 × 1

= 19101

A digit of hexadecimal number corresponds to 4 bits of binary numeral.

4. Binary Coded Decimal (BCD)


Binary coded decimal means the “number expressing each line of a decimal numeral in binary number system.” Therefore,
binary coded decimal represents 0 ~ 9,999(max of 4 lines) of decimal numeral in 16 bits.

For instance, a decimal numeral, 157 can be expressed as follows and the weight of each bit can be also expressed as
follows.

line 4

line 3

line 2
line 1

0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 1
8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1 Weight of bit
1 5 7

A1-4
Appendix1 Numerical System and Data Structure

5. Table of Numeral Systems

Binary coded Decimal (BCD) Binary (BIN) Decimal Hexadecimal (H)

00000000 00000000 00000000 00000000 0 0000


00000000 00000001 00000000 00000001 1 0001
00000000 00000010 00000000 00000010 2 0002
00000000 00000011 00000000 00000011 3 0003
00000000 00000100 00000000 00000100 4 0004
00000000 00000101 00000000 00000101 5 0005
00000000 00000100 00000000 00000100 6 0006
00000000 00000111 00000000 00000111 7 0007
00000000 00001000 00000000 00001000 8 0008
00000000 00001001 00000000 00001001 9 0009
00000000 00010000 00000000 00001010 10 000A
00000000 00010001 00000000 00001011 11 000B
00000000 00010010 00000000 00001100 12 000C
00000000 00010011 00000000 00001101 13 000D
00000000 00010100 00000000 00001110 14 000E
00000000 00010101 00000000 00001111 15 000F
00000000 00000110 00000000 00010000 16 0010
00000000 00000111 00000000 00010001 17 0011
00000000 00001000 00000000 00010010 18 0012
00000000 00001001 00000000 00010011 19 0013
00000000 00100000 00000000 00010100 20 0014
00000000 00100001 00000000 00010101 21 0015
00000000 00100010 00000000 00010110 22 0016
00000000 00100011 00000000 00010111 23 0017
00000001 00000000 00000000 01100100 100 0064
00000001 00100111 00000000 01111111 127 007F
00000010 01010101 00000000 11111111 255 00FF
00010000 00000000 00000000 11100000 1,000 03E8
00100000 01000111 00000000 11111111 2,047 07FF
01000000 10010101 00000000 11111111 4,095 0FFF
10011001 10011001 00000111 00001111 9,999 270F
- 00100111 00010000 10,000 2710
- 01111111 11111111 32,767 7FFF

A1-5
Appendix1 Numerical System and Data Structure

A1.2 Integer Representation

Motion control module command is based on negative number system operation (Signed)
If the top level bit (MSB) is 0, it represents ‘positive number’ while if it is 1, it is expressed as ‘negative number’.
The top level bit expressing negative/positive is called ‘sign bit.’
Because of different position of MSB in 16 or 32 bits, be cautious of sign bit position.
 If 16 bits
b16 b0

Sign bit 0: 0 and positive number


1: negative number

Representation ran: -32,768 ~ 32,767

 If 32 bits
b31 b16 b15 b0

0 : 0 and positive number


Sign bit
1 : negative number

Representation range: -2,147,483,648 ~ 2,147,483,647

A1.3 Negative Number Representation

Ex) How to express – 0001


(1) Represent 0001 in case of negative number (b15 = 1).
b15 b0
1 0 ~ 0 1

(2) Reverse the result of (1) (b15 = excluded).


b15 b0
1 1 ~ 1 0

(3) Plus 1 to the result of (2).


b15 b0
1 1 ~ 1 1
-0001 = 16#FFFF

A1-6
Appendix2 Flag and Parameter List

Appendix 2 Flag and Parameter List


A2.1 System Flag

It displays the operation, stat and information of the Motion Control Module.

Reserved Variable Data Type Address Description


_RUN BOOL %FX0 RUN status
_STOP BOOL %FX1 STOP status
_ERROR BOOL %FX2 ERROR status
_RUN_EDIT_ST BOOL %FX5 Downloading edit program during run
_RUN_EDIT_CHK BOOL %FX6 Processing edit program during run
_RUN_EDIT_DONE BOOL %FX7 Complete edit program during run
_RUN_EDIT_NG BOOL %FX8 Abnormally complete edit program during run
_FLASH_BUSY BOOL %FX9 Writing to FLASH
_FLASH_FAIL BOOL %FX10 Failed to write to FLASH
_FORCE_IN BOOL %FX11 Forced input status
_FORCE_OUT BOOL %FX12 Forced output status
_PB1 BOOL %FX14 Select program code 1
_PB2 BOOL %FX15 Select program code 2
_BPRM_ER BOOL %FX35 Basic parameter error
_COMPRM_ER BOOL %FX36 Common parameter error
_AXISPRM_ER BOOL %FX37 Axis parameter error
_AXESPRM_ER BOOL %FX38 Axis group parameter error
_NETPRM_ER BOOL %FX39 Network parameter error
_SDPRM_ER BOOL %FX40 Shared variable parameter error
_PGM_ER BOOL %FX41 Program error
_CODE_ER BOOL %FX42 Program code error
_SWDT_ER BOOL %FX45 System watch-dog error
_AB_SD_ER BOOL %FX64 Stop from abnormal operation
_TASK_ER BOOL %FX65 Task collision
_PTASK_CYCLE_ER BOOL %FX67 Main task period error
_CTASK_CYCLE_ER BOOL %FX168 Periodic task period error
_T20MS BOOL %FX96 20ms cycle clock
_T100MS BOOL %FX97 100ms cycle clock
_T200MS BOOL %FX98 200ms cycle clock

A2-1
Appendix2 Flag and Parameter List

Reserved Variable Data Type Address Description


_T1S BOOL %FX99 1s cycle clock
_T2S BOOL %FX100 2s cycle clock
_T10S BOOL %FX101 10s cycle clock
_T20S BOOL %FX102 20s cycle clock
_T60S BOOL %FX103 60s cycle clock
_ON BOOL %FX104 All time on bit
_OFF BOOL %FX105 All time off bit
_1ON BOOL %FX106 The only first scan on bit
_1OFF BOOL %FX107 The only first scan off bit
_STOG BOOL %FX108 Reversal at every scanning
_ERR BOOL %FX112 Operation error flag
_LER BOOL %FX113 On for 1 scan if any operation error
_ARY_IDX_ERR BOOL %FX114 Out of arrangement index error flag
_ARY_IDX_LER BOOL %FX115 Out of arrangement index latch error flag
_OS_VER DWORD %FD4 OS version
_OS_DATE DWORD %FD5 OS distribution date
_OS_VER_PATCH DWORD %FD6 OS patch version
_SCAN_MAX WORD %FW14 Main task – Maximum scan time
_SCAN_MIN WORD %FW15 Main task – minimum scan time
_SCAN_CUR WORD %FW16 Main task – Current scan time
_CTASK_SCAN_MAX WORD %FW17 Periodic task – Maximum scan time
_CTASK_SCAN_MIN WORD %FW18 Periodic task – minimum scan time
_CTASK_SCAN_CUR WORD %FW19 Periodic task – Current scan time
ARRARY [0..7] %FB40
_PLC_TIME Current RTC time
OF BYTE
_PLC_DATE DATE %FW24 Current RTC date
_PLC_TOD TIME_OF_DAY %FD13 Current time of RTC(ms unit)
_FLASH_WR_RATIO WORD %FW28 FLASH writing ratio
_SCAN_WR BOOL %FX464 Initialize scan value
_CTASK_SCAN_WR BOOL %FX465 Periodic task – Initialize scan value
_FLASH_WR_CNT DWORD %FD16 Flash write count

A2-2
Appendix2 Flag and Parameter List

A2.2 Motion Flag


The flag displayed following are as follows. It displays the state and data of the Motion Control.
The flag related to axis is displayed as “_AXxx_...”(xx indicates the relevant axis No.)and the flag related to axis group is
displayed as “_AGxx_...”(xx indicates the axis group No.: 01 ~ 40).

Reserved Variable Data Type Address Description


_RUN_MODE BOOL %JX0.0 RUN mode on
_STOP_MODE BOOL %JX0.1 STOP mode on
_TEST_MODE BOOL %JX0.2 TEST mode on
_WARNING BOOL %JX0.3 Warning state
_ALARM BOOL %JX0.4 Alarm state
_LINKUP_INFO BOOL %JX0.5 Link up / down information
_COMM BOOL %JX0.6 Communication connecting state
_COMM_ERR BOOL %JX0.7 Communication timeout error
_COM_ERR BOOL %JX0.8 Common error exist
_ERR_CODE WORD %JW0.1 Axis error code
_AX_RDY ARRAY[0..32] OF %JX0.32 Axis ready
BOOL
_IO_RDY ARRAY[0..4] OF %JX0.64 IO ready
BOOL
_AX_NUM BYTE %JB0.10 Number of connected axes
_IO_NUM BYTE %JB0.11 Number of connected I/O
_AX_SDO_BUSY ARRAY[0..32] OF %JX0.96 Axis SDO processing busy
BOOL
_AX_SDO_ERR ARRAY[0..32] OF %JX0.128 Axis SDO processing error
BOOL
_IO_SDO_BUSY ARRAY[0..4] OF %JX0.160 I/O SDO processing busy
BOOL
_IO_SDO_ERR ARRAY[0..4] OF %JX0.176 I/O SDO processing error
BOOL
_PD0_ERR_CNT WORD %JW0.12 PDO error count
_AXxx_RDY BOOL %JXxx.0 Axis xx ready
_AXxx_WARNING BOOL %JXxx.1 Axis xx warning state
_AXxx_ALARM BOOL %JXxx.2 Axis xx alarm state
_AXxx_SV_ON BOOL %JXxx.3 Axis xx servo on/off state

A2-3
Appendix2 Flag and Parameter List

Reserved Variable Data Type Address Description


_AXxx_SV_RDY BOOL %JXxx.4 Axis xx servo ready state
_AXxx_AX_TYPE BOOL %JXxx.5 Axis xx main axis/sub. Axis state
_AXxx_MST_INFO BYTE %JBxx.1 Axis xx main axis information
_AXxx_SVON_INCMPL BOOL %JXxx.16 Axis xx servo on incomplete
_AXxx_COMM_WARN BOOL %JXxx.17 Axis xx communication warning
_AXxx_DEV_WARN BOOL %JXxx.18 Axis xx abnormal deviation warning
_AXxx_SV_ERR BOOL %JXxx.32 Axis xx servo drive error
_AXxx_HW_POT BOOL %JXxx.33 Axis xx positive limit detection
_AXxx_HW_NOT BOOL %JXxx.34 Axis xx negative limit detection
_AXxx_SW_POT BOOL %JXxx.35 Axis xx S/W positive limit detection
_AXxx_SW_NOT BOOL %JXxx.36 Axis xx S/W negative limit detection
_AXxx_SV_OFF BOOL %JXxx.37 Axis xx execution error of operation command in
servo-off state
_AXxx_POS_OVR BOOL %JXxx.38 Axis xx exceeds the set range of positioning
movement amout
_AXxx_VEL_OVR BOOL %JXxx.39 Axis xx exceed the maximum velocity
_AXxx_DEV_ERR BOOL %JXxx.40 Axis xx deviation error alarm
_AXxx_HOME_INCMPL BOOL %JXxx.41 Axis xx Execution of absolute position operation
command in the state of un
_AXxx_COMM_ERR BOOL %JXxx.42 Axis xx communication alarm
_AXxx_BUSY BOOL %JXxx.48 Axis xx motion command busy state
%JXxx.49 Axis xx state of motion commands
_AXxx_PAUSE BOOL
pause(velocity is zero)
_AXxx_STOP BOOL %JXxx.50 Axis xx stop state by the stop command
_AXxx_FAIL BOOL %JXxx.51 Axis xx command error exit status
_AXxx_CMPL BOOL %JXxx.52 Axis xx command execution complete
_AXxx_DIR BOOL %JXxx.53 Axis xx operation direction
_AXxx_JOG BOOL %JXxx.54 Axis xx JOG operation
_AXxx_HOME BOOL %JXxx.55 Axis xx Home return operating
_AXxx_P_CTRL BOOL %JXxx.56 Axis xx position control operation
_AXxx_V_CTRL BOOL %JXxx.57 Axis xx velocity control operation
_AXxx_T_CTRL BOOL %JXxx.58 Axis xx torque control operation
_AXxx_LINTP BOOL %JXxx.59 Axis xx linear interpolation operation
_AXxx_CINTP BOOL %JXxx.60 Axis xx circular interpolation operation
_AXxx_SYNC BOOL %JXxx.61 Axis xx synchronous start operation

A2-4
Appendix2 Flag and Parameter List

Reserved Variable Data Type Address Description


_AXxx_POS_CMPL BOOL %JXxx.64 Axis xx positioning complete
_AXxx_INPOS BOOL %JXxx.65 Axis xx inposition detection
_AXxx_LATCH_CMPL BOOL %JXxx.66 Axis xx latch operation complete
_AXxx_HOME_CMPL BOOL %JXxx.67 Axis xx home return completition
_AXxx_Disabled BOOL %JXxx.80 Axis xx Disabled state
_AXxx_Standstill BOOL %JXxx.81 Axis xx Standstill state
_AXxx_Discrete BOOL %JXxx.82 Axis xx Discrete state
_AXxx_Continuous BOOL %JXxx.83 Axis xx continuous state
_AXxx_Synchronized BOOL %JXxx.84 Axis xx Synchronized state
_AXxx_Homing BOOL %JXxx.85 Axis xx Homing state
_AXxx_Stopping BOOL %JXxx.86 Axis xx Stopping state
_AXxx_Errorstop BOOL %JXxx.87 Axis xx Errorstop state
_AXxx_TPOS LREAL %JLxx.2 Axis xx target position
_AXxx_CPOS LREAL %JLxx.3 Axis xx command position of current scan
_AXxx_CVEL LREAL %JLxx.4 Axis xx command velocity
_AXxx_ACCDEC LREAL %JLxx.5 Axis xx command acc./dec.
_AXxx_CJERK LREAL %JLxx.6 Axis xx command jerk
_AXxx_CTRQ LREAL %JLxx.7 Axis xx command torque
_AXxx_POS LREAL %JLxx.8 Axis xx current position
_AXxx_VEL LREAL %JLxx.9 Axis xx current velocity
_AXxx_TRQ LREAL %JLxx.10 Axis xx current torque
_AXxx_POS_DEV LREAL %JLxx.11 Axis xx position deviation
_AXxx_ALM BOOL %JXxx.768 Axis xx alarm state
_AXxx_SV_ON_STS BOOL %JXxx.770 Axis xx servo on status
_AXxx_POT BOOL %JXxx.771 Axis xx positive limit input
_AXxx_NOT BOOL %JXxx.772 Axis xx negative limit input
_AXxx_HOME_INPUT BOOL %JXxx.773 Axis xx home input
_AXxx_LATCH1 BOOL %JXxx.774 Axis xx LATCH1 input
_AXxx_LATCH2 BOOL %JXxx.775 Axis xx LATCH2 input
_AXxx_SVPARAM_BUSY BOOL %JXxx.776 Axis xx read/write operation of the servo
parameters
_AXxx_DRV_IN DWORD %JDxx.25 01 servo drive input
_AXxx_AX_ERR WORD %JWxx.52 Axis xx error code
_AXxx_DRV_ERR WORD %JWxx.53 01 servo drive error code
_AGxx_RDY BOOL %CXyy.0 Axis group xx ready to execute

A2-5
Appendix2 Flag and Parameter List

Reserved Variable Data Type Address Description


_AGxx_WARNING BOOL %CXyy.1 Axis group xx warning state
_AGxx_SV_ON BOOL %CXyy.3 Axis group xx servo on/off state
_AGxx_SV_RDY BOOL %CXyy.4 Axis group xx servo ready state
_AGxx_BUSY BOOL %CXyy.16 Axis group xx motion command busy state
_AGxx_PAUSE Axis group xx state of motion commands
BOOL %CXyy.17
pause(velocity is zero)
_AGxx_STOP BOOL %CXyy.18 Axis group xx stop state by the stop command
_AGxx_FAIL BOOL %CXyy.19 Axis group xx command error exit status
_AGxx_CMPL BOOL %CXyy.20 Axis group xx command execution complete
_AGxx_LINTP BOOL %CXyy.21 Axis group xx linear interpolation operation
_AGxx_CINTP BOOL %CXyy.22 Axis group xx circular interpolation operation
_AGxx_POS_CMPL BOOL %CXyy.32 Axis group xx positioning complete
_AGxx_Disabled BOOL %CXyy.48 Axis group xx Disabled state
_AGxx_Standby BOOL %CXyy.49 Axis group xx Standby state
_AGxx_Moving BOOL %CXyy.50 Axis group xx Moving state
_AGxx_Homing BOOL %CXyy.51 Axis group xx Homing state
_AGxx_Stopping BOOL %CXyy.52 Axis group xx Stopping state
_AGxx_ErrorStop BOOL %CXyy.53 Axis group xx ErrorStop state
_AGxx_CMD_VEL LREAL %CLyy.1 Axis group xx target velocity
_AGxx_CMD_ACCDEC LREAL %CLyy.2 Axis group xx command acc./dec.
_AGxx_ACT_VEL LREAL %CLyy.3 Axis group xx current velocity
_AGxx_AX_NUM WORD %CWyy.17 Axis group xx number of axes
_AGxx_AX1 BYTE %CByy.36 Axis group xx composition Axis for Axis1
_AGxx_AX2 BYTE %CByy.37 Axis group xx composition Axis for Axis2
_AGxx_AX3 BYTE %CByy.38 Axis group xx composition Axis for Axis3
_AGxx_AX4 BYTE %CByy.39 Axis group xx composition Axis for Axis4

A2-6
Appendix2 Flag and Parameter List

A2.3 I/O Flag


The input/output flag indicates the embedded digital input and output values with embedded encoder values. In addition, it
indicates the PDO Data that is connected to the Motion Control Module under fixed-time communication. The below
example displays the fixed-time communication data flag when it is connected to L7N Servo Drive.

Reserved Variable Data Type Address Description


_IN ARRAY[0..7] OF %IX0.0 Internal Digital input
BOOL
_ENC1 LREAL %IL0.1 Encoder1 input
_ENC2 LREAL %IL0.2 Encoder2 input
_OUT ARRAY[0..7] OF %QX0.0 Internal digital output
BOOL
_SLx_Controlword UINT %QWx.0 Controlword
_SLx_Target_Torque INT %QWx.1 Target torque
_SLx_Target_Position DINT %QDx.1 Target position
_SLx_Mode_of_Operation USINT %QBx.8 Operation mode
_SLx_Touch_Probe_Function UINT %QWx.5 Touch probe function
_SLx_Statusword UINT %IWx.0 Statusword
_SLx_Torque_Actual_Value INT %IWx.1 Actual torque value
_SLx_Position_Actual_Value DINT %IDx.1 Actual position value
_SLx_Following_Error_Actual_Value DINT %IDx.2 Positioning error’s actual
value
_SLx_Digital_Inputs UDINT %IDx.3 Digital input
_SLx_Mode_of_Operation_Display USINT %IBx.16 Operation mode display
_SLx_Command_Speed(rpm) INT %IWx.9 Commanded speed
_SLx_Current_Speed(rpm) INT %IWx.10 Operating speed
_SLx_Touch_Probe_Status UINT %IWx.11 Touch probe status
_SLx_Touch_Probe_1_Positive_Edge_Position_Value Touch probe 1 forward’s
DINT %IDx.6
position value

A2-7
Appendix2 Flag and Parameter List

A2-8
Warranty and Environmental Policy

Warranty

1. Warranty Period
The product you purchased will be guaranteed for 18 months from the date of manufacturing.

2. Scope of Warranty
Any trouble or defect occurring for the above-mentioned period will be partially replaced or repaired. However, please note the following
cases will be excluded from the scope of warranty.

(1) Any trouble attributable to unreasonable condition, environment or handling otherwise specified in the manual,
(2) Any trouble attributable to others’ products,
(3) If the product is modified or repaired in any other place not designated by the company,
(4) Due to unintended purposes
(5) Owing to the reasons unexpected at the level of the contemporary science and technology when delivered.
(6) Not attributable to the company; for instance, natural disasters or fire

3. Since the above warranty is limited to PLC unit only, make sure to use the product considering the safety for system configuration or
applications.

Environmental Policy

LS ELECTRIC Co., Ltd supports and observes the environmental policy as below.

Environmental Management About Disposal

LS ELECTRIC considers the environmental LS ELECTRIC’ PLC unit is designed to protect


preservation as the preferential management the environment. For the disposal, separate
subject and every staff of LS ELECTRIC use aluminum, iron and synthetic resin (cover) from
the reasonable endeavors for the pleasurably the product as they are reusable.
environmental preservation of the earth.

1
Warranty and Environment Policy

2
www.lselectric.co.kr

■ Headquarter ■ Overseas Subsidiaries


LS-ro 127(Hogye-dong) Dongan-gu, Anyang-si, Gyeonggi-Do, 14119, • LS ELECTRIC Japan Co., Ltd. (Tokyo, Japan)
Korea Tel: 81-3-6268-8241 E-Mail: jschuna@lselectric.biz
• LS ELECTRIC (Dalian) Co., Ltd. (Dalian, China)
■ Seoul Office Tel: 86-411-8730-6495 E-Mail: jiheo@lselectric.com.cn
LS Yongsan Tower, 92, Hangang-daero, Yongsan-gu, Seoul, 04386, • LS ELECTRIC (Wuxi) Co., Ltd. (Wuxi, China)
Korea Tel: 86-510-6851-6666 E-Mail: sblee@lselectric.co.kr
Tel: 82-2-2034-4033, 4888, 4703 Fax: 82-2-2034-4588 • LS ELECTRIC Shanghai Office (China)
E-mail: automation@lselectric.co.kr Tel: 86-21-5237-9977 E-Mail: tsjun@lselectric.com.cn
• LS ELECTRIC Vietnam Co., Ltd.

■ Factory Tel: 84-93-631-4099 E-Mail: jhchoi4@lselectric.biz (Hanoi)

56, Samseong 4-gil, Mokcheon-eup, Dongnam-gu, Cheonan-si, Tel: 84-28-3823-7890 E-Mail: sjbaik@lselectric.biz (Hochiminh)

Chungcheongnam-do, 31226, Korea • LS ELECTRIC Middle East FZE (Dubai, U.A.E.)


Tel: 971-4-886-5360 E-Mail: salesme@lselectric.biz
• LS ELECTRIC Europe B.V. (Hoofddorf, Netherlands)
Tel: 31-20-654-1424 E-Mail: europartner@lselectric.biz
• LS ELECTRIC America Inc. (Chicago, USA)
Tel: 1-800-891-2941 E-Mail: sales.us@lselectricamerica.com

©2013. LS ELECTRIC Co., Ltd. All Rights Reserved. 2020.07

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy