Coolmay PLC Instructions Programming Manual
Coolmay PLC Instructions Programming Manual
Programming Manual
V20.81
Precautions
(Please read before using)
Basic instructions
⚫ Thank you for choosing Coolmay series programmable controller.
⚫ This manual mainly introduces the basics, application instructions and other contents of Coolmay's entire
series of programmable controllers.
⚫ Introduction to software and programming, compatible with Mitsubishi GX Developer/ GX Works2, please refer
to the relevant manual.
⚫ Please deliver this manual to the end user.
User notice
⚫ Only operators with certain electrical knowledge can perform wiring and other operations on the product. If
there is any unclear use, please consult our technical department.
⚫ The examples listed in the manual and other technical materials are for user understanding and reference
only, and certain actions are not guaranteed.
⚫ When using this product in combination with other products, please confirm whether it meets the relevant
specifications, principles and technical requirements.
⚫ When using this product, please confirm whether it meets the requirements and safety by yourself. If the failure
of this product may cause machine failure or loss, please set up backup and safety functions by yourself.
Liability statement
⚫ Although the contents in the manual have been carefully checked, errors are inevitable, and we cannot
guarantee complete consistency.
⚫ We will always check the contents of the manual and make corrections in subsequent versions. We welcome
your suggestions.
⚫ The contents described in the manual are subject to change without notice.
Contact details
If you have any questions about the use of this product, please contact us.
⚫ Tel: 0755-86950416-842
⚫ Web: www.coolmay.com
⚫ Email: m3@coolmay.com
⚫ Mobile/Skype/Whatsapp: 86 13316892240
⚫ Address: 6th Floor, Building 1, Zhongxing Industrial City, Chuangye Road, Nanshan District, Shenzhen, PRC.
I
Foreword
Note: 1. 3G series products are compatible with Mitsubishi FX3G, FX3U (C), FX3S instructions. If you
need to use the FX3U (C) instruction, you need to change the PLC type to FX3U (C) and then copy it to the
FX3G program. Finally, you need to download the program in the FX3G type. For the instruction
comparison table, please refer to 2.3 Main Application Instructions.
2. 2N series PLC and MX2N series PLC are compatible with Mitsubishi FX2N commands, and support
positioning commands DRVI, DRVA, PLSV, etc. need to be compiled in FX1N and then copied to FX2N
program.
II
CONTENT
Precautions ..................................................................................................................................................................... I
Foreword ........................................................................................................................................................................ II
1 Introduction ............................................................................................................................................................. 1
1.1 Types of programming languages ............................................................................................................ 1
1.1.1 List programming .............................................................................................................................. 1
1.1.2 Circuit programming .......................................................................................................................... 1
1.1.3 SFC(STL<step ladder >)programming ............................................................................................. 3
1.2 Program interchangeability ...................................................................................................................... 4
2 Instruction List ......................................................................................................................................................... 5
2.1 Basic Instructions ..................................................................................................................................... 5
2.2 Step Ladder Instructions .......................................................................................................................... 6
2.3 Applied Instructions .................................................................................................................................. 7
3 Devices in Detail ................................................................................................................................................... 14
3.1 Device Number List ................................................................................................................................ 14
3.1.1 3G series PLC ................................................................................................................................. 14
3.1.2 2N series PLC ................................................................................................................................. 16
3.1.3 MX2N series PLC............................................................................................................................ 17
3.2 Special device number and content ....................................................................................................... 18
3.2.1 3G series PLC ................................................................................................................................. 18
3.2.2 2N series PLC refer to 3.3 .............................................................................................................. 22
3.2.3 MX2N series PLC............................................................................................................................ 22
3.3 Special register number and content ..................................................................................................... 23
3.3.1 3G series PLC ................................................................................................................................. 23
3.3.2 2N series PLC ................................................................................................................................. 27
3.3.3 MX2N series PLC............................................................................................................................ 29
3.4 Input and output relays [X, Y] ................................................................................................................. 31
3.4.1 I/O relay number ............................................................................................................................. 31
3.4.2 Function and effect.......................................................................................................................... 31
3.5 Auxiliary relay [M] ................................................................................................................................... 32
3.5.1 Auxiliary relay number .................................................................................................................... 33
3.5.2 Function of auxiliary relay ............................................................................................................... 33
3.6 Status [S] ................................................................................................................................................ 33
3.6.1 State number................................................................................................................................... 33
3.6.2 State function .................................................................................................................................. 34
3.7 Timer [T] ................................................................................................................................................. 34
3.7.1 Timer number .................................................................................................................................. 34
3.7.2 Timer functions and examples ........................................................................................................ 35
3.7.3 Setting method of setting value ...................................................................................................... 36
3.7.4 Notes in the subroutine ................................................................................................................... 36
3.8 Counter [C] ............................................................................................................................................. 36
3.8.1 Counter number .............................................................................................................................. 36
3.8.2 Counter functions and examples .................................................................................................... 37
3.9 High-speed counter [C] .......................................................................................................................... 38
3.9.1 Types and numbers of high-speed counters .................................................................................. 38
3.9.2 Use of high-speed counters ............................................................................................................ 42
3.10 Data register [D], extension register [R] ................................................................................................. 43
3.10.1 Number of data register and extension register ............................................................................. 43
3.10.2 Function of data register and extension register ............................................................................ 44
3.10.3 Index register [V], [Z] ....................................................................................................................... 45
3.11 Pointer [P], [I] .......................................................................................................................................... 46
3.11.1 Pointer number................................................................................................................................ 46
3.11.2 Pointer function ............................................................................................................................... 46
3.11.3 Function of interrupt pointer ............................................................................................................ 47
4 How to Specify Devices and Constants to Instructions ........................................................................................ 51
4.1 Data processed by PLC ......................................................................................................................... 51
4.1.1 Types of numeric values ................................................................................................................. 51
4.1.2 Value conversion ............................................................................................................................. 52
4.1.3 Numerical processing in floating-point arithmetic ........................................................................... 53
4.2 Bit Specification ...................................................................................................................................... 54
4.2.1 Specification of Digits for Bit Devices(Kn 口***) ........................................................................... 54
4.2.2 Bit Specification of a Word Device(D 口.b)................................................................................... 55
5 Basic Instruction.................................................................................................................................................... 56
I https://en.coolmay.com/
5.1 LD, LDI instructions ................................................................................................................................ 58
5.2 OUT instructions ..................................................................................................................................... 59
5.3 AND, ANI instructions ............................................................................................................................. 59
5.4 OR, ORI instructions .............................................................................................................................. 61
5.5 LDP, LDF, ANDP, ANDF, ORP, ORF instructions ................................................................................... 62
5.6 ORB Instructions .................................................................................................................................... 64
5.7 ANB Instructions..................................................................................................................................... 65
5.8 MPS, MRD, MPP Instructions ................................................................................................................ 65
5.9 MC, MCR Instructions ............................................................................................................................ 66
5.10 INV instructions ...................................................................................................................................... 68
5.11 MEP, MEF instructions ........................................................................................................................... 69
5.12 PLS, PLF instructions ............................................................................................................................. 69
5.13 SET, RST instructions ............................................................................................................................ 71
5.14 NOP instruction ...................................................................................................................................... 71
5.15 END instruction ...................................................................................................................................... 72
6 Program Flow ........................................................................................................................................................ 73
6.1 CJ/ Conditional jump .............................................................................................................................. 74
6.2 CALL/ Subroutine call............................................................................................................................. 76
6.3 SRET/ Subroutine return ........................................................................................................................ 77
6.4 IRET/ Interrupt Return ............................................................................................................................ 79
6.5 EI/ Enable Interrupt ................................................................................................................................ 79
6.6 DI/ Disable Interrupt ............................................................................................................................... 79
6.7 FEND/ Main Routine Program End ...................................................................................................... 80
6.8 WDT/Watchdog Timer Refresh .............................................................................................................. 82
6.9 FOR/Start a FOR/NEXT Loop ................................................................................................................ 83
6.10 NEXT/ End a FOR/NEXT Loop .............................................................................................................. 83
7 Move and Compare .............................................................................................................................................. 85
7.1 CMP/Compare ........................................................................................................................................ 86
7.2 ZCP/ Zone Compare .............................................................................................................................. 87
7.3 MOV/Move.............................................................................................................................................. 88
7.4 SMOV/Shift Move ................................................................................................................................... 90
7.5 CML/Complement .................................................................................................................................. 92
7.6 BMOV/Block Move ................................................................................................................................. 94
7.7 FMOV/Fill Move ...................................................................................................................................... 95
7.8 XCH/Exchange ....................................................................................................................................... 96
7.9 BCD/Conversion to Binary Coded Decimal ........................................................................................... 98
7.10 BIN/Conversion to Binary ....................................................................................................................... 99
8 Arithmetic and Logical Operation ....................................................................................................................... 101
8.1 ADD/BIN Addition ................................................................................................................................. 102
8.2 SUB/BIN Subtraction ............................................................................................................................ 103
8.3 MUL/BIN Multiplication ......................................................................................................................... 105
8.4 DIV/BIN Division ................................................................................................................................... 106
8.5 INC/BIN Increment ............................................................................................................................... 108
8.6 DEC/BIN Decrement ............................................................................................................................ 109
8.7 WAND/Logical Word AND .................................................................................................................... 110
8.8 WOR/Logical Word OR .........................................................................................................................111
8.9 WXOR/Logical Exclusive OR ............................................................................................................... 113
8.10 NEG/Negation ...................................................................................................................................... 114
9 Rotation and Shift Operation –FNC 30 to FNC 39 ............................................................................................. 117
9.1 ROR/Rotation Right.............................................................................................................................. 118
9.2 ROL/Rotation Left................................................................................................................................. 119
9.3 RCR/Rotation Right with Carry ............................................................................................................ 120
9.4 RCL/Rotation Left with Carry ............................................................................................................... 121
9.5 SFTR/Bit Shift Right ............................................................................................................................. 122
9.6 SFTL/Bit Shift Left ................................................................................................................................ 123
9.7 WSFR/Word Shift Right........................................................................................................................ 125
9.8 WSFL/Word Shift Left........................................................................................................................... 126
9.9 SFWR/Shift Write [FIFO/FILO Control] ................................................................................................ 128
9.10 SFRD/Shift Read [FIFO Control] .......................................................................................................... 129
10 Data Operation- FNC 40 to FNC 49 ............................................................................................................ 131
10.1 ZRST/Zone Reset ................................................................................................................................ 132
10.2 DECO/Decode ...................................................................................................................................... 134
10.3 ENCO/Encode ...................................................................................................................................... 136
10.4 SUM/Sum of Active Bits ....................................................................................................................... 138
10.5 BON/Check Specified Bit Status .......................................................................................................... 139
II https://en.coolmay.com/
10.6 MEAN/Mean ......................................................................................................................................... 140
10.7 ANS/Timed Annunciator Set................................................................................................................. 141
10.8 ANR/Annunciator Reset ....................................................................................................................... 143
10.9 SQR/BIN Square Root ......................................................................................................................... 144
10.10 FLT/BIN Conversion to Floating Point .................................................................................................. 145
11 High Speed Processing – FNC 50 to FNC 59 ............................................................................................. 146
11.1 REF/Refresh ......................................................................................................................................... 147
11.2 REFF/Refresh and Filter Adjust ........................................................................................................... 148
11.3 MTR/Input Matrix .................................................................................................................................. 149
11.4 HSCS/High Speed Counter Set ........................................................................................................... 150
11.5 HSCR/High Speed Counter Reset ....................................................................................................... 151
11.6 HSZ/High Speed Counter Zone Compare ........................................................................................... 152
11.7 SPD/Speed Detection .......................................................................................................................... 154
11.8 PLSY/Pulse Y Output ........................................................................................................................... 156
11.9 PWM/Pulse Width Modulation.............................................................................................................. 158
11.10 PLSR/Acceleration/Deceleration Setup ............................................................................................... 162
12 Handy Instruction – FNC 60 to FNC 69....................................................................................................... 164
12.1 IST/Initial State ..................................................................................................................................... 165
12.2 SER/Search a Data Stack .................................................................................................................... 168
12.3 ABSD/Absolute Drum Sequencer ........................................................................................................ 170
12.4 INCD/ Incremental Drum Sequencer ................................................................................................... 172
12.5 TTMR/ Teaching Timer ......................................................................................................................... 174
12.6 STMR/Special Timer ............................................................................................................................ 175
12.7 ALT/Alternate State .............................................................................................................................. 177
12.8 RAMP/Ramp Variable Value ................................................................................................................ 178
12.9 ROTC/Rotary Table Control ................................................................................................................. 180
12.10 SORT/ Tabulated Data ......................................................................................................................... 182
13 External I/O .................................................................................................................................................. 185
13.1 TKY/Ten Key Input ............................................................................................................................... 186
13.2 HKY/Hexadecimal Input ....................................................................................................................... 188
13.3 DSW/Digital Switch .............................................................................................................................. 191
13.4 SEGD/Seven Segment Decoder .......................................................................................................... 194
13.5 SEGL/Seven Segment With Latch ....................................................................................................... 195
13.6 ARWS/Arrow Switch ............................................................................................................................. 198
13.7 ASC/ASCII Code Data Input ................................................................................................................ 200
13.8 PR/Print (ASCII Code).......................................................................................................................... 202
13.9 FROM/Read From A Special Function Block ....................................................................................... 204
13.10 TO/Write To A Special Function Block .................................................................................................. 205
14 External Device SER (Option equipment) ................................................................................................... 207
14.1 RS/Serial Communication .................................................................................................................... 208
14.2 PRUN/Parallel Run (Octal Mode)......................................................................................................... 209
14.3 ASCI/Hexadecimal to ASCII Conversion ............................................................................................. 210
14.4 HEX/ASCII to Hexadecimal Conversion .............................................................................................. 213
14.5 CCD/Check Code ................................................................................................................................. 216
14.6 RS2/Serial Communication 2 ............................................................................................................... 218
14.7 PID/PID Control Loop ........................................................................................................................... 219
15 Data Transfer 2 ............................................................................................................................................ 223
15.1 ZPUSH/Batch Store of Index Register ................................................................................................. 224
15.2 ZPOP/Batch POP of Index Register .................................................................................................... 226
16 Floating Point ............................................................................................................................................... 227
16.1 ECMP/Floating Point Compare ............................................................................................................ 228
16.2 EZCP/Floating Point Zone Compare ................................................................................................... 229
16.3 EMOV/Floating Point Move .................................................................................................................. 231
16.4 ESTR/Floating Point to Character String Conversion .......................................................................... 232
16.5 EVAL/ Character String to Floating Point Conversion ......................................................................... 234
16.6 EBCD/Floating Point to Scientific Notation Conversion ....................................................................... 239
16.7 EBIN/ Scientific Notation to Floating Point Conversion ....................................................................... 240
16.8 EADD/Floating Point Addition .............................................................................................................. 242
16.9 ESUB/ Floating Point Subtraction ........................................................................................................ 243
16.10 EMUL/ Floating Point Multiplication ..................................................................................................... 244
16.11 EDIV/ Floating Point Division ............................................................................................................... 245
16.12 EXP/ Floating Point Exponent .............................................................................................................. 246
16.13 LOGE/ Floating Point Natural Logarithm ............................................................................................. 247
16.14 LOG10/Floating Point Common Logarithm .......................................................................................... 248
16.15 ESQR/2 Floating Point Square Root .................................................................................................... 250
III https://en.coolmay.com/
16.16 ENEG/2 Floating Point Negation.......................................................................................................... 251
16.17 INT/2 Hexadecimal Floating Point → BIN Integer Conversion ............................................................ 252
16.18 SIN/2Floating Point Sine ...................................................................................................................... 253
16.19 COS/ Binary Floating Point Cosine ...................................................................................................... 254
16.20 TAN/ Binary Floating Point Tangent ..................................................................................................... 256
16.21 ASIN/Binary Floating Point Arc Sine .................................................................................................... 257
16.22 ACOS/Binary Floating Point Arc Cosine .............................................................................................. 258
16.23 ATAN/Binary Floating Point Arc Tangent .............................................................................................. 260
16.24 RAD/Binary Floating Point Degrees to Radians Conversion ............................................................... 262
16.25 DEG/Binary Floating Point Radians to Degrees Conversion............................................................... 263
17 Data Processing 2 ....................................................................................................................................... 264
17.1 WSUM/ Sum of Word Data .................................................................................................................. 265
17.2 WTOB/ WORD to BYTE ....................................................................................................................... 266
17.3 BTOW/ BYTE to WORD ....................................................................................................................... 268
17.4 UNI/ 4-bit Linking of Word Data ........................................................................................................... 270
17.5 DIS/ 4-bit Grouping of Word Data ........................................................................................................ 271
17.6 SWAP/ Byte Swap ................................................................................................................................ 273
17.7 SORT2/ Sort Tabulated Data 2 ............................................................................................................ 274
18 Positioning Control....................................................................................................................................... 277
18.1 DSZR/ Dog Search Zero Return .......................................................................................................... 278
18.1.1 Related devices............................................................................................................................. 278
18.1.2 Function and operation ................................................................................................................. 280
18.1.3 Zero return operation .................................................................................................................... 281
18.1.4 DOG search function .................................................................................................................... 282
18.2 DVIT/ Interrupt Positioning ................................................................................................................... 284
18.2.1 Function and operation ................................................................................................................. 285
18.2.2 Interruption positioning operation ................................................................................................. 286
18.3 TBL/ Batch Data Positioning Mode ...................................................................................................... 288
18.4 ABS/ Absolute Current Value Read...................................................................................................... 289
18.4.1 Related device .............................................................................................................................. 289
18.5 ZRN/ Zero Return ................................................................................................................................. 292
18.5.1 Related devices............................................................................................................................. 292
18.5.2 Function and Operation ................................................................................................................ 294
18.5.3 Zero return operation .................................................................................................................... 294
18.5.4 Cautions ........................................................................................................................................ 295
18.6 PLSV/ Variable Speed Pulse Output .................................................................................................... 297
18.6.1 Function and operation ................................................................................................................. 297
18.6.2 Important points ............................................................................................................................ 299
18.7 DRVI/ Drive to Increment ..................................................................................................................... 301
18.7.1 Function and Operation ................................................................................................................ 301
18.7.2 Important Points ............................................................................................................................ 302
18.8 DRVA/ Drive to Absolute ...................................................................................................................... 303
18.8.1 Function and Operation ................................................................................................................ 303
18.8.2 Important Points ............................................................................................................................ 304
19 Real Time Clock Operation.......................................................................................................................... 305
19.1 TCMP/ RTC Data Compare ................................................................................................................. 306
19.2 TZCP/ RTC Data Zone Compare ......................................................................................................... 308
19.3 TADD/ RTC Data Addition .................................................................................................................... 309
19.4 TSUB/ RTC Data Subtraction .............................................................................................................. 311
19.5 HTOS/ Hour to Second Conversion ..................................................................................................... 312
19.6 STOH/ Second to Hour Conversion ..................................................................................................... 314
19.7 TRD/ Read RTC data ........................................................................................................................... 315
19.8 TWR/ Set RTC data ............................................................................................................................. 316
19.9 HOUR/ Hour Meter ............................................................................................................................... 318
20 External Devices .......................................................................................................................................... 320
20.1 GRY/ Decimal to Gray Code Conversion............................................................................................. 321
20.2 GBIN/ Gray Code to Decimal Conversion............................................................................................ 322
21 Other Instructions ........................................................................................................................................ 324
21.1 COMRD/ Read Device Comment Data................................................................................................ 325
21.2 RND/ Random Number Generation ..................................................................................................... 326
21.3 DUTY/ Timing Pulse Generation .......................................................................................................... 328
21.4 CRC/CRC Cyclic Redundancy Check ................................................................................................. 330
21.5 HCMOV/High Speed Counter Move .................................................................................................... 333
22 Block Data Operation – FNC190 to FNC199 .............................................................................................. 337
22.1 BK+/ Block Data Addition ..................................................................................................................... 338
IV https://en.coolmay.com/
22.2 BK-/Block Data Subtraction.................................................................................................................. 340
22.3 BKCMP=,>,<,<>,<=,>=/Block Data Compare ...................................................................................... 342
23 Character String Control – FNC200 to FNC209.......................................................................................... 346
23.1 STR/BIN to Character String Conversion ............................................................................................ 347
23.2 VAL/Character String to BIN Conversion ............................................................................................. 349
23.3 $+/Link Character Strings..................................................................................................................... 352
23.4 LEN/Character String Length Detection............................................................................................... 354
23.5 RIGHT/Extracting Character String Data from the Right ..................................................................... 356
23.6 LEFT/Extracting Character String Data from the Left .......................................................................... 358
23.7 MIDR/Random Selection of Character Strings .................................................................................... 360
23.8 MIDW/Random Replacement of Character Strings ............................................................................. 362
23.9 INSTR/Character string search ............................................................................................................ 364
23.10 $MOV/Character String Transfer.......................................................................................................... 366
24 Data Operation 3 – FNC210 to FNC219 ..................................................................................................... 368
24.1 FDEL/Deleting Data from Tables.......................................................................................................... 369
24.2 FINS/Inserting Data to Tables .............................................................................................................. 371
24.3 POP/Shift Last Data Read [FILO Control]............................................................................................ 373
24.4 SFR/Bit Shift Right with Carry .............................................................................................................. 375
24.5 SFL/Bit Shift Left with Carry ................................................................................................................. 376
25 Data Comparison – FNC220 to FNC249 .................................................................................................... 378
25.1 LD=, >, <, <>, <=, >=/Data Comparison .............................................................................................. 379
25.2 AND=,>,<,<>,<=,>=/Data Comparison ................................................................................................ 382
25.3 OR=,>,<,<>,<=,>=/Data Comparison ................................................................................................... 385
26 Data table operation .................................................................................................................................... 388
26.1 LIMIT/Limit Control ............................................................................................................................... 389
26.2 BAND/Dead Band Control .................................................................................................................... 391
26.3 ZONE/Zone Control.............................................................................................................................. 394
26.4 SCL/Scaling (Coordinate by Point Data).............................................................................................. 397
26.5 DABIN/Decimal ASCII to BIN Conversion............................................................................................ 400
26.6 BINDA/BIN to Decimal ASCII Conversion............................................................................................ 402
26.7 SCL2/Scaling 2 (Coordinate by X/Y Data) ........................................................................................... 404
27 High Speed Processing 2 ............................................................................................................................ 407
27.1 HSCT/High Speed Counter Compare With Data Table ....................................................................... 408
V https://en.coolmay.com/
Introduction
Introduction
Programmable logic controller (PLC), a digital operation controller with a microprocessor for automatic control,
can load control instructions into memory for storage and execution at any time. The programmable controller is
composed of CPU, instruction and data memory, input / output interface, power supply, digital to analog conversion
and other functional units. Early programmable logic controllers only had the function of logic control, so they were
named programmable logic controllers. Later, with continuous development, these computer modules with simple
functions had already included logic control, timing control, analog control, The names of various functions such as
multi-machine communication are also changed to Programmable Controller, but because of its conflict with the
abbreviation of PC and personal computer, and because of habits, people still use The term logic controller is
programmed, and the acronym PLC is still used.
With the development of electronic technology and the needs of industrial applications, the functions of PLCs are
becoming more and more powerful, such as position control and network functions. The input / output signals also
include DI (Digital Input), AI (Analog Input), PI (Pulse Input) and NI (Numerical Input), DO (Digital Output), AO (Analog
Output), PO (Pulse Output) and NO (Numerical Output), so PLC will still play a decisive role in future industrial control.
1.1.1.1 Features
In this method, sequence instructions are input in the form of instruction words such as "LD", "AND" and "OUT".
This input method is the basis of sequence programs.
1 https://en.coolmay.com/
Introduction
Ladder diagram is an automatic control language developed during World War II. It is the oldest and most widely
used automatic control language. Initially, there were only A (normally open) contacts, B (normally closed) contacts,
and output coils. , Timers, counters and other basic mechanisms and devices, until the appearance of the
programmable controller PLC, the devices that can be represented in the ladder diagram, in addition to the above,
also add devices such as differential contacts, holding coils and traditional distribution boards can not achieve
Application instructions, such as numerical operations such as addition, subtraction, multiplication and division.
No matter the traditional ladder diagram or PLC ladder diagram, the working principle is the same, but the
traditional ladder diagram is represented by a symbol that is closer to the entity in the symbolic representation, while
the PLC uses a simpler and easier to represent on the computer or report. Ladder diagram logic can be divided into
two kinds of combinational logic and sequential logic, which are described as follows:
The traditional ladder diagram (left) and the PLC ladder diagram (right) represent examples of combinational
logic.
Line 1: Use a normally open switch X0 (NO: Normally Open), also known as the "A" switch or contact. Its
characteristic is that in normal (not pressed), its contacts are open (OFF), so Y0 is not conductive, but
when the switch is activated (pressed the button), its contacts become conductive (ON), Therefore, Y0 is
turned on.
Line 2: Use a normally closed switch X1 (NC: Normally Close), also known as the "B" switch or contact. Its
characteristic is that at normal times, its contact is conductive, so Y1 is conductive, and the When the
switch is activated, its contact becomes an open circuit instead, so Y1 does not conduct.
Line 3: For the application of combined logic output of more than one input device, its output Y2 will only be
turned on when X2 is not in action or X3 is in action and X4 is in action.
Sequential logic is a loop with a feedback structure, that is, the loop output result is pulled back as the input
condition. In this way, under the same input condition, different output results will be obtained due to the difference in
the previous state or action sequence.
The traditional ladder diagram (left) and PLC ladder diagram (right) respectively represent examples of sequential
2 https://en.coolmay.com/
Introduction
logic.
When the circuit is just connected to the power supply, although the X6 switch is ON, the X5 switch is OFF, so
Y3 does not operate. After the start switch X5 is pressed, Y3 acts. Once Y3 acts, even if the start switch is released
(X5 becomes OFF), Y3 can continue to maintain the action (this is the self-holding circuit) because of its own contact
feedback. The actions can be expressed in the following table:
Status
X5 ON/OFF X6 ON/OFF Y3 ON/OFF
Sequence
1 No action No action OFF
2 Action No action ON
3 No action No action ON
4 No action Action OFF
5 No action No action OFF
It can be seen from the above table that under different sequences, although the input states are completely
consistent, the output results may also be different. For example, the action sequences 1 and 3 in the table, the X5
and X6 switches are not activated, and under the condition of state 1, Y3 is OFF, but Y3 is ON in state 3. This Y3
output state is pulled back as an input (so-called feedback) to give the loop a sequential control effect is the main
characteristic of the ladder circuit.
The program editing method is from the left bus to the right bus. The editing of one line is followed by the next
line. The number of contacts in a line can be up to 11, if it is not enough, continuous lines will be generated to continue
the connection, and then continue to connect more For devices, consecutive numbers are automatically generated,
and the same input point can be used repeatedly. As shown below:
Consecutive number
The operation of the ladder program is scanning from the upper left to the lower right. The coil and application
instruction operation box belong to the output processing, and are placed at the far right in the ladder diagram.
Sequence control using the SFC (sequential function chart) is available in PLCs.
In SFC programs, the role of each process and the overall control flow can be expressed easily based on machine
operations, so sequence design is easy. Accordingly, machine operations can be easily transmitted to any person,
3 https://en.coolmay.com/
Introduction
and created programs are efficient in maintenance, specifications changes and actions against problems.
1.1.3.1 Features
In SFC programs, each process performed by the machine is expressed by a state relay.
The instruction list program and ladder program that can be converted to each other can be converted into SFC
charts if they are prepared according to certain rules.
Note: When Coolmay PLC uses SFC programming, it is not allowed to use positioning instructions or other
pulsed instructions in SFC.
The sequence programs created by the above three methods are saved in the program memory of the
programmable controller through instructions (the contents of the instruction table programming).
• Programs created using the various input methods shown below can be converted and displayed and edited.
Instruction
list
Ladder SFC
diagra
m
Note: Our PLC programming is mainly based on ladder diagram programming. (Does not support
structured engineering, does not support the use of tags)
4 https://en.coolmay.com/
Intruction List
Instruction List
Program
Mnemonic Name Function Applicable devices
step
Contact Instruction
Initial logical operation
LD Load contact type NO X,Y,M,S,T,C,D 口.b 1
(normally open)
Initial logical operation
LDI Load Inverse contact type NC X,Y,M,S,T,C,D 口.b 1
(normally closed)
Initial logical operation of
LDP Load Pulse X,Y,M,S,T,C,D 口.b 2
Rising edge pulse
Load Falling Initial logical operation of
LDF X,Y,M,S,T,C,D 口.b 2
Pulse Falling/trailing edge pulse
Serial connection of NO
AND AND X,Y,M,S,T,C,D 口.b 1
(normally open) contacts
Serial connection of NC
ANI AND Inverse X,Y,M,S,T,C,D 口.b 1
(normally closed) contacts
Serial connection of Rising
ANDP AND Pulse X,Y,M,S,T,C,D 口.b 2
edge pulse
AND Falling Serial connection of
ANDF X,Y,M,S,T,C,D 口.b 2
Pulse Falling/trailing edge pulse
Parallel connection of NO
OR OR X,Y,M,S,T,C,D 口.b 1
(normally open) contacts
Parallel connection of NC
ORI OR Inverse X,Y,M,S,T,C,D 口.b 1
(normally closed) contacts
Parallel connection of NC
ORP OR Inverse X,Y,M,S,T,C,D 口.b 2
(normally closed) contacts
OR Falling Parallel connection of
ORF X,Y,M,S,T,C,D 口.b 2
Pulse Falling/trailing edge pulse
Connection Instruction
Serial connection of
ANB AND Block — 1
multiple parallel circuits
Parallel connection of
ORB OR Block — 1
multiple contact circuits
Stores the current result of
Memory Point
MPS the internal PLC — 1
Store
operations
5 https://en.coolmay.com/
Intruction List
Program
Mnemonic Name Function Applicable devices
step
STL Step Ladder Starts step ladder S 1
RET Return Completes step ladder — 1
6 https://en.coolmay.com/
Intruction List
Applicable PLC
FNC 3G series PLC 2N
Mnemonic Function
NO. series MX2N series PLC
FX3G FX3U(C)
PLC
00 CJ Conditional Jump ★ ★ ★ ★
04 EI Enable Interrupt ★ ★ ★
05 DI Disable Interrupt ★ ★ ★
10 CMP Compare ★ ★ ★ ★
12 MOV Move ★ ★ ★ ★
14 CML Complement ★ ★ ★ ★
17 XCH Exchange ★ ★ ★
Conversion to Binary Coded
18 BCD ★ ★ ★ ★
Decimal
19 BIN Conversion to Binary ★ ★ ★ ★
20 ADD Addition ★ ★ ★ ★
21 SUB Subtraction ★ ★ ★ ★
22 MUL Multiplication ★ ★ ★ ★
23 DIV Division ★ ★ ★ ★
24 INC Increment ★ ★ ★ ★
25 DEC Decrement ★ ★ ★ ★
29 NEG Negation ★ ★ ★
7 https://en.coolmay.com/
Intruction List
41 DECO Decode ★ ★ ★ ★
42 ENCO Encode ★ ★ ★ ★
45 MEAN Mean ★ ★ ★ ★
50 REF Refresh ★ ★ ★ ★
8 https://en.coolmay.com/
Intruction List
9 https://en.coolmay.com/
Intruction List
Scientific Notation to
119 EBIN Floating ★ ★ ★
Point Conversion
120 EADD Floating Point Addition ★ ★ ★ ★
10 https://en.coolmay.com/
Intruction List
11 https://en.coolmay.com/
Intruction List
12 https://en.coolmay.com/
Intruction List
13 https://en.coolmay.com/
Devices in Detail
Devices in Detail
Counter
General type up counter
C0~C15 16 points Counts 0 to 32,767
(16 bits)
EEPROM retention up counter 184
C16~C199 Counts 0 to 32,767
(16 bits) points
General type
−2,147,483,648 to
bi-directional counter C200~C219 20 points
+2,147,483,647 counts
(32 bits)
EEPROM retention bi-directional −2,147,483,648 to
C220~C234 15 points
counter +2,147,483,647 counts
14 https://en.coolmay.com/
Devices in Detail
(32 bits)
Pointer
Nesting
Constant
16 points -32,768~+32,767
Decimal (K)
32 points -2,147,483,648~+2,147,483,647
15 https://en.coolmay.com/
Devices in Detail
32 points 00000000~FFFFFFFF
-1.0×2128~-1.0×2-126,0,1.0×2-126~1.0×2128
Real number (E) 32 points Both the decimal point expression and the exponent
expression are available.
Item Substance
Operation control method Cyclic scanning through stored programs
Input and output control Batch processing (when executing END instruction), input and output refresh,
method pulse capture
Logic ladder diagram and instruction list (compatible with Mitsubishi software
Programming language
FXGP_WIN-C)
Basic 0.08µs
Operation instructions
time Application
10-30µs
instruction
Built-in 8000 step EEPROM
RAM
Storage box
Basic sequence 27
instruction
Step ladder 2
Instruction
instructions
Application 94
instruction
general 500 points M0 - M499
Auxiliary
lock 1036 points M500-M1535
relay
special 256 points M8000 -M8255
general 500 points S0 to S499
status initial 10 points S000-S009
lock 500 points S500 - S999
100 millisecond 200 points T0-T199
10 millisecond 46 points T200-T245
1 millisecond 4 points T246-T249
Timer
integration
100 millisecond 6 points T250- T255
integration
General 16 bits 100 points C0-C99
Lock 16 bits 100 points C100-C199
counter
General 32-bit
Lock 32 bits 35 points C200-C234
16 https://en.coolmay.com/
Devices in Detail
S0~S9 10 points
Status relay S S10~S999 990 points (For keeping)
(For keeping state)
T0~T199 200 T200~T245 46 T246~T249 4 points T250~T255 6 points
Timer T
points 100ms points 10ms 1ms accumulation 100ms accumulation
16-bit up counter 32-bit up-down counter
C235~C255 20
C0~C15 16 C16~C199 184 C200~C219 20 C220~C234
Counter C points
points points points 15 points (For
(Keep high
(general) (For keeping) (general) keeping)
speed)
17 https://en.coolmay.com/
Devices in Detail
number)
H (hexadecimal
16bit 0~FFFF 32bit 0~FFFFFFFF
number)
18 https://en.coolmay.com/
Devices in Detail
19 https://en.coolmay.com/
Devices in Detail
20 https://en.coolmay.com/
Devices in Detail
21 https://en.coolmay.com/
Devices in Detail
22 https://en.coolmay.com/
Devices in Detail
mark
M8051 I1 口口 interrupt disable M8198 4 octave sign for C251 C252 C254
Numbe Numbe
content Remarks content Remarks
r r
Fifth to eighth pulse
D8000 Watchdog timer D8148 acceleration and deceleration
time
Low
D8001 PLC type and system version D8160
position
2...2K steps;
4...4K steps;
8...8K steps; Eighth position pulse
High
D8002 PLC memory capacity At 16K steps or more, D8161
position
D8002=8,
corresponding to 16,
32, 64 in D8102.
10H: programmable
D8003 Types of memory controller built-in D8169 Restricted access status
memory
D8010 Scan current value D8182 Z1 Register contents
D8011 Minimum scan time D8183 V1 Register contents
D8012 Maximum scan time D8184 Z2 Register contents
D8013 second D8185 V2 Register contents
D8014 Minute D8186 Z3 Register contents
D8015 Time D8187 V3 Register contents
D8016 day D8188 Z4 Register contents
D8017 month D8189 V4 Register contents
D8018 year D8190 Z5 Register contents
23 https://en.coolmay.com/
Devices in Detail
24 https://en.coolmay.com/
Devices in Detail
High
D8058 DA is the current time setting Reference 5.2 D8357
position
D8059 Constant scan time D8358 Second pulse acceleration time
D8074 Low position D8359 Second pulse deceleration time
X0 rising edge ring counter
Low
D8075 value [1/6µs unit] High position D8360
position
Third position pulse
High
D8076 Low position D8361
X0 falling edge ring counter position
value [1/6µs unit] Y2 deviation speed
D8077 High position D8362
Initial value: 0
Low
D8078 Low position D8363
X0 pulse width/pulse period Maximum speed of the third position
[10µs unit] pulse High
D8079 High position D8364
position
Y2 crawl speed
D8080 X1 rising edge ring counter Low position D8365
Initial value: 1000
value
Low
D8081 [1/6µs unit] High position D8366
Y2 origin return speed position
Initial value: 50000 High
D8082 X1 falling edge ring counter Low position D8367
position
value
The third pulse acceleration
D8083 [1/6µs unit] High position D8368
time
The third pulse deceleration
D8084 Low position D8369
X1 pulse width/pulse period time
[10µs unit] Low
D8085 High position D8370
position
Fourth position pulse
High
D8086 X3 rising edge ring counter Low position D8371
position
value
Y3 deviation speed
D8087 [1/6µs unit] High position D8372
Initial value: 0
Low
D8088 X3 falling edge ring counter Low position D8373
The fourth pulse maximum position
value
speed High
D8089 [1/6µs unit] High position D8374
position
Y3 crawl speed
D8090 Low position D8375
X3 pulse width/pulse period Initial value: 1000
[10µs unit] Low
D8091 High position D8376
Y3 origin return speed position
X4 rising edge ring counter Initial value: 50000 High
D8092 Low position D8377
value position
D8093 [1/6µs unit] High position D8378 The fourth pulse acceleration
25 https://en.coolmay.com/
Devices in Detail
time
The fourth pulse deceleration
D8094 X4 falling edge ring counter Low position D8379
time
value [1/6µs unit]
D8095 High position D8395 Network setting function logo
ADPRW command serial port
D8096 X4 pulse width/pulse period Low position D8397
location
[10µs unit]
D8097 High position D8398 0~2147483647(1ms)
D8101 PLC type and system version D8399 Incremental ring count
Modbus RTU protocol
D8102 PLC memory capacity 16...16K steps D8400
Communication parameters
Number of special modules
D8108 D8401 Communication mode
connected
Y number where output refresh
D8109 D8406 Number of intervals
error occurred
Communication parameters of
D8120 D8409 overtime time
Modbus RTU protocol
RS2 header 1, 2 <initial value:
D8121 Master station number D8410
STX>
RS command sending data
D8122 D8411 RS2 header 3, 4
remaining points
RS command receiving point RS2 trailer 1, 2 <initial value:
D8123 D8412
monitoring ETX>
RS command header <initial
D8124 D8413 RS2 trailer 3, 4
value: STX>
RS command trailer <initial
D8125 D8414 Master station number
value: ETX>
The value of serial port 2 when The version before RS2 receives the sum
D8126 D8415
using ADPRW instruction is 0 26232 calculation result
26232 and
D8126 Serial port 2 interval period D8416 RS2 send summation
Later version
Specify the start number of the
lower computer communication
D8127 D8420 Communication parameters
request
26 https://en.coolmay.com/
Devices in Detail
27 https://en.coolmay.com/
Devices in Detail
28 https://en.coolmay.com/
Devices in Detail
29 https://en.coolmay.com/
Devices in Detail
30 https://en.coolmay.com/
Devices in Detail
(1-1ms)
The numbers of the input relay and output relay are fixed numbers held by the basic unit, and are counted from X0
and Y0. Since these numbers use octal numbers, there is no value of "8" or "9".
The numbers of input relay (X) and output relay (Y) are shown in the table below. (Numbers are assigned in octal
numbers)
I/O relay
40
Input relay X000~X047
points The device number is an octal number
40 Total input and output is 80 points
Output relay Y000~Y047
points
The input contact X is connected to the input device, and the input signal is read to enter the PLC. There is no limit
to the number of times that the normally open contact or normally closed contact of each input contact X can be used
in the program. The ON/OFF of the input contact X will only change with the ON/OFF of the input device. You cannot
use a program to force the ON/OFF of the input contact X.
The task of output contact Y is to send an ON/OFF signal to drive the load connected to output contact Y. There are
two types of output contacts, one is Relay and the other is Transistor. There is no limit to the number of times the
normally open contact or normally closed contact of each output contact Y can be used in the program, but the output
coil Y The number is recommended to be used only once in the program, otherwise according to the principle of PLC
program scanning, the decision of its output state will fall in the last output Y circuit in the program.
31 https://en.coolmay.com/
Devices in Detail
◆ Input processing:
1. The PLC reads the ON/OFF status of the external input signal into the input image area once before executing
the program.
2. If the input signal changes ON/OFF during program execution, the state in the input image area will not change
until the next ON/OFF state of the input signal is read again at the beginning of the next scan.
3. There is a delay of about 10ms when the external signal ON→OFF or OFF→ON changes to when the contact
in the program is recognized as ON/OFF (but may be affected by the program scan cycle).
◆ Program processing:
The PLC reads the ON/OFF status of each input signal in the input image area and starts to execute each
instruction in the program in sequence from address 0. The processing result, that is, the ON/OFF of each output
coil, is also sequentially stored in each device image area Inside.
◆ Output processing:
1. When the END instruction is executed, the ON/OFF status of Y in the device image area is sent to the output
image area latch, and this image area is actually the coil of the output relay.
2. There is a delay of about 10ms when the relay coil ON→OFF or OFF→ON changes to the contact ON/OFF.
3. Using a transistor module, there is a delay of about 10~20us when ON→OFF or OFF→ON changes to the
contact ON/OFF.
There are multiple auxiliary relays in the PLC. The coils of these auxiliary relays are the same as the output relays,
and are driven by the contacts of various soft elements in the PLC. Auxiliary relays have countless electronic normally
open contacts and normally closed contacts, which can be freely used in PLC. However, the external load cannot be
directly driven through this contact, and the external load must be driven through the output relay Y.
32 https://en.coolmay.com/
Devices in Detail
1. 3G series PLC
Auxiliary relay
General use M0~M383, M1536~M7679 6528 points, fixed as a non-blackout holding area
EEPROM retention M384~M1535 1152 points, fixed as the blackout holding area
Special use M8000~M8511 512 points
2. 2N series PLC
general 500 points M0 to M499
Auxiliary
lock 1036 points M500-M1535
relay
special 256 points M8000 to M8255
3. MX2N series PLC
M0~M499 500 points M500~M1535 1036 points M8000~M8255 255 points
Auxiliary relay M
(general use) (for holding) (special use)
1. Auxiliary relays Auxiliary relays for general use are turned off when the PLC is in operation,
for general use: and all of their statuses are reset to OFF. When power is supplied, except
for the input condition of ON, the status is all OFF.
2. Auxiliary relay for power The auxiliary relay for power failure maintenance will be kept in its state
failure maintenance: when the power is turned off during PLC operation, and the state will be the
state before power failure when the power is re-transmitted.
3. Special auxiliary relays: Each special auxiliary relay has its specific function. Do not use undefined
special auxiliary relays.
State S is an important soft element for easy programming in engineering automation control. It needs to be used
in combination with step ladder diagram (or Sequential Function Chart, Sequential FunctiON Chart, SFC) instructions
STL and RET.
status
For initial state (EEPROM hold) S0~S9 10 o'clock, fixed as the blackout holding area
33 https://en.coolmay.com/
Devices in Detail
The state is the same as the auxiliary relay. There are countless normally open contacts and normally closed
contacts, which can be used at will in the sequence program. Moreover, when not used for step ladder instructions,
the state (S) is also the same as the auxiliary relay (M) and can be used in general sequence control.
1. Initial state: S0~S9, the step point used as the initial state in the sequential function chart (SFC).
2. For power When the power is disconnected during the PLC operation, its state will be
retentive: maintained, and when the power is re-transmitted, the state will be the state before
the power failure;
And when it is run again, it can be restarted from the middle of the process.
When the power-off holding state is used as a general-purpose state, you can add
ZRST in front of the program to reset its state in batches.
3. For signal S900~S999, signal alarm status, can be used as output for diagnosing external
alarm:
faults. (For details, see 10.7 ANS/Signal Alarm Set)
4. General use: When the PLC power supply is disconnected, the general status will be cleared.
The timer is a device that calculates the clock pulses of 1ms, 10ms, 100ms, etc. in the PLC by addition, and
when the result of the addition calculation reaches the specified setting value, the output contact operates. As the
setting value, the constant (K) in the program memory and the indirect designation by the contents of the data register
(D) can be used.
34 https://en.coolmay.com/
Devices in Detail
◆ When X0=ON, the current value of timer T200 is counted by 10ms*k100, when the current value of timer=set
value K100, the output coil T200=ON.
◆ When X0=OFF or power failure, the timer T200 will be cleared. And the output coil T200 becomes OFF.
◆ When X1=ON, the current value of timer T250 is counted as 100ms*k100, when the current value of timer=set
value K100, output coil T250=O
◆ When X1=OFF or power failure, the timer T250 pauses counting, and the current value remains unchanged;
when the PLC runs again, that is, when X1=ON, the T250 continues to time, the accumulated time is 10s; the
current value=set value K100, the output coil T250=ON
35 https://en.coolmay.com/
Devices in Detail
1. Specify constant (K): The setting value directly specifies the constant K value.
◆ The contents of the indirectly designated data register are either written in the program in advance, or input
through digital switches.
1. In the subroutine and interrupt subroutine, please use the timer of T192~T199. This timer counts when the coil
instruction is executed or when the END instruction is executed.
If the set value is reached, the contact action will be output when the coil instruction or END instruction is executed.
Since the general timer only counts when the coil instruction is executed, only under certain conditions, the
subroutine and interrupt subroutine of the coil instruction are executed. If the timer is used to count, it cannot be
executed and cannot operate normally.
2. In the subroutine and interrupt subroutine, if a 1ms accumulation timer is used, when it reaches the set value, the
output contact will act at the coil command that was initially executed. Please pay attention.
The counter counts while performing a cyclic operation on the actions of the internal signals X, Y, M, S, C and other
contacts of the programmable controller.
36 https://en.coolmay.com/
Devices in Detail
Generally, a counter is used. If the PLC power supply is disconnected, the count value will be cleared. However,
the power failure retention counter will remember the count value and the state of the contact before the power failure,
so it can continue to count on the previous value. .
The setting value of the counter can be set directly using the constant K or indirectly using the value in the register
D.
The setting value of the 16-bit binary up counter is valid in the range of K1 to K32767 (decimal constant). The
operation of K0 is the same as that of K1, and the output contact operates at the first count.
◆ By counting input X011, the current value of the counter will increase every time the C0 coil is driven. When the
coil command is executed for the 10th time, the output contact C0 will act; after that, even if the counting input
X011 acts, the current value of the counter will not Variety.
3.8.2.2 32-bit up/down counter for general use/maintained after power failure
The set value of the 32-bit binary up/down counter is valid in the range of -2,147,483,648 to +2,147,483,647
(decimal constant). You can use the auxiliary relays M8200 to M8234 to specify the direction of up/down counting.
The increase and decrease of the current value has nothing to do with the operation of the output contact. The
current value of the counter starts from 2,147,483,647 to increase the number, and then becomes -2,147,483,648.
Similarly, the current value of the counter starts to decrease from -2,147,483,648 and becomes 2,147,483,647. (This
37 https://en.coolmay.com/
Devices in Detail
In the PLC, a high-speed counter (single-phase single-count, single-phase double-count and double-phase
double-count) with a 32-bit up-down counter built-in is divided into a hardware counter and a software counter
according to different counting methods.
1) 3G series PLC
High-speed counter (numbers are assigned in decimal numbers)
Single-phase single-count
-2,147,483,648~+2,147,483,647 counter
input
C235~C245
Bidirectional (32 bit) (EEPROM Software counter
38 https://en.coolmay.com/
Devices in Detail
C251/C252
Two-phase double-count input 4-times frequency: max 2 channels, max
Bidirectional (32 bit) (EEPROM C251~C255 frequency 24KHz
hold) M8199 is the 4 times frequency mark of
C253/C255
2) 2N series PLC
Max 6 points:C235-X0 C236-X1 C237-X7 C238-X3 C239-X4 C240-X5;
Single phase
High-speed Regular 2 points:C235-X0 C238-X3
1) 3G series PLC
39 https://en.coolmay.com/
Devices in Detail
U: Up counting input | D: Down counting input | A: Phase A input | B: Phase B input | R: External reset input |
S: External start input
Single phase: max 6 channels, max 60 KHz each
Two-phase: 1-time frequency: up to 2-3 channels, maximum frequency 60KHz. M8198 is the 4 times frequency
mark of C251/C252.
4-times frequency: max 2 channels, max frequency 24KHz. M8199 is the 4 times frequency mark
of C253/C255.
2) 2N series PLC
ABZ phase counting
Single-phase counting input AB phase counting input
input
C238 C251 C253 C252 C253
C235 C236 C239
10KHz C240 C237 10KHz 10KHz C254 10KHz 10KHz C254
10KHz/ 100KH 100KH
/100K 10KHz 10KHz /100K /100K 10KHz /100K /100K 10KHz
100KHz z z
Hz Hz Hz Hz Hz
X00
U/D A A
0
X00
U/D B B
1
X00
Z
2
X00
U/D A A
3
X00
U/D B B
4
X00
U/D R Z
5
X00
U/D
7
X01
A A
0
X01
B B
1
X01
Z
2
Conventional [U]: Up-counting input | [D]: Down-counting input | [A]: A-phase count input |
[B]: B-phase count input | [R]: Reset input
⚫ The maximum frequency of single-phase counting is 10KHz, which can be customized up to 6 channels of single-
phase 10KHz-100KHz and 3 channels of AB(Z) phase 10KHz-100KHz.
⚫ Single-phase counting 10KHz is usually X00/X03, corresponding to C235/238. Can be customized up to 6 single-
phase counting, the counter corresponds to the X point relationship: C235-X0; C236-X1; C237-X7; C238-X3;
C239-X4; C240-X5; C237 should be connected to X2 for high-speed counting, now Instead, connect to X7 for
high-speed counting; among them, X0/X1/X3/X4 can be customized to 100KHz, X5/X7 can be customized to
10KHz.
40 https://en.coolmay.com/
Devices in Detail
⚫ When using 6-way single-phase counting, it does not conflict with other counters and pulse outputs, but conflicts
with the ZRN origin return instruction. The ZRN origin return instruction cannot be used; only when X3 is not used
for counting, the Y7/X7 ZRN origin return instruction can be used.
⚫ The AB phase count is 2 times the frequency, the conventional is 10KHz two-way X00-X01/X03-X04,
corresponding to C251/C253. It can also be customized to 3-channel AB phase counting, add one channel X10-
X11, corresponding to C254; X00-X01/X03-X04 can be customized to 100KHz, X10-X11 can be customized to
10KHz.
41 https://en.coolmay.com/
Devices in Detail
Inputs X000~X007 cannot be used repeatedly by high-speed counters. When the input terminal is not used
as a high-speed counter, it can be used for general input.
⚫ Input X000~X007 can not be used repeatedly. For example, once C251 is used, X000 and X001 are occupied,
so C235, C236, C241, C244, C246, C247, C249, C252, C254 and interrupt input pointers *I00, *I01 and the
corresponding input SPD instructions cannot be used.
1) C251 C252 C254 (AB phase) maximum response frequency: 60KHz;
2) C253 C255 (AB phase) maximum response frequency: 60KHz;
3) C235 C241 C244 C238 (single-phase) maximum response frequency: 60KHz;
4) The highest response frequency of other high-speed counters: 10KHz;
5) The AB phase high-speed counter can be set to 2 times the frequency and 4 times the frequency (the setting
is only valid during the OUT drive cycle):
**When M8196-ON, C251 C252 C254 count pulse 2 times frequency;
**When M8197-ON, C253 C255 count pulse 2 times frequency;
**When M8198-ON, C251 C252 C254 count pulse 4 times frequency;
**When M8199-ON, C253 C255 count pulse 4 times frequency.
3.9.1.4 Attentions
Input X000~X007 can be used for high-speed counter, input interruption, pulse capture, SPD, ZRN, DSZR DVIT
instruction and general input. Therefore, do not reuse input terminals.
For example: X000 and X001 are occupied when using C251, so [C235, C236, C241, C244, C246, C247, C249,
C252, C254], [input interrupt pointer I000, I101], [pulse capture contact M8170 , M8171] and [Use the corresponding
input SPD, ZRN, DSZR, DVIT instructions] can not be used.
42 https://en.coolmay.com/
Devices in Detail
It is a 32-bit up/down binary counter. The action of the output contact corresponding to the current value is the same
as the high-speed counter of single-phase single-count input.
The count-down/count-up actions of C246~C250 can be monitored by the ON/OFF actions of M8246~M8250. ON:
count down; OFF: count up
◆ When X012 is ON, C251 counts the operation of input X000 (phase A) and X001 (phase B) by interrupt.
◆ X011 is ON, execute RST instruction, at this time C251 will be reset.
◆ If the current value exceeds the set value, Y002 will be ON, and it will be OFF when it changes within the set
value.
◆ Y003 turns ON (minus) and OFF (increasing) according to the counting direction.
The data register is used to store numeric data. Its data length is 16 bits (-32,768~+32,767), and the highest bit
is a sign. It can store numeric data of -32,768~+32,767, or it can combine two 16-bit registers into A 32-bit register
(D+1, the lower D number is the lower bit) is used, and the highest bit is a positive and negative sign, which can store
the numerical data of -2,147,483,648~+2,147,483,647.
43 https://en.coolmay.com/
Devices in Detail
D8196~D825 V0~V7
D0~D199 D200~D7999 D8000~D8195
Register 5 Z0~Z7
200 points 780 points (for 196 points (special
D.V.Z 59 points (for 16 points (for
(general use) keeping) use, hold)
special use) indexing)
The register can be divided into the following five types according to its nature:
1. General register: When PLC is from RUN→STOP or power off, all data in the register will be cleared
to 0. If M8033=ON, then the data will remain uncleared when PLC is from
RUN→STOP, but it will still be Clear to 0.
2. Power failure The PLC keeps its contents during RUN→STOP and power failure; to clear the
retention register: contents of the power failure retention register, you can use the RST or ZRST
instruction.
3. Special register: Each special purpose register has its special definition and purpose, mainly used
for storing system status, error information, and monitoring status. Please refer to
section 3.2 Special register numbers and contents.
4. Index register: The index register is a 16-bit register, which is used in the same way as the data
register. You can also use other device numbers and values in combination with
the operand of the application instruction to change the special register of the
device number and value in the program.
5. Extension register: Same as the data register, it is 16-bit data (the highest bit is a positive and negative
44 https://en.coolmay.com/
Devices in Detail
sign), but after combining two devices, you can save 32-bit (the highest bit is a
positive and negative sign) numeric data.
3.10.3.1 16 bits
The index register has the same structure as the data register
← 16bits ← 16bits
→ →
V Z
V0~V7: 8
Z0~Z7: 8 points
points
3.10.3.2 32 bits
Z0~Z7 must be used when modifying the device in the 32-bit application instruction or processing the value
beyond the 16-bit range.
← 32 bit →
Vx(High) Zx(Low)
As shown in the above figure, the combination of V and Z must specify Z when using 32-bit length. At this time,
V is occupied and cannot be used in other places, otherwise it will cause Z (32-bit data) to be inaccurate.
◆ When X0=O, Z0=8, V0=14, D5Z0=D(5+8)=D13, D10V0=D(10+14)=D24, at this time the content of D13 will
be moved to D24
45 https://en.coolmay.com/
Devices in Detail
◆ Hexadecimal value: H
For example, V5=K30, when the constant H30V5 is specified, it is regarded as H4E (30H+K30). In addition, when
V5=H30 and the constant H30V5 is specified, it is regarded as H60 (30H+30H).
pointer
46 https://en.coolmay.com/
Devices in Detail
◆ X0=ON, jump to the mark position specified by CJ instruction, and execute the following program;
◆ X0=OFF, the program is executed from top to bottom as a normal program, and the CJ instruction is not
executed at this time.
◆ X001=ON, execute the subroutine at the label position specified by the CALL instruction, and use the (SRET)
instruction to return to the original position.
The interrupt pointers include the following three types, which are used together with the application instruction
IRET (FNC 03) interrupt return, EI (FNC 04) enable interrupt, and DI (FNC 05) disable interrupt.
47 https://en.coolmay.com/
Devices in Detail
EI
FEN
D
The rising edge of X0 is detected
Interrupt pointer
I001
Interrupt subroutine①
IRE
T
The rising edge of X1 is
Interrupt pointer detected
中断指针
I101
Interrupt subroutine②
IRE
T
EN
D
◆ The EI instruction in the PLC allows interruption. During the scan program, X000 or X001=ON, execute the
interrupt subroutine ① or ②, and then return to the main program through the IRET instruction.
◆ The interrupt pointer (I***) must be placed after the FEND instruction as a mark during programming.
Notes:
1) The number of the input relay used as an interrupt pointer should not be repeated with application instructions
such as "high-speed counter", "pulse capture function", "pulse density" and other applications that use the same input
range.
2) After the input interrupt pointer I port 0 port is specified, the input filter of the input relay will be automatically
changed to high-speed reading.
Therefore, there is no need to use the REFF (FNC 51) command and the special data register D8020 (input
filter adjustment) to change the filter adjustment.
In addition, the input filter without an input relay used as an input interrupt pointer operates at 10ms (initial
value).
3) The rising edge interrupt and falling edge interrupt of the same input like I001 and I000 cannot be programmed
at the same time.
Every designated interrupt cycle time (10ms~99ms), execute interrupt subroutine. Outside the operation cycle
of the programmable controller, the timer interrupt becomes valid after the EI instruction.
Input number Interrupt cycle Disable interrupt flag
48 https://en.coolmay.com/
Devices in Detail
I8 口口 10ms M8058
According to the comparison result of the high-speed counter comparison set instruction (DHSCS instruction),
the interrupt subroutine is executed. It is used to control the priority processing of counting results using high-speed
counters.
Disable interrupt Disable interrupt
Pointer number Pointer number
flag flag
I010 I040
I020 M8059 I050 M8059
I030 I060
49 https://en.coolmay.com/
Devices in Detail
50 https://en.coolmay.com/
How to Specify Devices and Constants to Instructions
Bit: Bit is the most basic unit of binary value, and its state is either 1 or 0.
It is composed of two consecutive nibbles (that is, 8 bits, b7~b0), which can
Byte:
represent 00~FF in hexadecimal.
It is composed of two consecutive bytes (that is, 16 bits, b15 ~ b0), which can
Word:
represent the hexadecimal 4-digit value 0000 ~ FFFF.
It is composed of two consecutive words (that is, 32 bits, b31 ~ b0), which can
Double Word:
represent the 8-bit value 00000000 ~ FFFFFFFF in hexadecimal.
The relationship between bits, nibbles, bytes, words, and double words in the binary system is shown in the
following figure:
51 https://en.coolmay.com/
How to Specify Devices and Constants to Instructions
The data processed in the PLC can be converted according to the following table.
Decimal Octal number Hexadecimal
Binary number (BIN) BCD
number (DEC) (OCT) number (HEX)
0 0 00 0000 0000 0000 0000
1 1 01 0000 0001 0000 0001
2 2 02 0000 0010 0000 0010
3 3 03 0000 0011 0000 0011
4 4 04 0000 0100 0000 0100
5 5 05 0000 0101 0000 0101
6 6 06 0000 0110 0000 0110
7 7 07 0000 0111 0000 0111
8 10 08 0000 1000 0000 1000
9 11 09 0000 1001 0000 1001
10 12 0A 0000 1010 0001 0000
52 https://en.coolmay.com/
How to Specify Devices and Constants to Instructions
In the division operation of an integer, an answer such as 23÷2=11 with a remainder of 1 will be obtained; in the
same way, the decimal point should not be discarded in the square root operation of an integer. In the PLC, in order
to perform these operations with higher accuracy, floating-point operations can be performed.
◆ Binary floating point number (real number)
1. When handling binary floating-point numbers (real numbers) in data registers, use a pair of data registers with
consecutive numbers. For example, (D11,D10), as shown in the figure below:
← D10(b15~b0)
← D11(b15~b0) →
→
2- 2- 2- 2-
27 26 25 21 20 2-1 2-2 2-3
20 21 22 23
b31 b30 b29 b28 ...... b24 b23 b22 b21 b20 ...... b3 b2 b1 b0
53 https://en.coolmay.com/
How to Specify Devices and Constants to Instructions
54 https://en.coolmay.com/
How to Specify Devices and Constants to Instructions
Specify the bit of a word device, you can use it as bit data, a word device has 16 bits; when specifying the bit of
a word device, please use the word device number and bit number (hexadecimal number) to set .
Such as: MOV K4M0 D0 (transmit the state of the 16 bits of M0-M15 to b0-b15 of D0)
55 https://en.coolmay.com/
Basic Instruction
Basic Instruction
Program
Mnemonic Name Function Applicable devices
step
Contact Instruction
Initial logical operation contact type NO
LD Load X,Y,M,S,T,C,D 口.b 1
(normally open)
Initial logical operation contact type NC
LDI Load Inverse X,Y,M,S,T,C,D 口.b 1
(normally closed)
Initial logical operation of
LDP Load Pulse X,Y,M,S,T,C,D 口.b 2
rising edge pulse
Initial logical operation of
LDF Load Falling Pulse X,Y,M,S,T,C,D 口.b 2
falling/trailing edge pulse
Serial connection of NO
AND AND X,Y,M,S,T,C,D 口.b 1
(normally open) contacts
Serial connection of NC
ANI AND Inverse X,Y,M,S,T,C,D 口.b 1
(normally closed) contacts
ANDP AND Pulse Serial connection of rising edge pulse X,Y,M,S,T,C,D 口.b 2
56 https://en.coolmay.com/
Basic Instruction
PLC operations
Conversion of operation result
MEP M.E.P
to leading edge pulse
Conversion of operation result
MEF M.E.F
to trailing edge pulse
Out Instruction
OUT OUT Final logical operation type coil drive Y,M,S,T,C,D 口.b Note 1
Y,M,S,T,C,D,V,Z,D Note 2
RST Reset Reset bit device OFF
口.b
57 https://en.coolmay.com/
Basic Instruction
LD and LDI instructions are the contacts connected to the bus. After being combined with the ANB instruction
described later, it can also be used at the start of a branch.
Mnemonic Function Applicable models
LD(Load) The logic operation of the normally open contact (A) starts Coolmay series PLC
Operand X, Y, M, S, T, C, D 口.b
The LD instruction is used for the A contact at the beginning of the left bus or the A contact at
Instructions the beginning of a contact circuit block. Its function is to save the current content and at the
same time store the fetched contact status into the accumulator.
Program
example
LD X0 Input A contact of X0
AND X1 Series A contact of X1
OUT Y1 Drive Y1 coil
LDI(Load
The logic operation of the normally closed contact (B) starts Coolmay series PLC
Inverse)
Operand X, Y, M, S, T, C, D 口.b
The LD instruction is used for the B contact at the beginning of the left bus or the A contact at
Instructions the beginning of a contact circuit block. Its function is to save the current content and at the
same time store the fetched contact status into the accumulator.
Program
example
58 https://en.coolmay.com/
Basic Instruction
OUT instruction drives coils of output relays (Y), auxiliary relays (M), state relays (S), timers (T) and counters
(C).
Mnemonic Function Applicable models
Operand X, Y, M, S, T, C, D 口.b
Instructions Output the result of the logic operation before the OUT instruction to the specified device.
Program
example
The AND and ANI instructions are executed to connect 1 contact in series. There is no limit to the number of
serial contacts, this command can be used multiple times in succession.
Mnemonic Function Applicable models
Operand X, Y, M, S, T, C, D 口.b
Instructions The AND instruction is used for the series connection of A contacts.
Program
example
Operand X, Y, M, S, T, C, D 口.b
59 https://en.coolmay.com/
Basic Instruction
Program
example
60 https://en.coolmay.com/
Basic Instruction
OR and ORI instructions can be used as instructions for connecting 1 contact in parallel. When two or more
contacts are connected in series, to connect such a series circuit block with other circuits in parallel, use the ORB
instruction described later. OR and ORI start from the step of this instruction and are connected in parallel with the
steps of the previous LD and LDI instructions. The number of parallel connections is not limited.
Mnemonic Function Applicable models
Operand X, Y, M, S, T, C, D 口.b
Operand X, Y, M, S, T, C, D 口.b
Program
example
61 https://en.coolmay.com/
Basic Instruction
LDP, ANDP, ORP instructions are contact instructions that detect the rising edge. Only when the rising edge of
the specified bit device (changes from OFF to ON) is turned on, one operation cycle is turned on.
LDF, ANDF, ORF instructions are contact instructions that detect the falling edge. Only when the falling edge of
the specified bit device (changes from ON to OFF), one operation cycle is turned on.
Operand X, Y, M, S, T, C, D 口.b
The usage of LDP instruction is the same as LD, but the action is different. Its function
Instructions is to save the current content, and at the same time save the fetched contact rising
edge detection state into the accumulator.
Program
example
Operand X, Y, M, S, T, C, D 口.b
The usage of the LDF instruction is the same as LD, but the action is different. Its
Instructions function is to save the current content, and at the same time store the fetched contact
rising edge detection state into the accumulator.
Program
example
62 https://en.coolmay.com/
Basic Instruction
ANDP
Rising edge detection series connection Coolmay series PLC
(AND Pulse)
Operand X, Y, M, S, T, C, D 口.b
The ANDP instruction is used for series connection with the detection of the rising
Instructions
edge of the contact.
Program
example
Operand X, Y, M, S, T, C, D 口.b
The ANDF instruction is used for series connection where the falling edge of the
Instructions
contact is detected.
Program
example
Operand X, Y, M, S, T, C, D 口.b
Instructions ORP instruction is used for parallel connection with detection of rising edge of contact
Program
example
63 https://en.coolmay.com/
Basic Instruction
Operand X, Y, M, S, T, C, D 口.b
Instructions ORF instruction is used for parallel connection with detection of rising edge of contact
Program
example
A circuit in which two or more contacts are connected in series is called serial circuit block.
Mnemonic Function Applicable models
ORB
Parallel connection of circuit blocks Coolmay series PLC
(OR Block)
Operand Null
ORB is the "OR" operation between the previously saved logic result and the current
Instructions
accumulator content.
Explanat
Ladder diagram: Mnemonic: ion:
64 https://en.coolmay.com/
Basic Instruction
When the branch circuit (parallel circuit block) is connected in series with the previous circuit, use the ANB
instruction. The starting point of the branch uses the LD and LDI instructions. After the parallel circuit block ends, you
can use the ANB instruction to connect to the previous circuit in series. When there are multiple parallel circuits, use
the ANB instruction for each circuit block to connect.
Mnemonic Function Applicable models
ANB
Series connection of circuit blocks Coolmay series PLC
(AND Block)
Operand Null
ANB is the AND operation between the previously saved logic result and the current
Instructions
accumulator content.
Program
example
Instructions Store the contents of the current accumulator on the stack. (The stack pointer plus one).
MPD (Memory Read) Read the stack (pointer does not move) Coolmay series PLC
Operand Null
Read the stack content and store it in the accumulator. (The stack pointer does not
Instructions
move)
65 https://en.coolmay.com/
Basic Instruction
Operand Null
Retrieve the previously saved logical operation result from the stack and store it in the
Instructions
accumulator. (The stack pointer minus one)
Program
example
After executing the MC instruction, the bus (LD, LDI point) moves to behind the MC contact; using the MCR
instruction, it can be returned to the original bus position.
By changing the device numbers Y and M, the MC instruction can be used multiple times. However, when the same
device number is used, it is the same as the OUT instruction, and double coil output will appear.
Mnemonic Function Applicable models
MC/MCR
(Master Control /
Connection/disconnection of common series
Coolmay series PLC
Master Control contacts
Reset)
General timer / timer for The timing value returns to zero, the coil is de-
subroutine energized, and the contact does not operate
Accumulative timer/counter The coil is de-energized, and the count value
66 https://en.coolmay.com/
Basic Instruction
Program
example
67 https://en.coolmay.com/
Basic Instruction
The NV instruction is an instruction that reverses the calculation result before the INV instruction is executed,
and there is no need to specify the device number.
Mnemonic Function Applicable models
Operand Null
Invert the result of the logic operation before the INV instruction and store it in the
Instructions
accumulator.
Program
example
68 https://en.coolmay.com/
Basic Instruction
The MEP and MEF instructions are instructions that pulse the result of the operation, and there is no need to
specify the device number.
Mnemonic Function Applicable models
Operand Null
The result of the operation up to the MEP instruction changes from OFF to ON to turn
Instructions
on.
Program
example
Operand Null
The result of the operation up to the MEF instruction is turned on when it changes
Instructions
from ON to OFF.
Program
example
After using the PLS instruction, the target device operates only in one operation cycle after the drive input is
turned on.
After the PLF instruction is used, the target device operates only in one operation cycle after the drive input is
turned off.
Mnemonic Function Applicable models
69 https://en.coolmay.com/
Basic Instruction
When X0=OFF→ON (rising edge trigger), PLS instruction is executed, S sends out a
Instructions
pulse, and the pulse width is one scan period.
Ladder diagram: Mnemonic: Description:
Program
example
X0 LD X0 Load the A contact of X0
PLS M0 5
PLS M0 M0 rising edge detection
M0 LD M0 Load the A contact of M0
SET Y0 Y0 action hold (ON)
SET Y0
Timing diagram:
Timing diagram:
70 https://en.coolmay.com/
Basic Instruction
When the SET instruction is driven, the specified element is set to ON, and the set
Instructions element will remain ON, regardless of whether the SET instruction is still driven. The
RST instruction can be used to turn this component OFF.
Ladder diagram: Mnemonic: Description:
Program
example
X0 LD X0 Load the A contact of X0
SET Y1 5
SET Y1 Y1 action hold
When the RST instruction is driven, the actions of the specified components are as
follows:
Components S, Y, M: coils and contacts are all set to OFF;
Instructions
Component T, C: The current timing or count value is cleared, and the coil and contact
status are set to OFF;
Component D, Z, V: The content value is cleared to 0.
Ladder diagram: Mnemonic: Description:
Program
example
X0 LD X0 Load the A contact of X0
RST Y1 5
RST Y1 Y1 contact clear
Operand Null
Instructions The NOP instruction does not perform any operation in the program, so the original
71 https://en.coolmay.com/
Basic Instruction
logic operation result will be maintained after execution. The component machine is
as follows: If you want to delete a certain instruction but do not want to change the
program length, you can replace it with the NOP instruction.
Ladder diagram: Mnemonic: Description:
Program
example
X0 LD X0 Load the A contact of X0
RST Y1 5
NOP No action
RST Y1 Y1 contact clear
72 https://en.coolmay.com/
Program Flow
Program Flow
Support models
FNC
Mnemonic Function 3G series 2N series MX2N
NO.
PLC PLC series PLC
00 CJ Conditional Jump ★ ★ ★
04 EI Enable Interrupt ★ ★
05 DI Disable Interrupt ★ ★
73 https://en.coolmay.com/
Program Flow
It is an instruction that does not execute the sequence program starting from the CJ and CJP instructions to the
pointer (P). It is possible to shorten the cycle time (calculation cycle) and execute the program using double coils.
Operand
Instruction Function
type
16-bit Operation 32-bit
Mnemonic Mnemonic Operation Condition
Instruction Condition Instruction
Continuous
3 steps CJ ——
FNC 00 Operation
Pn.
CJ Pulse
CJP (Single) ——
P
Operation
Pointer P supports index modification; FX2N: n=0~127, FX3G: n=0~1280; but P63 is an END
Operand Pn.
jump.
◆ When the command input is ON, the program with the designated mark (pointer number) is
Instruction executed.
s
◆ The program pointed to by the pointer P can be before the CJ instruction, but when the scan
time exceeds 200ms (default setting), a watchdog timer (WDT) error will occur. Please be
careful.
◆ The CJ instruction can specify the same pointer P repeatedly, but CJ and CALL cannot specify
the same pointer P, otherwise an error will occur.
◆ here is no need to input the mark of pointer P63, otherwise the PLC will prompt an error and
stop running.
Sample
program (1)
◆ When X0=ON, the program automatically jumps from address 0 to address N (namely the
designated pointer P1) to continue execution, and the intermediate address skips and
does not execute.
◆ When X0=OFF, the program continues to execute from address 0 as a normal program,
and the CJ instruction is not executed at this time.
The relationship between the main control instruction and the jump instruction and the action
74 https://en.coolmay.com/
Program Flow
Sample
program (2)
Sample
program (3)
75 https://en.coolmay.com/
Program Flow
In a sequence program, an instruction to call a program that you want to process together. You can reduce the
number of steps in the program and design the program more effectively.
In addition, when writing subroutines, you also need to use FEND (FNC 06) and SRET (FNC 02) instructions.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
3 steps CALL ——
FNC 01 Operation
Pn.
CALL Pulse
CALLP (Single) ——
P
Operation
Instruction ◆ The subroutine specified by the pointer must be written after the FEND instruction;
s ◆ When the number of pointer P is used by CALL instruction, CJ designation cannot
specify the same number;
◆ When only using CALL instruction, the subroutine with the same pointer number can be
called unlimited times;
◆ The CALL instruction in the subroutine can be used up to 4 times, and overall, up to 5
levels of nesting are allowed.
76 https://en.coolmay.com/
Program Flow
Instuctions
◆ After executing the CALL instruction in the main program, jump to the subroutine, and then use the SRET
instruction to return to the main program.
Sample
program (1)
◆ When X0=ON, execute the CALL instruction and jump to the subroutine designated by P2. When the SRET
instruction is executed, it will return to address 24 and continue to execute.
77 https://en.coolmay.com/
Program Flow
Sample
program (2)
◆ When X10 is triggered by the rising edge of OFF → ON, the CALL P10 instruction is
executed, and the subroutine is executed at P10.
◆ When X10 is triggered by the rising edge of OFF → ON, the CALL P10 instruction is
executed, and the subroutine is executed at P10.
◆ When X11=ON, CALL P11 will be executed, and it will shift to P11 to execute the
designated subroutine.
◆ When X12 = ON, CALL P12 will be executed, and it will shift to P12 to execute the
designated subroutine.
◆ When X13=ON, CALL P13 is executed and transfer to P13 to execute the designated
subroutine.
◆ When X14=ON, CALL P14 will be executed, and it will be transferred to P14 to execute
the designated subroutine. When the SRET instruction is executed, it will return to the
previous Pn subroutine and continue to execute.
◆ After executing the SRET instruction in the P10 subroutine, return to the main program.
78 https://en.coolmay.com/
Program Flow
The programmable controller is usually in a state where interrupts are prohibited. Using this instruction, the
programmable controller can be changed to a state that allows interrupts, such as input interrupts, timer interrupts,
and counter interrupts.
Operand
Instruction Function
type
Independent Operation
Mnemonic
FNC 04 Inst. Condition
Null
EI Continuous No independent instructions to drive the
1step EI
Operation contacts are required.
After changing to enable interrupt, use EI (FNC 04) instruction to change to disable interrupt again. Note that the
interrupt (required) generated after the DI instruction can only be processed after the EI (FNC 04) instruction is
executed.
Operand
Instruction Function
type
Independent Operation
Mnemonic
FNC 05 Inst. Condition
Null
DI Continuous No independent instructions to drive the
1step DI
Operation contacts are required.
Instruction Interrupt subroutines are allowed between the EI instruction and the DI instruction in the
program. If there is no interruption in the forbidden section in the program, the DI
instruction may not be used.
79 https://en.coolmay.com/
Program Flow
Sample EI
program X0
Y1 Interrupt insertion allowable range
DI
Interrupt insertion prohibited range
EI
◆ When the PLC is executing, when the program scans between the EI instruction and the DI instruction, X1=ON
or X2=ON, the interrupt insertion subroutine A or B will be executed, and when the subroutine is executed to
IRET, it will return to the main program and continue Execute down.
Operand
Instruction Function
type
Independent Operation
Mnemonic
FNC 06 Inst. Condition
Null
FEND Continuous This instruction is the independent type,
1step FEND
Operation and does not require drive contact.
Instruction ◆ After the FEND instruction is executed, the same output processing, input processing, and
s
watchdog timer refresh as the END instruction will be executed, and then the program will
return to step 0. This instruction is needed when writing subroutines and interrupt programs.
◆ The CALL instruction program must be written after the FEND instruction, and the SRET
instruction must be added at the end of the subroutine; the interrupt program must also be
written after the FEND, and the IRET instruction must be added at the end of the program.
◆ When FEND instruction is written multiple times: Please design the subroutine and
interrupt program between the last FEND and END instructions.
◆ After the CALL instruction is executed: Before executing the SRET instruction, if the
FEND instruction is executed, a program error will occur.
◆ After the FOR instruction is executed: Before executing the NEXT instruction, if the FEND
instruction is executed, a program error will occur.
80 https://en.coolmay.com/
Program Flow
81 https://en.coolmay.com/
Program Flow
Operand
Instruction Function
type
Independent Inst. Mnemonic Operation Condition
FNC 07
Null WDT Continuous Operation
WDT P 1 step
WDTP Pulse (Single) Operation
◆ If the operation cycle of the PLC (0~END or FEND instruction execution time) exceeds
Instructions 200ms, the PLC will have a watchdog timer error (operation abnormality detected), then CPU
error, the PLC will stop after the ERROR light is on. In the case of a long operation cycle like
this, inserting the WDT instruction in the middle of the program can avoid such errors.
◆ D8000, watchdog timer time, the maximum can be set to 32767ms (initial value: 200)
As shown in the figure, if the scan cycle of the program is 300ms, at this time, the program
can be divided into 2 parts, and the WDT instruction can be placed in the middle. Make the
first half and the second half of the program are less than 200ms.
You can also modify the watchdog timer time directly through D8000, such as MOV K300
D8000. When no WDT instruction is programmed, the value of D 8000 becomes valid during
END processing.
Sample
program 300ms
program
82 https://en.coolmay.com/
Program Flow
The program from the FOR instruction to the NEXT (FNC 09) instruction is repeated for the specified number of
times.
Operand
Instruction Function
type
16-bit 32-bit Operation
Mnemonic Operation condition Mnemonic
Instruction Instruction condition
FNC 08
S. 3 steps FOR Continuous operation ——
FOR
——
Operand
Instruction Function
type
Independent Operation
Mnemonic
FNC 09 Inst. Condition
Null
NEXT Continuous This instruction is the independent type,
1 step NEXT
Operation and does not require drive contact.
The processing of FOR to NEXT instructions is repeated n times (the number of times
Instructions specified in the source data). After repeating the specified number of times, execute the
step processing after the NEXT instruction.
Sample After the A program is executed 3 times, the program after the NEXT instruction continues
program (1) to execute. And program A will execute every time program B is executed four times, that is,
program B is executed 3*4=12 times.
83 https://en.coolmay.com/
Program Flow
Sample When X7 = OFF, PLC will execute the program between FOR ~ NEXT;
program (2) When X7=ON, the execution of CJ instruction jumps to P6, the program between
FOR ~ NEXT is skipped and not executed.
84 https://en.coolmay.com/
Move and Compare
Support models
FNC
Mnemonic Function 3G series 2N series MX2N series
NO.
PLC PLC PLC
10 CMP Compare ★ ★ ★
12 MOV Move ★ ★ ★
14 CML Complement ★ ★ ★
17 XCH Exchange ★ ★ ★
Conversion to Binary
18 BCD ★ ★ ★
Coded Decimal
19 BIN Conversion to Binary ★ ★ ★
85 https://en.coolmay.com/
Move and Compare
7.1 CMP/Compare
This instruction compares two values, and outputs the result (smaller, equal or larger) to bit devices (3 points).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps CMP 13 steps DCMP
FNC 10 Operation Operation
S2.
CMP Pulse
D. Pulse (Single)
CMPP (Single) DCMPP
D P Operation
Operation
The comparison value S1. and the comparison source S2. are compared with each other. According
to the result (smaller, equal or larger), either one among D., D.+1 and D.+2 turns ON.
The comparison value [S1.+1, S1] and the comparison source [S2+1, S2.] are compared with each
other. According to the result (smaller, equal or larger), either one among D., D.+1 and D.+2 turns
ON.
⚫ The source data S1., S2. or [S1.+1, S1.] [S2.+1, S2.] are handled as binary values.
86 https://en.coolmay.com/
Move and Compare
Program
example
s
◆ Even if X10=OFF, the CMP instruction is not executed, M0~M2 remain in the state before X10=OFF.
◆ To clear the comparison result, please use RST or ZRST instruction.
◆ If you need to get ≥, ≤, ≠, you can get M0~M2 in series and parallel.
This instruction compares two values (zone) with the comparison source, and outputs the result (smaller, equal
or larger) to bit devices (3 points).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous Continuous
9 steps ZCP 17 steps DZCP
FNC 11 S2. Operation Operation
ZCP S. Pulse
Pulse (Single)
D. ZCPP (Single) DZCPP
D P Operation
Operation
The lower comparison value S1. and upper comparison value S2. are compared with the
87 https://en.coolmay.com/
Move and Compare
comparison source S.. According to the result (smaller, within zone or larger), either one among D.,
D.+1 and D.+2 turns ON.
The lower comparison value [S1.+1, S1.] and upper comparison value [S2.+1, S2.] are compared
with the comparison source [S.+1, S.]. According to the result (smaller, within zone or larger), either
one among D,, D.+1 and D.+2 turns ON.
⚫ Comparison is executed algebraically. Example: −10 < 2 <10
⚫ When the lower limit value S1.>the upper limit value S2., the lower limit value S1. is instructed as
the upper and lower limit values for comparison.
⚫ Start with the device specified in D. and occupy 3 points.
Sample
program
◆ Even if X10=OFF, the ZCP instruction is not executed, M0~M2 remain in the state before X10=OFF.
◆ To clear the comparison result, please use RST or ZRST instruction.
7.3 MOV/Move
88 https://en.coolmay.com/
Move and Compare
16 points(multiple of 4).;
Make sure to use DMOV instruction for transferring the operation result of an applied instruction
(such as MUL) whose operation result is output in 32 bits, and for transferring a 32-bit numeric
value or transferring the current value of a high speed counter (C235 to C255) which is a 32-bit
device.
When specifying digits of a bit device (K8X000 → K8Y000),The bit device transfers a maximum of
Program
example
89 https://en.coolmay.com/
Move and Compare
⚫ While the command input is OFF, the transfer destination D. does not change.
⚫ When the command input turns ON,The transfer source S. and unspecified digits in the transfer
destination D. do not change.
Program
examples 1
90 https://en.coolmay.com/
Move and Compare
D10(BIN16-bit)
↓ ↓ ↓Auto convert
103 102 101 100 D10(BCD 4-digital)
↓Digital move
3 2 1 0
10 10 10 10 D20(BCD 4-digital)
↓ ↓ ↓Auto convert
D20(BIN16-bit)
◆ When M8168=OFF (BCD mode), X0=ON, Specify the 4th digit of the decimal value of D10 (i.e., thousands) from
the lower 2nd digits to the 3rd digit of the decimal value of D20 (i.e., hundreds) from the lower 2nd 2 digits. The
contents of 103 and 100 of D20 have not changed after this instruction is executed.
◆ Before execute, if D10=K1234, D20=K5678, After Being executed, D10 does not change, D20=K5128.
M10
Program M816
examples 8
2
◆ When M8168=ON (BIN mode), if SMOV instruction is executed, D10,D20 will not be executed as BCD conversion,
but is moved in units of 4 bits.
◆ Before execute , if D10=H1234, D20=H5678, After Being executed, D10 does not change, D20=H5128.
91 https://en.coolmay.com/
Move and Compare
7.5 CML/Complement
This instruction inverts data in units of bit, and then transfers (copies) the inverted data.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5steps CML 9steps DCML
FNC 14 S. Operation Operation
CML D. Pulse
Pulse (Single)
CMLP (Single) DCMLP
D P Operation
Operation
2. 32-bit operation(DCML,DCMLP)
Each bit of devices specified as [S.+1,S.] is inverted (0→1,1→0), and then transferred to
[D.+1,D.].
⚫ This operation is useful when a logically inverted output is required as an output from a PLC.
⚫ When a constant K is specified as transfer source S., it is automatically converted into BIN.
Program
example 1
b15 b3 b2 b1 b0
D1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
K1Y0 0 1 0 1
Y3 Y2 Y1 Y0
←Inverted data is
transferred→
◆ When X10=ON, Invert b0~b3 content of D1 and transfer to Y0~Y3.
92 https://en.coolmay.com/
Move and Compare
Program
example 2
93 https://en.coolmay.com/
Move and Compare
Instruction Transfers "n" points of data from S. to "n" points of D. at one time.
Explanation ⚫ If the device number range is exceeded, data is transferred within the possible range.
Program
example 1
Program
example 2
◆ When specifying digits of bit devices KnX, KnY, KnM, KnS to transfer, S. and D. digital numbers should be
same, Namely n number should be same.
94 https://en.coolmay.com/
Move and Compare
Program
example 3
◆ When two operation specif transferred numbers overlap, transfer in the order of ①→②→③.
2. 32-bit operation(DFMOV,DFMOVP)
The contents of [S.+1,S.] are transferred to "n" 32-bit devices starting from [D.+1,D.].
⚫ The contents will be the same among all of "n" 32-bit devices.
⚫ If the number of points specified by "n" exceeds the device number range, data is transferred within
the possible range.
⚫ While the command input is OFF, the transfer destination D. does not change.
⚫ While the command input is ON, the data of the transfer source S. does not change.
95 https://en.coolmay.com/
Move and Compare
⚫ When a constant (K) is specified as the transfer source [ +1, ], it is automatically converted into
binary.
Program
example
3
◆ When X10=ON, K10 is transferred to constant 5 registers which start from D10.
7.8 XCH/Exchange
2. 32-bit operation(DXCH,DXCHP)
96 https://en.coolmay.com/
Move and Compare
Program X0=OFF→ON,Data is exchanged between D20 and D40. Before Execute After Execute
example 1
D20=120 D20=40
D40=40 D40=120
Extend
function
◆ When the instruction is executed while M8160 is ON, high-order 8 bits (byte) and low-order 8 bits (byte) of a
word device are exchanged each other. [while device number of D1. and D2. should be same]
◆ this instruction works in the same way as SWAP instruction
◆ In a 32-bit operation, high-order 8 bits (byte) and low-order 8 bits (byte) of each word device are exchanged for
each other.
97 https://en.coolmay.com/
Move and Compare
This instruction converts binary (BIN) data into binary-coded decimal (BCD) data.
Binary data is used in operations in PLCs. Use this instruction to display numeric values on the seven segment
display unit equipped with BCD decoder.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps BCD 9 steps DBCD
FNC 18 S. Operation Operation
BCD D. Pulse
Pulse (Single)
BCDP (Single) DBCDP
D P Operation
Operation
This instruction converts the binary (BIN) data of [S.+1,S.] into BCD (binary-coded decimal ) data, and
transfers the converted BCD data to [D.+1,D.].
⚫ In 16-bit operation,The data of S. can be converted into BCD (K0 to K9999 )
In 32-bit operation,The data of [S.+1,S.] can be converted into BCD (K0 to K99999999 ).
⚫ The Arithmetic and Logical Operation of the PLC, and the INC and DEC instructions are all executed
in BIN mode. So in terms of application, when you want to see a display with a decimal value, you
can use BCD conversion to convert the BIN value into a BCD value output.
⚫ Operand number specify bits,please check below table: (16-bit max is K4Y0, 32-bit max is K8Y0)
98 https://en.coolmay.com/
Move and Compare
Program
example
◆ When X0=ON, BIN value of D10 is converted to BCD value, Store the single digit of the result in K1Y0 (Y0 ~
Y3) four bit devices .
◆ If D10=001E (Hex)=0030(Decimal), Then execute result Y0~Y3=0000(BIN).
This instruction converts binary-coded decimal (BCD) data into binary (BIN) data.
Use this instruction to convert a binary-coded decimal (BCD) value such as a value set by a digital switch into
binary (BIN) data and to receive the converted binary data so that the data can be handled in operations in PLCs.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps BIN 9 steps DBIN
FNC 19 S. Operation Operation
BIN D. Pulse
Pulse (Single)
BINP (Single) DBINP
D P Operation
Operation
99 https://en.coolmay.com/
Move and Compare
2. 32-bit operation(DBIN,DBINP)
This instruction converts the binary-coded decimal (BCD) data of [S.+1,S.] into binary (BIN) data, and
transfers the converted binary data to [D.+1,D.].
⚫ Constants K and H will be automatically converted into BIN, so this instruction is not necessary.
⚫ In 16-bit operation,The data of S. can be converted between K0 to K9999 (BCD )
In 32-bit operation,The data of [S.+1,S.] can be converted between K0 to K99999999 ( BCD ).
⚫ The Arithmetic and Logical Operation of the PLC, and the INC and DEC instructions are all executed
in BIN mode. So in terms of application, when you want to see a display with a decimal value, you
can use BCD conversion to convert the BIN value into a BCD value output.
⚫ Operand number specify bits,please check below table: (16-bit max is K4Y0, 32-bit max is K8Y0)
Program
Example
Program
Examppl
e
◆ When X0=ON, After the BCD value of K1M0 is converted to BIN value, the result is stored in D10.
100 https://en.coolmay.com/
Arithmetic and Logical Operation
29 NEG Negation ★ ★ ★
101 https://en.coolmay.com/
Arithmetic and Logical Operation
This instruction executes addition by two values to obtain the result (A + B = C).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps ADD 13 steps DADD
FNC 20 Operation Operation
S2.
ADD Pulse
D. Pulse (Single)
ADDP (Single) DADDP
D P Operation
Operation
2. 32-bit operation(DADD,DADDP)
The contents of [S2.+1,S2.] are added to [S1.+1,S1.] in the binary format, and the addition result is
transferred to [D.+1,D.].
⚫ When a constant (K) is specified in or , it is automatically converted into the binary format.
⚫ The most significant bit of each data indicates the sign (positive: 0 or negative: 1), and data are
added algebraically. 5 + (−8) = −3.
⚫ Relationship between the flag operation and the sign (positive or negative) of a numeric value, as
below
102 https://en.coolmay.com/
Arithmetic and Logical Operation
Program
Example
◆ 16-bit BIN addition: When X0=ON, Result of adding D0 content to D10 content will be restored in D20 content
◆ 32-bit BIN addition: When X1=ON, Result of adding (D31,D30) content to (D41,D40) content will be restored in
(D51、D50)content. (Among them, D30,D40,D50 is the low 16-bit data;D31,D41,D51 are the high 16-bit data)
◆ Source Operand number and Target Operand number can also be specified as the same device number
◆ In the above case,when ADD of Continuous Operation is used “ADD: X2=ON”,each scan cycle D100 will add
K25 to D100.
This instruction executes subtraction using two values to obtain the result (A − B = C).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7steps SUB 13steps DSUB
FNC 21 Operation Operation
S2.
SUB Pulse
D. Pulse (Single)
SUBP (Single) DSUBP
D P Operation
Operation
103 https://en.coolmay.com/
Arithmetic and Logical Operation
2. 32-bit operation(DSUB,DSUBP)
The contents of [S2.+1,S2.] are subtracted from [S1.+1,S1.] in the binary format, and the subtraction
result is transferred to [D.+1,D.].
⚫ Relationship between the flag operation and the sign (positive or negative) of a numeric value:
Device Name Description
ON : When the operation result is 0
M8020 Zero
OFF: When the operation result is other than 0
ON : When the operation result is less than −32768 (in 16-bit operation) or
−2,147,483,648 (in 32-bit operation)
M8021 Borrow OFF: When the operation result is not less than −32768 (in 16-bit
operation) or
−2,147,483,648 (in 32-bit operation)
ON : When the operation result is more than 32767 (in 16-bit operation) or
2,147,483,647 (in 32-bit operation)
M8022 Carry OFF: When the operation result is not more than 32767 (in 16-bit
operation) or
2,147,483,647 (in 32-bit operation)
Program X0
Example SUB D0 D10 D20
◆ 16-bit BIN Subtraction: When X0=ON, Result of subtracting D10 content from D0 content will be restored in
D20 content
X1
DSUB D30 D40 D50
◆ 32-bit BIN Subtraction: When X1=ON, Result of subtracting (D41,D40) content from (D31,D30) content will be
restored in (D51、D50)content. (Among them, D30,D40,D50 is the low 16-bit data;D31,D41,D51 are the high
16-bit data)
X2
SUB D100 k25 D100
◆ Source Operand number and Target Operand number can also be specified as the same device number
◆ In the above case,when Continuous Operation is used “SUB: X2=ON”,each scan cycle D100 will subtract K25
to D100.
104 https://en.coolmay.com/
Arithmetic and Logical Operation
This instruction executes multiplication by two values to obtain the result (A x B = C).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps MUL 13 steps DMUL
FNC 22 Operation Operation
S2.
MUL Pulse
D. Pulse (Single)
MULP (Single) DMULP
D P Operation
Operation
2. 32-bit operation(DMUL,DMULP)
The contents of [S1.+1, S1.] are multiplied by[S2.+1, S2.] in the binary format, and the multiplication
result is transferred to 64-bit [D.+3, D.+2, D.+1, D.] (four word devices).
⚫ When a constant (K) is specified in S1. and S2 or [S1.+1,S1.]and [S2.+1,S2.], it is automatically
converted into the binary format.
⚫ The most significant bit of each data indicates the sign (positive: 0 or negative: 1), and data are
⚫ When a digit (K1 to K8) is specified for [D.+3, D.+2, D.+1, D.],occupy 2 consecutive 32-bit data.
⚫ In a 32-bit operation (DMUL ,DMULP), Z cannot be specified.
X0
Program MUL D0 D2 D4
Example
◆ 16-bit BIN Multiplication: When X0=ON, Result of multiplying D0 and D2 content will be restored in [D5,D4]
content
X1
DMUL D6 D8 D10
◆ 32-bit BIN Multiplication: When X1=ON, Result of multiplying (D7,D6) and (D9,D8) content will be restored in
(D13,D12,D11,D10) content.
105 https://en.coolmay.com/
Arithmetic and Logical Operation
This instruction executes division by two values to obtain the result (A ÷ B = C ... ).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps DIV 13 steps DDIV
FNC 23 Operation Operation
S2.
DIV Pulse
D. Pulse (Single)
DIVP (Single) DDIVP
D P Operation
Operation
2. 16-bit operation(DDIV,DDIVP)
[S1.+1, S1.] indicates the dividend,[S2.+1, S2.] indicates the divisor, the quotient is transferred to
[D.+1, D.]), and the remainder is transferred to [D.+3, D.+2]
106 https://en.coolmay.com/
Arithmetic and Logical Operation
Program X0
Example
DIV D0 D2 D4
X1
DDIV D6 D8 D10
107 https://en.coolmay.com/
Arithmetic and Logical Operation
2. 32-bit operation(DINC,DINCP)
The contents of [D.+1, D.] are incremented by "1", and the increment result is transferred to [D.+1,
D.].
⚫ Note that data is incremented in every operation cycle in a continuous operation type instruction.
⚫ 16-bit BIN operation,When "+32767" is incremented by "1", the result is "−32768". Flags (zero, carry
and borrow) are not activated at this time.
⚫ 32-bit BIN operation,When "+2,147,483,647" is incremented by "1", the result is "−2,147,483,648".
Flags (zero, carry and borrow) are not activated at this time.
X1
Program
INCP D0
Example
108 https://en.coolmay.com/
Arithmetic and Logical Operation
2. 32-bit operation(DDEC,DDECP)
The contents of [D.+1, D.] are decremented by "1", and the decremented result is transferred to
[D.+1, D.].
⚫ Note that data is decremented in every operation cycle in a continuous operation type instruction.
⚫ 16-bit BIN operation,When "−32768" is decremented by "1", the result is "+32767". Flags (zero,
carry and borrow) are not activated at this time.
⚫ 32-bit BIN operation,When "−2,147,483,648" is decremented by "1", the result is
"+2,147,483,6478". Flags (zero, carry and borrow) are not activated at this time.
Program
Example
109 https://en.coolmay.com/
Arithmetic and Logical Operation
This instruction executes the logical product (AND) operation of two numeric values.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
W
Continuous Continuous
S1. 7 steps WAND 13 steps DAND
FNC 26 Operation Operation
S2.
AND Pulse
D. Pulse (Single)
WANDP (Single) DANDP
D P Operation
Operation
Data used for logical product or word device number storing data
S1. BIN16/32-bit
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, modify
Operand Data used for logical product or word device number storing data
S2. BIN16/32-bit
number Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, modify
Word device number storing the logical product result
D. BIN16/32-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, V, Z, modify
2. 32-bit operation(DAND,DANDP)
The logical product (AND) operation is executed to the contents of [S1.+1,S1.] and [S2.+1,S2.] in
units of bit, and the result is transferred to[D.+1, D.].
⚫ When a constant (K) is specified in the transfer source S1. and S2 or [S1.+1,S1.]and [S2.+1,S2.],
it is automatically converted into the binary format
⚫ The logical product (AND) operation is executed in units of bit as shown in the table below (1 ∧ 1
= 1, 0 ∧ 1 = 0, 1∧ 0 = 0, 0 ∧ 0 = 0).
S1. S2. D.
[S1.+1,S1.] [S2.+1,S2.] [D.+1, D.]
0 0 0
Logical operation 1 0 0
(unit: bit) 0 1 0
1 1 1
110 https://en.coolmay.com/
Arithmetic and Logical Operation
Program X0
Example WAND D0 D2 D4
◆ When X0=ON, 16-bit D0 and D2 for WAND logical AND operation, the result will be restored in D4.
b15 b0
Before D0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1
execution WAND
D2 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
After
D4 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0
execution
This instruction executes the logical sum (OR) operation of two numeric values.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
W
Continuous Continuous
S1. 7 steps WOR 13 steps DOR
FNC 27 Operation Operation
S2.
OR Pulse
D. Pulse (Single)
WORP (Single) DORP
D P Operation
Operation
Data used for logical sum or word device number storing data
S1. BIN16/32-bit
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, modify
Operand Data used for logical sum or word device number storing data
S2. BIN16/32-bit
number Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, modify
Word device number storing the logical sum result
D. BIN16/32-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, V, Z, modify
111 https://en.coolmay.com/
Arithmetic and Logical Operation
2. 32-bit operation(DOR,DORP)
The logical sum (OR) operation is executed to the contents of [S1.+1,S1.] and[S2.+1,S2.] in units of
bit, and the result is transferred to [D.+1, D.].
⚫ When a constant (K) is specified in the transfer source S1. and S2 or [S1.+1,S1.]and [S2.+1,S2.],
it is automatically converted into the binary format.
⚫ The logical word OR operation is executed in units of bit as shown in the table below (1∨1=1 0∨
S1. S2. D.
[S1.+1,S1.] [S2.+1,S2.] [D.+1, D.]
0 0 0
Logical operation 1 0 1
(unit: bit) 0 1 1
1 1 1
Program
Example
◆ When X0=ON, 16-bit D0 and D2 for WOR, logical word OR operation, the result will be restored in D4.
b15 b0
Before D0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
execution WOR
D2 0 0 0 0 1 1 1 1 1 0 1 0 0 1 0 1
After
D4 0 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1
execution
112 https://en.coolmay.com/
Arithmetic and Logical Operation
This instruction executes the exclusive logical sum (XOR) operation of two numeric values.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
W
Continuous Continuous
S1. 7 steps WXOR 13 steps DXOR
FNC 28 Operation Operation
S2.
XOR Pulse
D. Pulse (Single)
WXORP (Single) DXORP
D P Operation
Operation
Data used for exclusive logical sum or word device number storing data
S1. Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, BIN16/32-bit
modify
Operand Data used for exclusive logical sum or word device number storing data
number S2. Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, BIN16/32-bit
modify
Word device number storing the exclusive logical sum result
D. BIN16/32-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, V, Z, modify
2. 32-bit operation(DXOR,DXORP)
The exclusive logical sum (XOR) operation is executed to the contents of [S1.+1,S1.] and [S2.+1,S2.]
in units of bit, and the result is transferred to [D.+1, D.].
⚫ When a constant (K) is specified in the transfer source S1. and S2 or [S1.+1,S1.]and [S2.+1,S2.],
it is automatically converted into the binary format.
⚫ The logical exclusive OR operation is executed in units of bit as shown in the table below(1∀1=0
0∀0=0 1∀0=1 0∀1=1).
S1. S2. D.
[S1.+1,S1.] [S2.+1,S2.] [D.+1, D.]
0 0 0
Logical operation 1 0 1
(unit: bit) 0 1 1
1 1 0
113 https://en.coolmay.com/
Arithmetic and Logical Operation
Program
Example
◆ When X0=ON, 16-bit D0 and D2 for WXOR, logical exclusive OR operation, the result will be restored in D4.
b15 b0
Before D0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
execution WXOR
D2 0 0 0 0 1 1 1 1 1 0 1 0 0 1 0 1
After
D4 0 1 0 1 1 0 1 0 1 1 1 1 0 0 0 0
execution
8.10 NEG/Negation
This instruction obtains the complement of a numeric value (by inverting each bit and adding "1").
This instruction can be used to negate the sign of a numeric value.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
3 steps NEG 13 steps DNEG
FNC 29 Operation Operation
D.
NEG Pulse
Pulse (Single)
NEGP (Single) DNEGP
D P Operation
Operation
Word device number which stores data for obtaining complement and
Operand will store the operation result (The operation result will be stored in the
D. BIN16/32-bit
number same word device number.)
Applicable devices: KnY, KnM, KnS, T, C, D, R, V, Z, modify
2. 32-bit operation(DNEG,DNEGP)
114 https://en.coolmay.com/
Arithmetic and Logical Operation
Each bit of [D.+1, D.] is inverted (0 → 1, 1 → 0), "1" is added, and then the result is stored in the
original device.
⚫ When a constant (K) is specified in the transfer source S1. and S2 or [S1.+1,S1.]and [S2.+1,S2.],
it is automatically converted into the binary format
⚫ Note that the complement is obtained in every operation cycle in a continuous operation type
instruction
M800
Program 0
BON D10 M0 K15
Example
(一) M0
NEGP D10
Program
Example
(二)
More
explanation
115 https://en.coolmay.com/
Arithmetic and Logical Operation
116 https://en.coolmay.com/
Rotation and Shift Operation
117 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts and rotates the bit information rightward by the specified number of bits without the carry flag.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps ROR 9 steps DROR
FNC 30 D. Operation Operation
ROR n Pulse
Pulse (Single)
RORP (Single) DRORP
D P Operation
Operation
2. 32-bit operation(DROR,DRORP)
Program
Example
◆ When X0 change from “OFF” to “ON”, 16bits of D10are rotated rightward as 4bits one group, bit content of ※
118 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts and rotates the bit information leftward by the specified number of bits without the carry flag.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps ROL 9 steps DROL
FNC 31 D. Operation Operation
ROL n Pulse
Pulse (Single)
ROLP (Single) DROLP
D P Operation
Operation
2. 32-bit operation(DROL,DROLP)
Program
Example
◆ When X0 change from “OFF” to “ON”, 16bits of D10are rotated leftward as 4bits one group, bit content of ※ is
119 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts and rotates the bit information rightward by the specified number of bits together with the carry
flag
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps RCR 9 steps DRCR
FNC 32 D. Operation Operation
RCR n Pulse
Pulse (Single)
RCRP (Single) DRCRP
D P Operation
Operation
2. 32-bit operation(DRCR,DRCRP)
"n" bits out of 32 bits of [D.+1, D.] and 1 bit (carry flag M8022) are rotated rightward.
⚫ The carry flag is intervened in the rotation loop. If M8022 has been set to ON or OFF before the
rotation instruction, the carry flag is transferred to the destination Operand number.
⚫ In a device with digit specification, K4 (16-bit instruction) / K8(32-bit instruction)is valid.
Program
Example
◆ When X0 change from “OFF” to “ON”, Total 17bits that 16bits of D10 and carry flag M8022 are rotated
rightward as 4bits one group, bit content of ※ is transferred to carry flag M8022, as below picture.
120 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts and rotates the bit information leftward by the specified number of bits together with the carry
flag.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps RCL 9 steps DRCL
FNC 33 D. Operation Operation
RCL n Pulse
Pulse (Single)
RCLP (Single) DRCLP
D P Operation
Operation
2. 32-bit operation(DRCL,DRCLP)
"n" bits out of 32 bits of [D.+1, D.] and 1 bit (carry flag M8022) are rotated leftward.
⚫ The carry flag is intervened in the rotation loop. If M8022 has been set to ON or OFF before the
rotation instruction, the carry flag is transferred to the destination Operand number.
⚫ In a device with digit specification, K4 (16-bit instruction) / K8(32-bit instruction)is valid.
Program
Example
◆ When X0 change from “OFF” to “ON”, Total 17bits that 16bits of D10 and carry flag M8022 are rotated leftward
as 4bits one group, bit content of ※ is transferred to carry flag M8022, as below picture.
121 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts bit devices of the specified bit length rightward by the specified number of bits. After shift, the
bit device S. is transferred by "n2" bits from the most significant bit.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S. Continuous
9 steps SFTR --
FNC 34 D. Operation
SFTR n1 Pulse
n2 SFTRP (Single) --
P
Operation
Head bit device number to be stored to the shift data after rightward
S. shift bit
Applicable devices: X, Y, M, S, D 口.n, modify
122 https://en.coolmay.com/
Rotation and Shift Operation
Program
Example
◆ When X0 is in rising edge, 16bits (M0~M15) shift right as 4bits. Shift right of each scan acts as below ①~⑤.
① M3~M0 → carry
② M7~M4 → M3~M0
③ M11~M8 → M7~M4
④ M15~M12 → M11~M8
X3 X2 X1 X0
Shift right as 4bits one group→
⑤ ↓ ↓ ↓ ↓
M1 M1 M1 M1 M1 carr
M11 M9 M8 M7 M6 M5 M4 M3 M2 M1 M0
5 4 3 2 0 y
④ ③ ② ①
This instruction shifts bit devices of the specified bit length leftward by the specified number of bits. After shift, the
bit device S. is transferred by "n2" bits from the least significant bit.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S. Continuous
9 steps SFTL --
FNC 35 D. Operation
SFTL n1 Pulse
n2 SFTLP (Single) --
P
Operation
Head bit device number to be stored to the shift data after leftward shift
S. bit
Operand Applicable devices: X, Y, M, S, D 口.n, modify
number Head bit device number to be shifted leftward
D. bit
Applicable devices: Y, M, S, modify
123 https://en.coolmay.com/
Rotation and Shift Operation
⚫ Note that "n2" bits are shifted every time the command input turns ON from OFF in SFTLP
instruction, but that "n2" bits are shifted in each operation cycle in SFTL instruction.
Program
Example
◆ When X0 is in rising edge, 16bits (M0~M15) shift left as 4bits. Shift left of each scan acts as below ①~⑤.
① M15~M12 → Carry
② M11~M8 → M15~M12
③ M7~M4 → M11~M8
④ M3~M0 → M7~M4
M3~M0
⑤ X3~X0 →
Complete
X3 X2 X1 X0
←Shift left as 4bits one group
↓ ↓ ↓ ↓
⑤
M1 M1 M1 M1 M1
Carry M11 M9 M8 M7 M6 M5 M4 M3 M2 M1 M0
5 4 3 2 0
① ② ③ ④
124 https://en.coolmay.com/
Rotation and Shift Operation
This instruction shifts word devices with "n1" data length rightward by "n2" words.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S. Continuous
9 steps WSFR --
FNC 36 D. Operation
WSFR n1 Pulse
n2 WSFRP (Single) --
P
Operation
Head device number to be stored to the shift data after rightward shift
S. BIN16-bit
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, modify
Head word device number storing data to be shifted rightward
D. BIN16-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, modify
Operand
number Word data length of the shift data n2≦n1≦512
n1 BIN16-bit
Applicable devices: K, H
⚫ Note that "n2" words are shifted when the drive input turns ON in WSFRP instruction, but that "n2"
words are shifted in each operation cycle in WSFR instruction.
Program
Example
◆ When X0 change From “OFF” to “ON”, 16registers (D20-D35) are listed as the shift area, and shifted to the
125 https://en.coolmay.com/
Rotation and Shift Operation
① D23~D20 → carry
② D27~D24 → D23~D20
③ D31~D28 → D27~D24
④ D35~D32 → D31~D28
D35 D34 D33 D32 D31 D30 D29 D28 D27 D26 D25 D24 D23 D22 D21 D20 carry
④ ③ ② ①
This instruction shifts the word data information leftward by the specified number of words.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S. Continuous
9 steps WSFL --
FNC 37 D. Operation
WSFL n1 Pulse
n2 WSFLP (Single) --
P
Operation
Head device number to be stored to the shift data after leftward shift
S. BIN16-bit
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, modify
Head word device number storing data to be shifted leftward
D. BIN16-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, modify
Operand
number Word data length of the shift data n2≦n1≦512
n1 BIN16-bit
Applicable devices: K, H
126 https://en.coolmay.com/
Rotation and Shift Operation
⚫ Note that "n2" words are shifted when the drive input turns ON from OFF in WSFLP instruction, but
that "n2" words are shifted in each operation cycle in WSFL instruction.
Program
Program
Example
Examppl
e
◆ When X0 change From “OFF” to “ON”, 16registers (D20-D35) are listed as the shift area, and shifted to the left
① D35~D32 → carry
② D31~D28 → D35~D32
③ D27~D24 → D31~D28
④ D23~D20 → D27~D24
① ② ③ ④
127 https://en.coolmay.com/
Rotation and Shift Operation
This instruction writes data for first-in first-out (FIFO) and last-in first-out (LIFO) control.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S. 7steps SFWR --
FNC 38 Operation
D.
SFWR Pulse
n
SFWRP (Single) --
P
Operation
Operand Head word device number storing data (The first word device works
number D. as the pointer, and data is stored in D.+1 and later) BIN16-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, modify
⚫ Note that data are stored (overwritten) in each scan time (operation cycle).
⚫ When the contents of the pointer D. exceeds "n-1", no operation is executed (so data is not written)
and the carry flag M8022 turns ON.
⚫ the number of stored data is specified by the contents of the pointer
⚫ SFWR and SFRD instruction can be used together, execute write/read control of FIFO/FILO data
listed.
Program
Example
◆ Clear the pointer D0, when X0 change from OFF to ON, content of D20 is transferred to D1, pointer D0 content
becomes to 1. After changing D20 content, again change X0 from OFF to ON, then content of D20 is
transferred to D2, D0 content becomes to 2.
128 https://en.coolmay.com/
Rotation and Shift Operation
D20 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Pointer
D0= 3 2 1
Head word device number storing data (The first word device works
S. as the pointer, and data is stored from S.+1) BIN16-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, modify
Operand Word device number storing data taken out first
number D. BIN16-bit
Applicable devices: KnY, KnM, KnS, T, C, D, R, V, Z, modify
⚫ When use SFRD Continuous Operation,Each scan circle(operation circle) will execute and read in
turns, but content of S.+n do not change.
⚫ When content of S. is 0,no operand, and the content of D. will not change,the zero flag M8020 turns
ON.
⚫ Data after reading was executed,The contents of S.+n do not change by reading.
129 https://en.coolmay.com/
Rotation and Shift Operation
⚫ SFWR and SFRD instruction can be used together, execute write/read control of FIFO/FILO data
listed.
Program
Example
◆ When X0=OFF→ON, the content of D1 is transferred to D21, D9~D2 are shifted right by 1 register(D9 keep
same), Pointer D0 content decrease 1.
← n=10 →
D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 D21
Pointer
Data read
130 https://en.coolmay.com/
High Speed Processing
41 DECO Decode ★ ★ ★
42 ENCO Encode ★ ★ ★
45 MEAN Mean ★ ★ ★
131 https://en.coolmay.com/
High Speed Processing
This instruction resets devices located in a zone between two specified devices at one time.
Use this instruction for restarting operation from the beginning after pause or after resetting control data.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps ZRST --
FNC 40 D1. Operation
ZRST D2. Pulse
ZRSTP (Single) --
P
Operation
132 https://en.coolmay.com/
High Speed Processing
Program
Example
Extended
instruction
1. RST is an independent reset instruction for device,. RST instruction can be used for bit devices (Y,M,S) and word
devices (T, C, D and R).
For example: RST M0, RST T0.
2. FMOV (FNC 16) instruction is provided to write a constant (example: K0) at one time to devices (KnY, KnM, KnS,
T, C, D and R) to clear to 0.
For example: FMOV K0 D0 K100(write K0 to D0~D99)
133 https://en.coolmay.com/
High Speed Processing
10.2 DECO/Decode
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S. 7 steps DECO --
FNC 41 Operation
D.
DECO Pulse
n
DECOP (Single) --
P
Operation
134 https://en.coolmay.com/
High Speed Processing
Program
Example
◆ When X10=OFF→ON, DECO instruction decodes the content value of X0~X2 to M100~M107.
◆ When the value of X0~X3 is 3(1+2+0), the 3rd bit M103 from M100 is set to 1.
◆ When the DECO instruction is executed, and X10 becomes OFF, The decoder output acted as usual.
Program
Example
◆ When X10=OFF→ON, DECO instruction decodes the content value of (b2~b0) in D10 to (b7~b0) of D20 All
unused bits (b15~b8) in D20 become 0.
◆ The lower 3 bits of D10 are decoded and stored in the lower 8 bits of D20, and the upper 8 bits are all 0.
◆ When the DECO instruction is executed, and X10 becomes OFF, The decoder output acted as usual.
135 https://en.coolmay.com/
High Speed Processing
10.3 ENCO/Encode
⚫ When S. is a bit device ((1≦n≦8), ON bit positions among "2n" bits (1 ≤ n ≤ 8) from S. are encoded
to (1≦n≦8)D..
——The encoding result of D. is "0" (OFF) from the most significant bit to the low-order bit "n".
When "n" is "8", 28 = 256 bits (which is the maximum value) are occupied.
⚫ When is a word device S. (1≦n≦4), ON bit positions among "2n" bits (1 ≤ n ≤ 4) from a device
136 https://en.coolmay.com/
High Speed Processing
Program
Example
◆ When X10=OFF→ON,23 bits(M0~ M7)of data is decoded by ENCO instruction and stored in the lower 3bits
(b2~b0) of D0,All unused bits (b15~b3) in D0 become 0.
◆ When the ENCO instruction is executed, and X10 becomes OFF, data in D don’t change.
Program
Example
(二)
◆ When X0=OFF→ON, the 23 bits of data (b0~b7) in D10 are stored in the lower 3 bits (b2~b0) of D20, and all
unused bits (b15~b3) in D20 become 0 . (B8~b15 in D10 are invalid data)
◆ When the ENCO instruction is executed, X0 turns OFF, and the data in D don’t change.
137 https://en.coolmay.com/
High Speed Processing
Calculate how many "1" (ON) instructions are in the data of the specified device.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps SUM 9 steps DSUM
FNC43 S. Operation Operation
SUM D. Pulse
Pulse (Single)
SUMP (Single) DSUMP
D P Operation
Operation
Instruction
1. 16-bit operation(SUM,SUMP)
Explanation
The number of bits in the ON status in S. is counted, and stored to D..
2. 32-bit operation(DSUN,DSUMP)
The number of bits in the ON status in [S.+1, S.] is counted, and stored to D..
⚫ When all bits are OFF in S. or [S.+1, S.], the zero flag M8020 turns ON.
⚫ The number of bits in the ON status are stored in D., and K0 is stored in D.+1.
Program
Example
b15 b0
0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 K3
D0 D2
◆ When X10 is ON, Among 16bits of D0, the total number of bits with a content of "1" is stored in D2.
138 https://en.coolmay.com/
High Speed Processing
This instruction counts the number of "1" (ON) bits in the data of a specified device.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S. 7 steps BON 13 steps DBON
FNC44 Operation Operation
D.
BON Pulse
n Pulse (Single)
BONP (Single) DBONP
D P Operation
Operation
2. 32-bit operation(DBON,DBONP)
The status (ON or OFF) of the bit "n" in[S.+1, S.] is output to D.
⚫ When a constant (K) is specified as the transfer source S. or [S.+1, S.], it is automatically converted
into the BIN format.
⚫ Note: When D and R are specified as n of 32-bit instruction, the 32-bit value of [n+1,n] will take
Program
Example
(二)
10.6 MEAN/Mean
Instruction
1. 16-bit operation(MEAN,MEANP)
Explanation
The mean value of "n" 16-bit data from S. is stored to D. .
2. 32-bit operation(DMEAN,DMEANP)
The mean value of "n" 32-bit data from [S.+1, S.] is stored to [D.+1, D.].
⚫ The sum is obtained as algebraic sum, and divided by "n".
⚫ The remainder is ignored.
Program X1
Example 0 MEAN D0 D10 K3
(D0+D1+D2)/3→ D10
(K100+K113+K125)/3→ D10=K112.......remainder=2 (ignored)
◆ When X10=ON, The data of D0, D1 and D2 are summed, divided by "3", and then stored to D10.
140 https://en.coolmay.com/
High Speed Processing
2. Related devices:
Device Name Description
Enable
M8049 When M8049 is set to ON, M8048 and D8049 are valid.
annunciator
When M8049 is ON and one of the state relays S900 to S999 is
M8048 Annunciator ON
ON, M8048 turns ON.
Smallest state
relay Among S900 to S999, the smallest state relay number in the ON
D8049
number in ON status is stored.
status
141 https://en.coolmay.com/
High Speed Processing
Program
example (1)
◆ When X3=ON exceeds 5 seconds, the alarm point S999=ON, then even if X3 becomes OFF, S999 will remain
ON. (But T10 will be reset to OFF, the current value = 0).
Program
example (2)
142 https://en.coolmay.com/
High Speed Processing
This instruction resets an annuciator (S900 to S999) in the ON status with the smallest number.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
1 step ANR
FNC47 Operation
null
ANR Pulse
ANRP (Single)
P
Operation
3. Related devices:
Device Name Description
Enable
M8049 When M8049 is set to ON, M8048 and D8049 are valid.
annunciator
When M8049 is ON and one of the state relays S900 to S999 is
M8048 Annunciator ON
ON, M8048 turns ON.
Smallest state
relay Among S900 to S999, the smallest state relay number in the ON
D8049
number in ON status is stored.
status
143 https://en.coolmay.com/
High Speed Processing
2. 32-bit operation(DSQR,DSQRP)
The square root of the data stored in [S.+1, S.] is calculated, and stored to [D.+1, D.].
⚫ Operation result:
1) The obtained square root is an integer because the decimal point is ignored.
When the calculated value is ignored, M8021 (borrow flag) turns ON.
2) When the calculated value is true "0", M8020 (zero flag) turns ON.
Program
Example
144 https://en.coolmay.com/
High Speed Processing
This instruction converts a binary integer into a binary floating point (real number).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5steps FLT 9steps DFLT
FNC49 S. Operation Operation
FLT D. Pulse
Pulse (Single)
FLTP (Single) DFLTP
D P Operation
Operation
2. 32-bit operation(DFLT,DFLTP)
The binary integer data of [S.+1, D.] is converted into binary floating point (real number), and stored
to[D.+1, D.].
⚫ The value of a K or H specified in each instruction for binary floating point (real number) operation
is automatically converted into binary floating point (real number). It is not necessary to convert
such a constant using by FLT instruction
Program
Example
◆ When X10=ON, D0 (internal BIN integer) is converted into a binary floating point value and stored in D13 and
D12.
145 https://en.coolmay.com/
High Speed Processing
146 https://en.coolmay.com/
High Speed Processing
11.1 REF/Refresh
This instruction immediately outputs the latest input (X) information or the current output (Y) operation result in the
middle of a sequence program.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps REF
FNC50 D. Operation
REF n Pulse
REFP (Single)
P
Operation
Program
Example1
◆ When X10=ON, X0~X7,X10~X17 The status of these 16 input points is refreshed immediately.
Program
Example2
◆ When X10=ON, Y0~Y7,Y10~Y17,Y20~Y27 The status of these 24 input points is refreshed immediately.
147 https://en.coolmay.com/
High Speed Processing
The digital input filter time of the inputs X000 to X017*1 can be changed using this instruction or D8020.
Using this instruction, the status of inputs X000 to X017*1 can be refreshed at an arbitrary step in the program for
the specified input filter time, and then transferred to the image memory.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
3 steps REFF
FNC51 Operation
n
REFF Pulse
REFFP (Single)
P
Operation
⚫ The value of the input filter, changes according to the design content of D8020 (initial value: 10ms).
⚫ When the input turns ON "n × 1 ms" before the instruction is executed, the image memory is set to
ON.
When the input turns OFF "n × 1 ms" before the instruction is executed, the image memory is set
to OFF.
⚫ When the command input is ON, the REFF instruction is executed in each operation cycle.
⚫ When the command input is OFF, the REFF instruction is not executed, and the input filter of X000
to X017*1 uses the set value of D8020 (which is the value used during input processing).
Program
Example
◆ When PLC power =OFF→ON, When PLC power is turned from OFF→ON, The
response time of the input terminals X0~X17 is determined by the content value
of D8020 (default 10ms).
◆ When X20=ON, REFF K5 instruction is executed,
The response time was changed to 5 ms, and it was adjusted at the next scan.
◆ X20=OFF 时, REFF K20 instruction is executed,
The response time was changed to 20 ms, and it was adjusted at the next scan.
148 https://en.coolmay.com/
High Speed Processing
This instruction reads matrix input as 8-point input* "n"-point output (transistor) in the time division method
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC52 D1. Continuous
9 steps MTR
MTR D2. Operation
n
Program
Example
◆ When PLC RUN, The MTR instruction starts to be executed, and the status of 16 switches in the external 2
lines is read sequentially and stored in the internal relays M10~M17, M20~M27.
149 https://en.coolmay.com/
High Speed Processing
This instruction compares a value counted by a high speed counter with a specified value, and immediately sets an
external output (Y) if the two values are equivalent each other.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1.
FNC53 Continuous
S2. 13 steps DHSCS
HSCS Operation
D.
D
6points: I010~I060]
Program
Example
◆ When X3=ON, DHSCS instruction execute, the current value of the high speed counter C255 changes from
"99" to "100" or from "101" to "100",Y010 is set to ON (output refresh).
150 https://en.coolmay.com/
High Speed Processing
Program
Example
This instruction compares the value counted by a high speed counter with a specified value at each count,and
immediately resets an external output (Y) when both values become equivalent to each other.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1.
FNC54 Continuous
S2. 13 步 DHSCR
HSCR Operation
D.
D
151 https://en.coolmay.com/
High Speed Processing
⚫ 8 input points are occupied from the input device number specified in S.
⚫ "n" output points are occupied from the output device number specified in D1..
When specifying the output in D2., make sure that "n" output numbers specified in D1.
⚫ Use the transistor output format.
Program
M8000
Example
C255 K2,147,482,647
X3
DHSC K100 C255 Y10
◆ When X3=ON, DHSCS instruction execute, the current value of the high speed counter C255 changes from
"99" to "100" or from "101" to "100",Y010 is set to ON (output refresh).
This instruction compares the current value of a high speed counter with two values (one zone), and outputs the
comparison result to three bit devices (refresh).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. Instruction Condition Instruction Condition
FNC55 S2. Continuous
17 steps DHSZ
HSZ S. Operation
D.
D
152 https://en.coolmay.com/
High Speed Processing
comparison points (comparison value 1 S1.and comparison value 2 S2.). Based on the comparison
result, "smaller than the lower comparison value", "inside the comparison zone" or "larger than the
upper comparison value",one among , D.,D.+1,D.+2 is set to ON regardless of the operation cycle.
In this instruction, the comparison processing is executed after the count processing in the high
speed counter.
⚫ DHSZ instruction outputs the comparison result only when the count pulse is input. Even if the
current value of C23 is 0, Y010 will remain OFF when start.
Program
Example
(1)
153 https://en.coolmay.com/
High Speed Processing
This instruction counts the input pulse for a specified period of time as interrupt input.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1.
FNC56 Continuous Continuous
S2. 7 steps SPD 13 steps DSPD
SPD Operation Operation
D.
D
2. 32-bit operation(DSPD)
The input pulse S1. is counted only for [S2.+1, S.]* 1 ms. The measured value is stored in [D.+1,
D.], the present value is stored in [D.+3, D.+2], and the remaining time is stored in [D.+5,
D.+4](ms).
By repeating this operation, the measured value [ +1, ] will store the pulse density (which is
proportional to the rotation speed).
⚫ An input device X000 to X007 specified as cannot overlap the following functions or instructions:
- High speed counter
- Input interrupt
- Pulse catch
- DSZR instruction
- DVIT instruction
⚫ - ZRN instruction ,Only one instruction can be used per input point.
⚫ Occupied devices
1) 16-bit operation: 3devices are occupied from a device specified in D.
2) 32-bit operation: 6devices are occupied from a device specified in D.
⚫ The value of the measured value D. is proportional to the speed as follows
154 https://en.coolmay.com/
High Speed Processing
N: Rotating speed.
n: The number of pulses produced by one rotation of the rotating equipment.
t: The detection time specified for S2.(ms)
X3
Program
Example SPD X1 K1000 D0
◆ WhenX3=ON, D1 calculates the high-speed pulse input by X1. After 1000ms, the calculation stops
automatically, and the result is stored in D0.
◆ 1000ms timing, is over, the content of D1 is cleared to 0, and when X7 turns ON again, D1 accepts the count
again.
155 https://en.coolmay.com/
High Speed Processing
Y0,Y1,Y6,Y7,Y10(optional)], modify
2. 32-bit operation(DPLSY)
A pulse train at the frequency [S1+1., S1] is output by the quantity [S2+1., S2] from the output Y D.
⚫ S2.,[S2.+1, S2.]: Specify the generated pulse quantity(PLS), Allowable setting range: 1 ~
2,147,483,647(PLS)
⚫ D.: Specify the output (Y) number from which pulses are output, Allowable setting range: 3G:
Y0~Y7;2N: Y0~Y3,Y10.
156 https://en.coolmay.com/
High Speed Processing
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
Function
Description
Send end flag M8029 M8029 M8029 M8029 M8029 M8029 M8029 M8029
Pulse M8340 M8350 M8360 M8370 M8151 M8152 M8153 M8154
operation
monitoring
Position D8340 D8350 D8360 D8370 D8140 D8142 D8144 D8160
pulse(32bit) D8341 D8351 D8361 D8371 D8141 D8143 D8145 D8161
accelerate / D8348 D8358、 D8368、 D8378、 D8148 D8148 D8148 D8148
decelerate D8349
D8359 D8369 D8379
time
Pulse stop bit M8349 M8359 M8369 M8379 M8450 M8451 M8452 M8453
Maximum D8343 D8353 D8363 D8373 D8146 D8146 D8146 D8146
speed D8344 D8354 D8364 D8374 D8147 D8147 D8147 D8147
Program X0
Example
PLSY K1000 K0 D0
◆ If X0=ON, generate 1KHz frequency pulse without any limitation(S2. is set to K0, pulses are output without any
limitation.)output from Y0.
157 https://en.coolmay.com/
High Speed Processing
Y0~Y3,Y10(Optional)], modify
Program X0
Example PWM K1000 K2000 Y1
Output Y1
◆ If X0=ON, Y1 output above pulse, When X0=OFF, Y1 output also change to OFF.
158 https://en.coolmay.com/
High Speed Processing
Extra
Description
1. For Coolmay PLC, PWM pulse width usage pls refer to below:
Conventional PWM:
1) Only Support 2channels Y0,Y1(please select transistor MT output);
2) There is no limit to the pulse width and pulse period, both in milliseconds (ms).
Special customized PWM——as Analog output
The following parameters are required for model selection:
1) the controller type and the output voltage of the required PWM;
2) the output frequency of the required PWM;
3) pulse width range;
4) to customize to microsecond (μs) level or millisecond (ms) level? [default is millisecond (ms) level];
5) the digital range corresponding to the controller action range;
6) Confirm the numbers of customized PWM, up to 8 PWM. (depending on analog outputs that customer make).
Program, refer to analog output.
159 https://en.coolmay.com/
High Speed Processing
1) M8080 , the start contact of the analog DA0-DA3 output function. When it is set to ON, the analog DA0-DA3 can
be output.
2) M8084 is the start contact for the analog DA4-DA7 output function. When it is set to ON, the analog DA4-DA7
can be output.
2. For Coolmay PLC, PWM pulse width usage in 3G series pls refer to below:
Conventional PWM:
1) Support 8channels Y0-Y7 (please select transistor MT output);
2) There is no limit to the pulse width and pulse period, both in milliseconds (ms).
Special customized PWM——as Analog output
The following parameters are required for model selection:
1) the output voltage of the required PWM;
2) the output frequency of the required PWM;
3) Confirm the numbers of customized PWM, up to 8 PWM. (depending on analog outputs that customer make).
4) Whether the customized PWM coexists with other analog. (If the product is separately equipped with analog,
the analog output terminals DA0~DA3 are a group, and DA4~DA7 are a group. When custom PWM of 3G series
products, Only when the output frequency is 21KHz,it can be used with other analog group. ).
Special customized PWM -- Output frequency setting
When special customize PWM,don’t need to use the PWM instruction. You only need to set the special register
and then turn on the hardware.
The special registers used for each analog, check below table:
160 https://en.coolmay.com/
High Speed Processing
Analog output
DA0 DA1 DA2 DA3 DA4 DA5 DA6 DA7
address
Duty cycle setting D8050 D8051 D8052 D8053 D8054 D8055 D8056 D8057
PWM division
D8268 D8268 D8268 D8268 D8278 D8278 D8278 D8278
factor setting
D8050-D8057: 0~32760
D8268-D8278: 840~16800000 (32 bits);
When D8268 and D8278are powered on, the default setting is 4000, No data keeping when power off, and program
assignment is required when using.
161 https://en.coolmay.com/
High Speed Processing
Y0,Y1,Y6,Y7,Y10(Optional)], modify
2. 32-bit operation(DPLSR)
Pulses are output from the output (Y D.) by the specified number [S2.+1, S2.] with acceleration/
deceleration to the maximum frequency [S1.+1, S1.] for the time[S3.+1, S3.](ms).
2,147,483,647(PLS)
2,147,483,647(PLS)
162 https://en.coolmay.com/
High Speed Processing
⚫ D.: Pulse output signal, Allowable setting range: 3G: Y0~Y7;2N: Y0~Y3,Y10。
⚫ 2N series:
Y0 Y1 Y6 Y7 Y10
Send end flag M8029 M8029 M8029 M8029 M8029
Position pulse(32bit) D8140 D8142 D8150 D8152 D8154
D8141 D8143 D8151 D8153 D8155
accelerate / decelerate D8148 D8148 D8148 D8148 D8148
time
Pulse stop bit M8145 M8146 M8155 M8156 M8159
Pulse output busy flag M8147 M8148 M8157 M8158 M8161
⚫ 3G series:
Pulse point
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
Function
Description
Send end flag M8029 M8029 M8029 M8029 M8029 M8029 M8029 M8029
Pulse operation M8340 M8350 M8360 M8370 M8151 M8152 M8153 M8154
monitoring
Position D8340 D8350 D8360 D8370 D8140 D8142 D8144 D8160
pulse(32bit) D8341 D8351 D8361 D8371 D8141 D8143 D8145 D8161
D8348 D8358 D8368 D8378 D8148 D8148 D8148 D8148
accelerate / D8349 、 、 、
decelerate time
D8359 D8369 D8379
Pulse stop bit M8349 M8359 M8369 M8379 M8450 M8451 M8452 M8453
Maximum D8343 D8353 D8363 D8373 D8146 D8146 D8146 D8146
speed D8344 D8354 D8364 D8374 D8147 D8147 D8147 D8147
Program
Example
◆ If X0=ON, the PLSR instruction executes the maximum frequency value of pulse output of 1,000Hz, the total
number of pulses output by all pulses D10 and the acceleration and deceleration time of 3,000ms, and then
outputs pulses from Y0. Start to output pulses every time the frequency increases by 1,000/10 Hz. The output
time of each frequency pulse is fixed at 3,000/9.
◆ The output is interrupted when X0 turns OFF, and the pulse count starts from 0 when it turns ON again.
163 https://en.coolmay.com/
Handy Instruction
164 https://en.coolmay.com/
Handy Instruction
This instruction automatically controls the initial state and special auxiliary relays in a step ladder program.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S.
FNC 60 Continuous
D1. 7 steps IST —— ——
IST Operation
D2.
Head bit device number of the selector switch in the operation mode
S. bit
Applicable devices: X, Y, M, D 口.b, modify
mode[D1.<D2.]
Operand D1. bit
mode[D1.<D2.]
D2. bit
165 https://en.coolmay.com/
Handy Instruction
⚫ While the command input is ON, the following devices are automatically switched and controlled.
While the command input is OFF, the devices are not switched.
*1. Cleared when the PLC mode is changed from RUN to STOP.
*2. Set to ON when END instruction is executed
166 https://en.coolmay.com/
Handy Instruction
Program
Example
◆ When the IST instruction is executed, the following special auxiliary relays will be switched automatically.
M8040: STL transfer disable S0: Manual operation initial state step point
M8041: Transfer start S1: Return to origin initial state step point
M8042: Start pulse S2: Automatic operation initial state step point
M8047: Enable STL monitoring
◆ When using the IST instruction, S10~S19 are used for “Return to origin”, and the step point in this state cannot
be used as a general step point. When the step points of S0~S9 are used, the actions of the three state points
of S0~S2 are manual use, return-to-origin use, and automatic operation. Therefore, in the program, you must
write the circuit of the three state step points firstly.
◆ When switching to S1 (Return to origin) mode, if any point between S10~S19 is ON, there will be no action in
“Return to origin”.
◆ When switching to S2 (automatic operation) mode, if any point of S between D1~D2 is ON, or M8043 is ON,
there will be no action in automatic operation.
167 https://en.coolmay.com/
Handy Instruction
This instruction searches for the same data, maximum value and minimum value in a data table.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous Continuous
9 steps SER 17 steps DSER
FNC61 S2. Operation Operation
SER D. Pulse
Pulse (Single)
n SERP (Single) DSERP
D P Operation
Operation
2. 32-bit operation(DSER,DSERP)
In "n" data starting from [S1.+1, S1.], same data as [S2.+1, S2.] is searched, and the search
result is stored to[D.+1, D.] to [D.+9, D.+8].
168 https://en.coolmay.com/
Handy Instruction
Program
Example
◆ If X0=ON, the data block composed of D10~D19 is compared with D0, and the result is stored in D50~D52.
When the equal value does not exist, the contents of D50~D52 are all 0.
◆ The minimum number of all comparison data is recorded in D53, and the maximum value is recorded in D54.
When there is more than one minimum and maximum value, the one with the largest number is recorded.
169 https://en.coolmay.com/
Handy Instruction
This instruction creates many output patterns corresponding to the current value of a counter
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. Instruction Condition Instruction Condition
FNC62 S2. Continuous Continuous
9 steps ABSD 17 steps DABSD
ABSD D. Operation Operation
n
D P
Head device number storing the data table (with rising and faling point data) BIN16/3
S1.
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, modify 2-bit
Counter number for monitoring the current value compared with the data table BIN16/3
S2.
Operand Applicable devices: C, modify 2-bit
Number of lines in the table and the number of output bit devices [1≤n≤64] BIN16-
n
Applicable devices: K, H bit
2. 32-bit operation(DABSD)
In this example, outputs are controlled to ON or OFF by one rotation (0 to 360°)
(using the rotation angle signal of 1°/pulse).
The present value S2. of the counter is compared with the data table having "n" lines starting from
[S1.+1, S1.] (which occupies "n" lines*2 points), and consecutive "n" outputs starting from D. are
controlled to ON or OFF during one rotation.
In DABSD instruction, a high seed counter can be specified as S2. , however, the output pattern
170 https://en.coolmay.com/
Handy Instruction
contains response delay caused by the scan cycle with regard to the current value of a counter.
⚫ When specifying digits of a bit device as S1.,
1) Device number: Specify a multiple of 16 (0, 16, 32, 64 ...).
Program
Example
◆ M10~M13. When X10=ON, the current value of the counter C10 is compared with the upper and lower limits of
4 groups such as D100~D107, and the results are reflected in M10~M13 respectively.
◆ When X10=OFF, the ON/OFF status of the original M10~M13 will not change.
◆ The corresponding M10~M13 within the range of greater than or equal to the lower limit and less than or equal
to the upper limit will be ON.
lower upper limit C10 current
Output
limit value value value
D100=40 D101=100 40≤C10≤100 M10=ON
D102=120 D103=210 120≤C10≤210 M11=ON
D104=140 D105=170 140≤C10≤170 M12=ON
D106=150 D107=390 150≤C10≤390 M13=ON
◆ If the lower limit value is greater than the upper limit value, Then when it is less than the upper limit value
(C10<60) or greater than the lower limit value (C10>140), M12=On.
lower upper limit C10 current
Output
limit value value value
D100=40 D101=100 40≤C10≤100 M10=ON
D102=120 D103=210 120≤C10≤210 M11=ON
D104=140 D105=170 140≤C10≤170 M12=OFF
D106=150 D107=390 150≤C10≤390 M13=ON
171 https://en.coolmay.com/
Handy Instruction
⚫ When specifying digits of a bit device as S1 specify a multiple of 16 (0, 16, 32, 64 ...).
Program
example
172 https://en.coolmay.com/
Handy Instruction
◆ When the command contact turns ON, the output M0 turns ON.
◆ When the current value of C0 reaches the comparison value D300, the output M0 is reset. "1" is added to the
count value of the process counter C1, and the current value of the counter C0 is reset.
◆ The next output M1 turns ON.
◆ When the current value of C0 reaches the comparison value D301, the output M1 is reset. "1" is added to the
count value of the process counter C1, and the current value of the counter C0 is reset.
◆ The current value is compared for up to "n (K4)" outputs in the same way (1 ≤ n ≤ 64).
◆ When the final process specified by "n" is finished, the execution complete flag M8029 turns ON and remains
ON for one operation cycle.M8029 is used for many instructions as the instruction execution complete flag. Use
M8029 as a contact just after a corresponding instruction.
◆ The program execution returns to the beginning, and outputs are repeated.
173 https://en.coolmay.com/
Handy Instruction
This instruction measures the period of time in which TTMR instruction is ON.
Use this instruction to adjust the set value of a timer by a pushbutton switch.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC64 D. Continuous
5 step TTMR ——
TTMR n Operation
⚫ The current value [D. +1] of the pressing and holding time is reset, and the teaching time will not
change any more.
⚫ Two devices are occupied from a device specified as the teaching time. Make sure that these
devices are not used in other controls for the machine.
D. : Teaching time
[D. +1]: Current value of the pressing and holding time
X0
Program
TTMR D0 K0
example
◆ The time the button switch X0 is held down (the ON time of X0) is stored in D1, the multiple of that time is
specified by n, and the number of digits of time is stored in D0. In this way, you can use the button switch to
adjust the timer setting value.
◆ When X0 turns OFF, the content of D1 is reset to 0, but the content of D0 has not changed.
◆ Assuming the ON time of X0 is T seconds, and the relationship between D0, D1 and n is shown in the following
table:
n D0 D1(Unit:
100ms)
K0 (Unit: s) 1xT D1=D0x10
K1 (Unit: 100ms) 10xT D1=D0
K2 (Unit: 10ms) 100xT D1=D0/10
This instruction can easily make off-delay timers, one-shot timers and flicker timers.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S.
FNC65 Continuous
m 7step STMR —— 16-bit binary
STMR Operation
D.
⚫ The timer number specified in this instruction cannot be used in other general circuits (such as OUT
instruction).
⚫ Four devices are occupied from a device specified in D.
175 https://en.coolmay.com/
Handy Instruction
Function
Device
Flicker
D. Off-delay timer Occupied
D.+1 One-shot timer Flicker(a contact)
D.+2 Occupied Flicker(b contact)
D.+3 Occupied flicker(b contact)
⚫ D.、D.+1、D.+3 will turn OFF after the set time. D.+2 and the timer S. are immediately reset.
Program X10
example STMR T0 K50 Y0
◆ When X10 = ON, the STMR instruction specifies timer T0, and the setting value of T0 is 5 seconds.
◆ Y0 is OFF Delay contact: When X10 changes from OFF to ON, Y0 = ON, and when X10 changes from ON to
OFF, Y0 = OFF after a delay of 5 seconds.
◆ When Y1 turns from ON to OFF, Y1 = ON output for 5 seconds.
◆ When Y2 changes from OFF to ON, Y2 will be output once for 5 seconds.
◆ When Y3 changes from OFF to ON, Y3 = ON after a delay of 5 seconds, and when X10 changes from ON to
OFF, Y3 = OFF after a delay of 5 seconds.
◆ Add a b contact of Y3 after conditional contact X10, then Y1 and Y2 can be output as a flashing circuit. When
X10 turns OFF, Y0, Y1 and Y3 turn OFF, and the contents of T10 are reset to 0.
X10 Y3
STMR T10 K50 Y0
176 https://en.coolmay.com/
Handy Instruction
This instruction alternates a bit device (from ON to OFF or from OFF to ON) when the input turns ON.
Operand
instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
FNC66 3 step ALT ——
D. Operation
ALT
Pulse
ALTP
P Operation
⚫ When ALT instruction is used, a specified bit device is alternated in every operation cycle.
To alternate a specified device by turning the command ON or OFF, please use the (pulse operation
type) ALTP instruction
Program
example 1
◆ When X0 goes from OFF → ON for the first time, Y0 = ON. The second time X0 goes from OFF → ON, Y0 =
OFF.
Program
example 2
◆ Use a single switch to control start and stop. At the beginning, M0 = OFF, so Y0 = ON, Y1 = OFF, when X10 is
the first ON / OFF, M0 = ON, so Y1 = ON, Y0 = OFF, when the second ON / OFF, M0 = OFF Therefore, Y0 =
ON and Y1 = OFF.
177 https://en.coolmay.com/
Handy Instruction
This instruction obtains the data which changes between the start value (initial value) and the end value
(target value) over the specified "n" times.
Operand
instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. Instruction Condition Instruction Condition
FNC67 S2. Continuous
9 Step RAMP ——
RAMP D. Operation
n
Explanation of
16-bit operation (RAMP)
function and
When the start value S1. and the end value S2. have been specified and the command input is
operation
set to ON, the value obtained by adding a value divided equally by "n" times to in every
operation cycle is stored to D. .
By combining this instruction and an analog output, the cushion start/stop command can be
output.
⚫ When the power failure holding device (holding area) is specified in D., the command input turns
ON as it is, and when the programmable controller is set to RUN (start), first clear D.
⚫ This is an instruction to find the slope. The slope is linear and has an absolute relationship with the
scanning cycle. Therefore, when using this instruction, the scanning cycle must usually be fixed in
advance.
⚫ Write a prescribed scan time (which is longer than the actual scan time) to D8039 and set M8039
178 https://en.coolmay.com/
Handy Instruction
Program
example
◆ Write the setting value of the start point of the tilt signal to D10 and the setting value of the end point of the tilt
signal to D11 in advance. When X10 = ON, the setting value of D10 moves towards D11 (increases), and the
elapsed time (n = 100 scans) It is stored in D12, and the number of scans is stored in D13.
◆ In the program, first drive M1039 to ON to fix the scan cycle, and then use the MOV instruction to write the
fixed scan cycle setting value to the special data register D1039. Assuming that the value is 30ms, taking the
above program as an example, n = K100, the time from D10 to D11 is 3 seconds (30ms × 100).
◆ During the execution of the instruction, when the start signal X10 turns OFF, the execution of the instruction is
stopped. When X10 turns ON again, the content of D12 is reset to 0 and recalculated.
◆ When M8026 = OFF, M1029 = ON, the content of D12 is reset to the setting value of D10.
179 https://en.coolmay.com/
Handy Instruction
This instruction is suitable for efficient control of the rotary table for putting/taking a product into/out of the
rotary table.
Operand
instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC68 m1 Continuous
9 steps ROTC ——
ROTC m2 Operation
D.
180 https://en.coolmay.com/
Handy Instruction
Operation conditions
1) Rotation detection signal: X→D.
-Provide a 2-phase switch (X000 and X001) for detecting the rotation direction (forward or backward)
of the table and the switch X002 which turns ON when the product No. 0 reaches the port No. 0.
2) The counter S. detects which number of product is located at the port No. 0.
3) Registers specifying the calling condition: +1, +2
a) Set the port No. to be called in S.+1
b) Set the product No. to be called in
4) Number of divisions m1 and number of low-speed sections m2
Specify the number of divisions m1 of the table, and number of low-speed sections m2.
Cautions
⚫ When the command input is set to ON and this instruction is executed, the result will be automatically
output to D.+3~D.+7
When the command input is set to OFF, D.+3~D.+7 are set to OFF accordingly.
For example, when the rotation detection signal (D.~D.+2) is activated 10 times in one division, set a
value multiplied by "10" to each division, port No. to be called and product No. to be called.
As a result, an intermediate value of the division number can be set to a low-speed section.
181 https://en.coolmay.com/
Handy Instruction
This instruction sorts a data table consisting of data (lines) and group data (columns) based on a specified
group data (column) sorted by line in ascending order. This instruction stores the group data (columns) in
serial devices.On the other hand, SORT2 (FNC149) instruction stores the data (lines) in serial devices facilitating the
addition of data (lines), and sorts a table in either ascending or descending order.
Operand
instruction Function
type
16-bit Operation 32-bit Operation
S. Mnemonic Mnemonic
Instruction Condition Instruction Condition
m1
FNC69 Continuous
m2 11steps SORT ——
SORT Operation
D.
n
Cautions
⚫ Do not change the contents of operands and data while the instruction is executed.
⚫ Before executing the instruction again, set the command input to OFF.
⚫ Only one instruction can be used in a program.
182 https://en.coolmay.com/
Handy Instruction
Program
example
◆ When X0 = ON, specify to execute the data sorting job. When sorting is completed, M8029 = ON. Please do
not change the contents of the sorted data during the execution of the instruction. If you want to reorder the
data, please turn off and turn on X0 again.
183 https://en.coolmay.com/
Handy Instruction
184 https://en.coolmay.com/
External I/O
External I/O
Support Model
FNC
Mnemonic Function 3G series 2N series
NO. MX2N series PLC
PLC PLC
70 TKY Number key input ★
Hexadecimal numeric key
71 KHY ★
input
72 DSW Digital switch ★
77 PR ASCII print ★
185 https://en.coolmay.com/
External I/O
This instruction sets data to timers and counters through inputs of the ten keys from "0" to "9".
Operand
instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S.
FNC70 Continuous Continuous
D1. 7steps TKY 13 steps DTKY
TKY Operation Operation
D2.
D
Head bit device number from which one of the ten keys is input [10
S. devices are occupied] bit
Target Device: X, Y, M, S, D. b, retouch
Word device number storing the data
Operand D1. BIN16/32bit
Target Device: KnY, KnM, KnS, T, C, D, R, V, Z, retouch
Head bit device number storing the key pressing information [11
D2. devices are occupied] bit
Target Device: X, Y, M, S, D. b, retouch
1) Numeric value D1.when an input value is larger than "9999", it overflows from the most significant
digit.
2. 32-bit operation(DTKY)
[D1.+1, D.] store a numeric value input from[S.~S.+9] connected to the ten keys. Output
informations for key pressing and key sensing are output to D2.~D2. +10
1) Numeric value D1.when an input value is larger than "9999", it overflows from the most significant
digit.
⚫ An input numeric D1. value is stored in the binary format.
- For the key pressing information, D2.~D2.+9 turn ON or OFF according to the pressed keys.
- D2.+10 is ON while either one among "0" to "9" keys is pressed (key sensing output).
⚫ When two or more keys are pressed at the same time, only the first key pressed is valid.
⚫ Though the contents of D1. do not change, all of D2.~D2.+10 turn OFF.
186 https://en.coolmay.com/
External I/O
- D2.~D2.+9: Turn ON or OFF according to input of the ten keys "0" to "9".
- D2.+10: Is ON while either one among "0" to "9" keys is pressed (key sensing output).
Program X0
example TKY X0 D0 M10
◆ The command specifies that the 10 input terminals starting with X0 are connected to 10 keys from 0 to 9. When
X20=ON, the command is executed, and the value entered by the keyboard is stored in D0 in the form of BIN
value, and the key is placed in M10~M19.
◆ When the ten keys are pressed in the order "[1] → [2] →[3] → [4]" shown in the figure, "5301" is stored in (D0).
When an input value is larger than "9999",when the number exceeds 4 digits, it overflows from the most
significant digit.
◆ When X2 is pressed, M12 turns ON and remains ON until another key is pressed. Other keys work in the same
way.
◆ When any key among X0~X11 is pressed, one of M10~M19 corresponds to ON.
◆ When pressing a key, M20=ON.
◆ When conditional contact X20 turns OFF, the value before D0 does not change, but all M10~M20 turn OFF.
187 https://en.coolmay.com/
External I/O
This instruction allow 16 key (0 to F) 4-digit (byte) input. Keys 0 to 9 stores numerical values, and keys A to F
represent function keys. When the extension function is set to ON, hexadecimal keys 0 to F all store their
corresponding numerical values.
Operand
instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC71 D1. Continuous Continuous
9 steps HKY 17 steps DHKY
HKY D2. Operation Operation
D3.
D
When a key A to F is pressed, the corresponding key press information bit [D3.~D3.+5] turns ON,
1) When an input value D2.、D3.+7 is larger than "9999", it overflows from the most significant digit.
2. 32-bit operation(DHKY)
Signals [S.~S.+3] and [D1.~D1.+3] connected to the 16 key input (0 to F) are scanned.
When a key 0 to 9 is pressed, the corresponding numeric value is shifted into [D2.+1, D2.] from the
least significant byte, and D3.+7 turns ON.
When a key A to F is pressed, the corresponding key press information bit[D3.~D3.+5] turns ON.
1) When an input value [D2.+1、D2.]、D3.+7 is larger than "99,999,999", it overflows from the most
188 https://en.coolmay.com/
External I/O
significant digit.
- The key sensing output D3.+6 turns ON when any key A to F is pressed.
⚫ When two or more keys are pressed at the same time, the first key pressed is valid.
189 https://en.coolmay.com/
External I/O
Program
example
◆ The instruction specifies 4 input terminals such as X0~X3 and 4 input terminals such as Y0~Y3 to form a
keyboard for scanning 16 keys. When X4=On, the instruction is executed, and the value input by the keyboard
is stored in D0 in the form of BIN value, and the key is placed in M0~M7.
◆ Digital input:
⓪①②③④⑤⑥⑦⑧⑨
BCD
One digit BCD code
value
BCD
value
↓
BIN
D0
value
190 https://en.coolmay.com/
External I/O
◆ External wiring:
191 https://en.coolmay.com/
External I/O
- The first set is stored to D2. , and the second set is stored to D2.+1.
- When using one set of 4 digits [n = k1] A 4-digit BCD digital switch connected to S.~[S.+3] is
read in turn by the strobe signal D1.~[D1.+3], and stored in the binary format to D2.
- When using two sets of 4 digits [n = k2],A 4-digit BCD digital switch connected to S.~[S.+3]
is read in turn by the strobe signal D1.~[D1.+3], and stored in the binary format to D2.
A 4-digit BCD digital switch connected to S.+4~[S.+7] is read in turn by the strobe signal
⚫ When the command contact turns OFF. Though the contents of D2. do not change, all of D1.~
Program
example
◆ The first group of DIP switch circuits is composed of X10~X13 and Y10~Y13, and the second group of DIP
switch circuits is composed of X14~X17 and Y10~Y13. When X0=On, the instruction starts to execute, the
192 https://en.coolmay.com/
External I/O
setting value of the first group of dial switches is read and converted into BIN value and stored in D0, and the
setting value of the second group of digital switches is read and converted into BIN value and stored To D1.
◆ While X000 is ON, Y010 to Y013 turn ON in turn at every 100 ms. After one cycle is finished, the execution
complete flag M8029 turns ON.
◆ During the period when X0 is ON, Y10~Y13 will turn ON in sequence every 100ms. After the loop operates once,
the end flag M8029 will be executed.
◆ Connection diagram
1) While M0 (digital switch read input) is ON, DSW (FNC 72) is driven.
2) DSW (FNC 72) completes one cycle of operation, and remains driven until the execution complete flag (M8029)
turns ON.
193 https://en.coolmay.com/
External I/O
This instruction decodes data, and turns the seven-segment display unit (1 digit) ON.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps SEGD ——
FNC73 S. Operation
SEGD D. Pulse
SEGDP (Single)
P
Operation
⚫ The number of occupied points of the device, low-order 8 bits of D. are occupied, and high-order 8
bits do not change.Seven-segment decoding table:
S. Seven D.
Hexadeci- segment
Display
mal num- b3~b0 Configurati- ... B7 B6 B5 B4 B3 B2 B1 B0
data
ber on
0 0000 ... 0 0 1 1 1 1 1 1
1 0001 ... 0 0 0 0 0 1 1 0
2 0010 ... 0 1 0 1 1 0 1 1
3 0011 ... 0 1 0 0 1 1 1 1
4 0100 ... 0 1 1 0 0 1 1 0
5 0101 ... 0 1 1 0 1 1 0 1
6 0110 ... 0 1 1 1 1 1 0 1
7 0111 ... 0 0 1 0 0 1 1 1
194 https://en.coolmay.com/
External I/O
8 1000 ... 0 1 1 1 1 1 1 1
9 1001 ... 0 1 1 0 1 1 1 1
A 1010 ... 0 1 1 1 0 1 1 1
B 1011 ... 0 1 1 1 1 1 0 0
C 1100 ... 0 0 1 1 1 0 0 1
D 1101 ... 0 1 0 1 1 1 1 0
E 1110 ... 0 1 1 1 1 0 0 1
F 1111 ... 0 1 1 1 0 0 0 1
Program
example
⚫ When X10=ON, the contents (0~F: hexadecimal) of the lower 4 bits (b0~b3) of D10 are decoded into 7-segment
display output, and the decoding result is temporarily stored in Y10~Y17. If the specified data exceeds 4 bits, the
contents of the 4 bits are still removed for decoding.
This instruction controls one or two sets of 4-digit seven-segment display units having the latch function.
16-bit
Instruction Function
Instruction
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S.
FNC74 Continuous
D. 7 steps SEGL ——
SEGL Operation
n
195 https://en.coolmay.com/
External I/O
turn from D.~[D.+3] in the time division method. The strobe signal is output in turn from [D.+4]~
[D.+7]in the time division method also to latch one set of 4-digit seven-segment display unit.
2) For S. , binary data in the range from 0 to 9999 is valid.
output in turn from D.~[D.+3] in the time division method.The strobe signal is output in turn
from [D.+4]~[D.+7] in the time division method also to latch the first set of 4-digit seven-
output in turn from D.+10~D.+13 in the time division method.The strobe signal is output in turn
fromD.+4~D.+7 in the time division method also to latch the second set of 4-digit seven-
segment display unit. (The strobe signal outputs D.+4~D.+7 are shared by the 1st and 2nd
sets.)
2) For S. and S.+1, binary data in the range from 0 to 9999 is valid.
⚫ It is determined by n to scan and output 4-digit seven-segment display with 1 set or 2 sets, and n
is also used to specify the positive and negative logic output of PLC output.
⚫ The scan time (operation cycle) multiplied by 12 is required to update (one or two sets of) the 4-
digit display.
⚫ When the command contact is set to OFF in the middle of an operation, the operation is paused.
When the command contact is set to ON again, the operation is started from the beginning.
⚫ Number of occupied devices
When one set of 4 digits is used: 1 device is occupied from the head device specified in S.
8 devices are occupied from the head device specified in D.
When two sets of 4 digits are used: 2 devices are occupied from the head device specified in S.
12 devices are occupied from the head device specified in D.
Note: Even if the number of digits is small, the occupied points cannot be used for other purposes.
X1
Program 0
example SEGL D10 Y10 K4
196 https://en.coolmay.com/
External I/O
◆ When X10=ON, the instruction starts to be executed, and Y10~Y17 form a seven-segment display scanning
circuit. The value in D10 is converted into BCD code and sent to the first group of seven-segment display. The
value in D11 is converted into BCD The code is sent to the second group of seven-segment displays and
displayed. If the value in D10 or D11 exceeds 9,999, an operation error will occur.
◆ When X10=ON, Y14~Y17 will automatically scan cyclically. Each scan cycle needs 12 scan cycles, and the scan
completion flag signal M9029=ON for one scan cycle.
◆ Seven-segment display units wiring details
197 https://en.coolmay.com/
External I/O
This instruction inputs data through arrow switches used for shifting the digit and incrementing/decrementing the
numeric value in each digit.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC75 D1. Continuous
9 steps ARWS ——
ARWS D2. Operation
n
D1. actually stores a 16-bit binary value in the range from 0 to 9999
1) Specifying the number of digits of the seven-segment display unit having the BCD decoder n
In the explanation below, "n" is set to "4" (up to the 103 digit).
Every time the lower digit switch is pressed, the digit specification changes in the way
103→102→101→100→103
Every time the higher digit switch is pressed, the digit specification changes in the
wa103→100→101→102→103
A specified digit can be displayed by the LED offered by the strobe signals D2.+4~D2.+7
198 https://en.coolmay.com/
External I/O
In a digit specified by a digit selection switch described above, data is changed as follows:
Every time the increment switch is pressed, the contents of D1. change in the way
0→1→2→…→8→9→0→1
Every time the decrement switch is pressed, the contents of D1. change in the way
0→9→8→7…1→0→9
The contents can be displayed in the seven-segment display unit.
As described above, a target numeric value can be written to D1.using a series of operation while
looking at the seven-segment display unit.
Program
example
addition
Digit indication
LED
Move left
Move right
subtraction
seven-segment showing 4-digit setting values 4 switches are used to move the left and right
and the addition and subtraction
of the set value
◆ This instruction is executed, X20 is defined as the down key, X21 is defined as the up key, X22 is defined as the
right key, X23 is defined as the left key, and the operation and display of the external set value are performed by
using the up, down, left and right keys. Store the setting value in D20, setting value range: 0~9,999.
◆ When X10=ON, the command start digit 103 is the effective setting digit. If the left button is pressed, the effective
setting digit will show a cycle of 103→1000→101→102→103→1000.
◆ If you press the right shift button, the effective setting bit will show the direction of
199 https://en.coolmay.com/
External I/O
103→102→101→100→103→102 cyclically jumping. Simultaneously with the cycle, the digit indicator connected
by Y24~Y27 is also cycled to indicate the effective digit setting.
◆ If you press the up button, the content of the effective setting digits will change from 0→1→2→…8→9→0→1. If
the down button is pressed, the content of the effective setting digits changes from 0→9→8→...1→0→9. At the
same time, the changed value is also displayed on the seven-segment display.
This instruction converts a half-width alphanumeric character string into ASCII codes. Use this instruction for
selecting one among two or more messages and displaying it on an external display unit.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC76 S. Continuous
11 steps ASC ——
ASC D Operation
⚫ Related devices
200 https://en.coolmay.com/
External I/O
⚫ ARWS instruction can be used only once in a program. When ARWS instruction should be used
two or more times, use the indexing (V, Z) function.
Program
example
201 https://en.coolmay.com/
External I/O
Character string
Head device number storing ASCII code data
S. (only ASCII
Target Device: T, C, D, R, retouch
Operand codes)
Head output (Y) number to which ASCII code data is output
D. 16-bit binary
Target Device: Y, retouch
Explanation of 16-bit operation(PR)
function and ASCII codes stored in low-order 8 bits (1 byte) of S.~S.+7 are output to D.~D.+7 in turn by
operation
one character at a time in the time division method.
⚫ Related devices
Device Name Content
M8027 OFF:8-byte serial output (fixed to 8 characters)
PR model
(from RUN→STOP clear) ON :16-byte serial output (1 to 16 characters)
⚫ While the command input is ON: Even if the command input is continuously ON or if the pulse
operation type instruction is used, execution is completed after a series of outputs. M8029 turns
ON only while M8027 is ON. While the command input is OFF:The output is all OFFARWS
instructions, and only one can be used in the program. To use more than one, please use the
index modification (V, Z) function programming.
⚫ This instruction is executed in synchronization with the scan time.
If the scan time is short, the constant scan mode can be used. If the scan mode is too long, the
timer interrupt function can be used.
⚫ When "00H (NUL code)" is contained in the data (while M8027 is ON).The instruction is executed
completely, and the data after "00H" is not output. M8029 remains ON during one operation cycle.
Program
example 1
202 https://en.coolmay.com/
External I/O
X10 Start
signal
Y10~Y17dat
a
Y21 Execution
◆ When M8027=OFF and X10=ON change, the instruction is executed, Y10 (low bit) ~ Y17 (high bit) is
designated as the data output point, the scan signal is designated Y20, and the monitoring signal during
execution is designated as Y21. This mode can perform sequential output of 8 words. And during the output, if
the conditional contact is OFF, the data output will be stopped immediately, and all the outputs will be turned
OFF.
◆ When X10 turns OFF during the execution of the instruction, the data output is interrupted, and when X10 turns
ON again, the data is sent again.
M8002
Program SET M8027
example 2
X10
PR D0 Y10
data
T:Operation cycle or interrupt time:
T T
T
Y20 scan signal
Y21 Execution
M8029 Finished
◆ PR instruction is a serial output instruction with 8 bits. When special auxiliary relay M8027=Off, it can execute a
serial output of up to 8 words. When M8027=ON, it can execute a serial of 1~16 output.
◆ When M8027=ON, X10 changes from OFF→ON, the instruction is executed, Y10 (low bit) ~ Y17 (high bit) is
designated as the data output point, the scan signal is designated Y20, and the monitoring signal during
execution is designated Y21. This mode can perform sequential output of 16 words. And during the output, if
the conditional contact is OFF, it will stop after the data output is completed.
◆ If 00H (NUL) is encountered in the character string, it means the end of the character string, and then the text
will not be processed.
◆ When conditional contact X10 is ON→OFF, the data output automatically stops after one cycle. However, if X10
is always ON, M8029 will not operate.
203 https://en.coolmay.com/
External I/O
This instruction reads the contents of buffer memories (BMF) in a special extension unit/block attached to a PLC.
When a large capacity of buffer memory (BFM) data is read by this instruction, a watchdog timer error may occur.
When bad effect is not given to the control even if data to be read is divided, use RBFM (FNC278) instruction.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
m1
Continuous Continuous
FNC78 m2 9 steps FROM 17 steps DFROM
Operation Operation
FROM D.
Pulse (Single) Pulse (Single)
n FROMP DFROMP
D P Operation Operation
2. 32-bit operation(DFROM、DFROMP)
"n" 32-bit data starting from the buffer memory (BFM) # [m2+1、m2] inside a special extension
unit/block No.m1 are transferred (read) to "n" devices starting from [D.+1、D.] inside a PLC.
⚫ Related devices
204 https://en.coolmay.com/
External I/O
Program
example
◆ Read out the contents of BFM#29 of expansion module number 0 into D0 of PLC, and read out the contents of
BFM#30 into D1, and read two strokes at a time (n=2).
◆ When X0=ON, the instruction is executed. When X0 turns OFF, the instruction is not executed, and the content
of the previously read data has not changed.
This instruction writes data from a PLC to buffer memories (BFM) in a special extension unit/block.
When a large capacity of data is written to buffer memories (BFM) by this instruction, a watchdog timer error
may occur. When splitting the data to be written does not affect the control, use WBFM (FNC279) instruction.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
m1 Continuous Continuous
9 steps TO 17 steps DTO
FNC79 m2 Operation Operation
TO S. Pulse
Pulse (Single)
n TOP (Single) DTOP
D P Operation
Operation
205 https://en.coolmay.com/
External I/O
2. 32-bit operation(DTO、DTOP)
n"-point 32-bit data starting from[S., S.+1] inside a PLC are transferred (written) to "n"-point buffer
memories starting from the buffer memory (BFM) # [m2+1, m2] inside a special extension
unit/block No. m1.
⚫ Related devices
Device Name Content
OFF: Disables interrupts.(Interrupts are executed after
M8028 Enable interrupt flag FROM/TO instruction is executed.)
ON : Enables interrupts.
⚫ Digit specification in bit device S.
For the 16-bit operation instruction, specify K1 to K4. For the 32-bit operation instruction, specify
K1 to K8.
⚫ Note that when D and R are designated as m1, m2, and n of a 32-bit instruction, the 32-bit values
of [m1+1, m1], [m2+1, m2] [n+1, n] become effective.
For example: DTO D0 D2 D100 R0, then m1=[D1, D0], m2=[D3, D2], n=[R1, R0].
Program
example
◆ Using the 32-bit instruction DTO, the action of the program is to write the contents of D11 and D10 into BFM#13
and BFM#12 of the expansion module with the number 0, and write only one sum at a time (n=1).
◆ When X0=ON, the instruction is executed. When X0 turns OFF, the instruction is not executed and the written
data remains unchanged.
206 https://en.coolmay.com/
External Device SER
207 https://en.coolmay.com/
External Device SER
This instruction sends and receives data in no-protocol communication by way of a serial port (only the ch1) in
accordance with RS-232C or RS-485 provided in the main unit.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC 80 m Continuous
9 steps RS —
RS D. Operation
n
⚫ Related devices
Device Name Device Name
Serial
M8063 communication D8120 Communication format setting
error 1
Remaining number of data to
M8121 Sending wait flag D8122
be sent
Monitor for number of received
M8122 Sending request D8123
data
Receiving
M8123 D8124 Header
complete flag
Carrier detection
M8124 D8125 Terminator
flag
208 https://en.coolmay.com/
External Device SER
Time-out check
M8129 D8129 Time-out time setting
flag
8-bit processing Error code number of serial
M8161 D8063
mode communication error 1
❖ For detailed configuration and case description, please refer to 2N series PLC/MX2N series PLC/3G
series PLC programming manual
This instruction handles the device number of S. with digit specification and the device number of D.
as octal numbers, and transfers data.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps PRUN 9 steps DPRUN
FNC 81 S. Operation Operation
PRUN D. Pulse
Pulse (Single)
PRUNP (Single) DPRUNP
D P Operation
Operation
Digit specification
S. 16/32-bit binary
Target Device: KnX, KnM, retouch
Operand
Device number of transfer destination
D. 16/32-bit binary
Target Device: KnY, KnM, retouch
2. 32-bit operation(DPRUN、DPRUNP)
209 https://en.coolmay.com/
External Device SER
X3
Program
example PRUN K4X10 K4M10
no change
210 https://en.coolmay.com/
External Device SER
2. 16-bit conversion mode (while M8161 is OFF) (M8161 is also used for the RS, HEX, CCD and
CR instructions.)
Each digit of hexadecimal data stored in S. and later is converted into ASCII code, and transferred
to the high-order 8 bits and low-order 8 bits of each device D. and later. The number of digits
(characters) to be converted is specified by "n".
3. 8-bit conversion mode (while M8161 is ON) (M8161 is used also for the RS, HEX, CCD and
CRC instructions.)
Each digit of hexadecimal data stored in S. and later is converted into an ASCII code, and
transferred to low-order 8 bits of each device D. and later. The number of digits (characters) to be
converted is specified by "n". "0" is stored in high-order 8 bits of each device D. and later.
M8001
M8161
Program
example 1 X0
ASCI D10 D20 K4
211 https://en.coolmay.com/
External Device SER
M8000
M8161
Program
example 2 X0
ASCI D10 D20 K4
212 https://en.coolmay.com/
External Device SER
This instruction converts ASCII codes into hexadecimal codes. On the other hand, DABIN (FNC260) instruction
converts ASCII codes into binary data, and EVAL (FNC117) instruction converts ASCII codes into binary floating
point data.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC 83
D. 7 steps HEX Continuous —
HEX
n HEXP Operation
P
Character
Head device number storing ASCII code to be converted string
S.
Target Device: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, retouch (only ASCII
code)
Operand
Head device number storing converted hexadecimal code
D. 16/32-bit binary
Target Device: KnY, KnM, KnS, T, C, D, R, retouch
Number of ASCII codes (bytes) to be converted [setting range: 1 to 256]
n 16-bit binary
Target Device: D, R, K, H
213 https://en.coolmay.com/
External Device SER
2. 16-bit conversion mode (while M8161 is OFF) (M8161 is used also for the RS, ASCI, CCD,
and CRC instructions.)
Each ASCII code stored in high-order 8 bits and low-order 8 bits of devices S. and later is
converted into a hexadecimal code, and transferred to devices D. and later in units of 4 digits. The
number of characters to be converted is specified by "n".
3. 8-bit conversion mode (while M8161 is ON) (M8161 is used also for the RS, ASCI, CCD and
CRC instructions.)
Each ASCII code stored in the low-order 8 bits of each device S. and later is converted into a
hexadecimal code, and transferred to device D. and later in 4-digits units. The number of
characters to be converted is specified by "n".
Program
example 1
214 https://en.coolmay.com/
External Device SER
Program M8000
example 2
M8161
X0
HEX D20 D10 K4
215 https://en.coolmay.com/
External Device SER
This instruction calculates the horizontal parity value and sum check value in the error check methods used in
communication. There is another check method, CRC (cyclic redundancy check) also. For obtaining CRC value,
use CRC instruction.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S. Instruction Condition Instruction Condition
FNC 84
D. 7 steps CCD Continuous —
CCD
n CCDP Operation
P
2. 16-bit conversion mode (while M8161 is OFF) (M8161 is also used for the RS, ASCI, HEX and
CRC instructions.)
With regard to "n" data starting from S. , the addition data and horizontal parity data of high-order
8 bits and low-order 8 bits are stored to D. and D.+1 respectively.
3. 8-bit conversion mode (while M8161 is ON) (M8161 is used also for the RS, ASCI, HEX and
CRC instructions.)
With regard to "n" data starting from S. , the addition data and horizontal parity data of only low-
order 8 bits are stored to D. and D.+1 respectively.
M8001
M8161
Program
example 1 X0
CCD D0 D100 K6
216 https://en.coolmay.com/
External Device SER
D0 high K111=0110111①
D1 Low K120=01111000
D1 high K202=11001010
D2 Low K123=0111101①
When the number of "1" is odd, the
horizontal parity is "1"
D2 high K211=1101001①
When the number of "1" is even, the
horizontal parity is "0".
D100(sum) K867
D101 0001000①
Program M8000
example 2
M8161
X0
CCD D0 D100 K6
D0 high K111=0110111①
D1 Low K120=01111000
D1 high K202=11001010
D2 Low K123=0111101①
When the number of "1" is odd, the
horizontal parity is "1"
D2 high K211=1101001① When the number of "1" is even, the
horizontal parity is "0".
D100(sum) K867
D101 0001000①
◆ When X0=ON, the contents of the 6 data starting from the starting number of the register specified by D0 (in 8-
bit units n=6 represents the specified D0~D5) are added up, and the totalization result is stored in the specified
by D100 In the register, the level check is stored in D101.
This instruction sends and receives data in no-protocol communication by way of serial ports in accordance with
RS-232C or RS-485 provided in the main unit.
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
S. Mnemonic Mnemonic
Instruction Condition Instruction Condition
m
FNC 87 Continuous
D. 11 steps RS2 —
RS2 Operation
n
n1
⚫ Related devices
Device Device Name
Name
ch2 ch3 CAN Ch 2 Ch 3 CAN
Communication
M8122 M8402 M8422 Sending request D8120 D8400 D8420
format setting
Receiving Communication
M8123 M8403 M8423 D8121 D8401 D8421
complete flag mode
Remaining points
M8124 M8404 M8424 Data receiving D8122 D8402 D8422
of sent data
218 https://en.coolmay.com/
External Device SER
D8412、 D8432、
D8125 Footer
D8413 D8433
D8129 D8409 D8429 Set timeout
D8063
❖ For detailed configuration and case description, please refer to 2N series PLC/MX2N series PLC/3G
series PLC programming manual
This instruction executes PID control which changes the output value according to the input variation. (Coolmay
PLC supports step response method)
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. Instruction Condition Instruction Condition
FNC 88 S2. Continuous
9 steps PID —
PID S3. Operation
D.
219 https://en.coolmay.com/
External Device SER
2. Set items
Number of
Set item Content occupied
points
Target value Set the target value (SV).
S1. 1
(SV) PID instruction does not change the contents of setting.
Measured
S2. This is the input value in PID control loop 1
value (PV)
Auto tuning: In the case of limit cycle method
a)Operation setting (ACT): When bits 1, 2 and 5 are not all "0" 25
S3. Parameter Twenty-five devices are occupied from the head device specified in S3.
b)Operation setting (ACT): When bits 1, 2 and 5 are all "0" 20
Twenty devices are occupied from the head device specified in S3.
Auto tuning: In the case of step response method
Output value
D. Before driving PID instruction, the user should set the initial output value. 1
(MV)
During auto tuning, PID instruction does not change the MV output.
220 https://en.coolmay.com/
External Device SER
221 https://en.coolmay.com/
External Device SER
⚫ Two or more PID instructions can be executed at the same time. (There is no limitation in the
number of
loops.) However, make sure that S3. , D. and other operands specified in each instruction are
different to each other.
⚫ Number of devices occupied for parameters starting from S3.: In the step response method
1) Operation setting (ACT): When bits 1, 2 and 5 are not all "0"
Twenty-five devices are occupied from the head device specified in S3.
2) Operation setting (ACT): When bits 1, 2 and 5 are all "0"
Twenty devices are occupied from the head device specified in S3.
❖ 2N series PLC supports PID, but it does not support auto-tuning, you need to manually adjust the parameters.
❖ More procedures please refer to the official website Demos of 3G PLC PID Automatic Tuning and 2N PLC PID
output 300℃
222 https://en.coolmay.com/
Data Transfer 2
Data Transfer 2
223 https://en.coolmay.com/
Data Transfer 2
This instruction temporarily batch-stores the present value of the index registers V0 to V7 and Z0 to Z7.
For restoring the present value of temporarily batch-stored index registers, use ZPOP (FNC103) instruction.
Operand
Instruction Function
Type
16-bit Operation 16-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
3 steps ZPUSH —
FNC102 Operation
D.
ZPUSH Pulse
ZPUSHP (Single) —
P
Operation
storage destination
Target Device: D, R
224 https://en.coolmay.com/
Data Transfer 2
⚫ When not using the nest structure, clear the number of batch-storage times D. before executing
ZPUSH (FNC102) instruction.
⚫ When using the nest structure, clear the number of batch-storage times D. before executing
ZPUSH (FNC102) instruction the first time.
Program
example 2
225 https://en.coolmay.com/
Data Transfer 2
This instruction restores the contents of the index registers V0 to V7 and Z0 to Z7 which were batch-stored
temporarily by ZPUSH (FNC102) instruction.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
3 steps ZPOP —
FNC103 Operation
D.
ZPOP Pulse
ZPOPP (Single) —
P
Operation
storage destination
Target Device: D, R
1) The contents of the index registers V0 to V7 and Z0 to Z7 which were batch-stored temporarily
to D. and later are restored to the original index registers. When the contents of the index
registers are restored, the number of times of batch-storage D. is decremented by "1".
2) For temporarily batch-storing the data, use ZPUSH (FNC102) instruction.
Use ZPUSH (FNC102) and ZPOP (FNC103) instruction as a pair.
⚫ When there is no nesting action, please clear the batch save times D. before executing the
ZPUSH (FNC 102) instruction.
⚫ When there are nested actions, please clear the batch save times D. before the first execution.
226 https://en.coolmay.com/
Floating Point
Floating Point
Supported Model
FNC NO. Mnemonic Function
3G PLC 2N PLC MX2N PLC
110 ECMP Floating Point Compare ★ ★ ★
227 https://en.coolmay.com/
Floating Point
This instruction compares two data (binary floating point), and outputs the result (larger, same or smaller) to
three single bit devices.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous
FNC110 — 13 steps DECMP
S2. Operation
ECMP
D. Pulse (Single)
DECMPP
D P Operation
Device number storing binary floating point data to be compared Real number
S1.
Target Device: D, R, K, H, E, retouch (binary)
Device number storing binary floating point data to be compared Real number
S2.
Operand Target Device: D, R, K, H, E, retouch (binary)
Head bit device number to which the comparison result is output (Three
D. devices are occupied.) bit
Target Device: Y, M, S, retouch
Even if the command input turns OFF and DECMP instruction is not executed, D.~D.+2
converted from binary into binary floating point (real number) when the instruction is executed.
228 https://en.coolmay.com/
Floating Point
Program
example
This instruction compares data (binary floating point) with two values (one zone), and outputs the comparison
result to three single bit devices.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1.
Continuous
FNC111 S2. — 17 steps DEZCP
Operation
EZCP S.
Pulse (Single)
D. DEZCPP
D P Operation
Data register number storing binary floating point data to be compared Real number
S1.
Target Device: D, R, K, H, E, retouch (binary)
Data register number storing binary floating point data to be compared Real number
S2.
Target Device: D, R, K, H, E, retouch (binary)
Operand Data register number storing binary floating point data to be compared Real number
S.
Target Device: D, R, K, H, E, retouch (binary)
Head bit device number to which the comparison result is output (Three
D. devices are occupied.) bit
Target Device: Y, M, S, retouch
Explanation of 32-bit operation(DEZCP、DEZCPP)
function and
The comparison values [S1.+1, S1.]、[S2.+1, S2.] are compared with the comparison source
operation
229 https://en.coolmay.com/
Floating Point
[S.+1, S.] as floating point data, and either bit amongD.、D.+1、D.+2 turns ON according to
Even if the command input turns OFF and DEZCP instruction is not executed, D.~D.+2
⚫ When the constants (K, H) are specified in [S1.+1, S1.], [S2.+1, S2.], [S.+1, S.], the value is
automatically converted from BIN to 2. After processing the floating point number, process it.
⚫ Three devices are occupied from [D., D.+1, D.+2]
⚫ Make sure that two comparison values have the following relationship:[S1.+1, S1.]≦[S2.+1, S2.]. In
the case of [S1.+1, S1.]>[S2.+1, S2.], the value [S2.+1, S2.] is regarded as [S1.+1, S1.] value
during comparison
Program
example
◆ The designated device is M0, which automatically occupies M0~M2. To clear the comparison result, use the
RST or ZRST instruction.
◆ When X0=ON, the DEZCP instruction is executed, and one of M0~M2 turns ON; when X0=OFF, the DEZCP
instruction is not executed, and the state of M0~M2 remains in the state before X0=OFF.
230 https://en.coolmay.com/
Floating Point
Binary floating point data (transfer source) or device number storing data Real number
S.
Target Device: D, R, E, retouch (binary)
Operand
Device number receiving floating point data Real number
D.
Target Device: D, R, retouch (binary)
Program
example
◆ When X0=OFF, the content of (D11, D10) does not change. If X0=ON, the current value of E3.1415926 floating
point number is transferred to the (D11, D10) data register.
231 https://en.coolmay.com/
Floating Point
This instruction converts binary floating point data into a character string (ASCII codes) having a specified
number of digits.
On the other hand, STR (FNC200) instruction converts binary data into a character string (ASCII codes).
Operand
Instruction Function
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous
FNC116 — 13 steps DESTR
S2. Operation
ESTR
D. Pulse (Single)
DESTRP
D P Operation
Binary floating point data to be converted or device storing data Real number
S1.
Target Device: D, R, E, retouch (binary)
Head device number storing the display specification of a numeric
Operand S2. value to be converted 16-bit binary
Target Device: KnX, KnY, KnM, KnS, T, C, D, R, retouch
Head device number storing converted character string Character
D.
Target Device: KnY, KnM, KnS, T, C, D, R, retouch string
232 https://en.coolmay.com/
Floating Point
digits - 3)"
3. In the case of exponent format
1) The total number of digits which can be specified byS2.+1 is as follows (24 digits maximum):
When the number of digits of the decimal part is "0" Total number of digits ≥ 6
When the number of digits of the decimal part is any value other than "0" Total number of
digits ≥ (Number of digits of decimal part + 7)
2) The number of digits of the decimal part which can be specified by S2.+2 is from 0 to 7.
However, the following must be satisfied, "Number of digits of decimal part ≤ (Total number of
digits - 7)"
Program
example 1
◆ When X0=ON, the contents of D0 and D1 (binary floating point data) are converted according to the contents
specified in D10 to D12, and the program stored in the device after D100 is converted.
D1 Conversion
0 Total number of digits b15————b8 b7————b0
0 form
D1 D100
3 All digits 0 . 0 3 3 20H(space) 20H(space)
1
D1 Decimal Em Decimal
7 D101 2EH(.) 30H(0)
2 places pty
Quantile D102 33H(3) 30H(0)
D0=0.0327457 D103 00H 33H(3)
Program
example 2
◆ When X0=ON, the contents of D0 and D1 (binary floating point data) are converted according to the contents
specified in D10 to D12, and the program stored in the device after D100 is converted.
D1 Conversion
1 ←Total number of digits→ b15————b8 b7————b0
0 form
D1 1
All digits 3 . 2 7 4 6 E - 0 2 D100 20H(space) 20H(space)
1 2
D1 Decimal Em Decimal D101
4 2EH(.) 33H(3)
2 places pty Quantile
D102 37H(7) 32H(2)
D0=0.0327457 D103 36H(6) 34H(4)
D104 2DH(-) 45H(E)
D105 32H(2) 30H(0)
D106 0000H
233 https://en.coolmay.com/
Floating Point
This instruction converts a character string (ASCII codes) into binary floating point data.
On the other hand, the VAL (FNC201) instruction converts a character string (ASCII codes) into binary data.
Instruction Operand
Function
format Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC Continuous
S. — 9 steps DEVAL
117 Operation
D.
EVAL Pulse
DEVALP
D P Operation
Head device number storing character string data to be converted into binary
S. floating point data Character string
Operand Target Device: KnX, KnY, KnM, KnS, T, C, D, R, retouch
Head device number storing converted binary floating point data Real number
D.
Target Device: D, R, retouch (binary)
Explanation 1. 32-bit operation(DEVAL, DEVALP)
of function A character string stored in and later is converted into binary floating point, and stored to [ D.+1, D.]
and
operation
⚫ A specified character string may be in the decimal point format or exponent format. A character string in
either format can be converted into binary floating point data.
b15——————b8 b7——————b0
ASCII code for 1st
S. ASCII code for sign
character
ASCII code for 3rd ASCII code for 2nd
S.+1 D.+1 D.
character character
Binary floating
ASCII code for 5th ASCII code for 4th
S.+2 point
character character
(real number)
ASCII code for 7th ASCII code for 6th
S.+3
character character
00H(Indicates the
S.+4 end of the character
string.)
234 https://en.coolmay.com/
Floating Point
When a character string to be converted into binary floating point specified by S. has 7 digits or more
excluding the sign, decimal point and exponent part, the conversion result may contain rounding error.
a) In the case of decimal point format
235 https://en.coolmay.com/
Floating Point
⚫ When "2BH (+)" is specified as the sign in the floating point format or when the sign is omitted, a character
string is converted into a positive value.
When "2DH (-)" is specified as the sign, a character string is converted into a negative value.
⚫ When "2BH (+)" is specified as the sign in the exponent format or when the sign is omitted, a character
string is converted into a positive exponent.
When "2DH (-)" is specified as the sign, a character string is converted into a negative exponent.
⚫ When "20H (space)" or "30H (0)" exists between numbers except the first "0" in a character string specified
by S. , "20H" or "30H" is ignored during conversion.
⚫ When "30H (0)" exists between a number and "E" in a character string in the exponent format, "30H" is
ignored during conversion.
236 https://en.coolmay.com/
Floating Point
2. Related devices
Description
Device Name
Condition Operation
The conversion result is true "0".
M8020 Zero flag The zero flag M8020 turns ON.
(The mantissa part is "0".)
−126
The absolute value of the The value of D. is the minimum value (2 ) of
M8021 Borrow flag conversion result is less than "2 32-bit real numbers and the borrow flag M8021
−126
". turns ON.
128
The absolute value of the The value of D. is the maximum value (2 ) of
M8022 Carry flag conversion 32-bit real numbers and the carry flag M8022
result is not less than "2 128 ". turns ON.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error code is
stored in D8067.
• When any character other than "30H (0)" to "39H (9)" exists in the integer part or decimal part (error code:
K6706)
• When "2EH (.)" exists in two or more positions in a character string specified by S. (error code: K6706)
• When any character other than "45H (E)", "2BH (+)" or "2DH (-)" exists in the exponent part, or when two or
more exponent parts exist (error code: K6706)
• When "00H" does not exist in the corresponding device range starting from S. (error code: K6706)
• When the number of characters after S. is "0" or more than "24" (error code: K6706)
Program
example 1
◆ In the program example shown below, a character string stored in R0 and later is converted into binary
floating point, and stored to D0 and D1 when X0 turns ON
237 https://en.coolmay.com/
Floating Point
Program
example 2
◆ In the program shown below, a character string stored in D10 and later is converted into binary floating
point, and stored to D100 and D101 when X0 turns ON
238 https://en.coolmay.com/
Floating Point
X0
Program DEBCD D0 D2
example
◆ When X0=ON, the binary floating-point numbers in D1 and D0 are converted into decimal floating-point numbers
and stored in D3 and D2.
◆ Binary floating point number [D1, D0] The real number is 23 bits, the exponent is 8 bits, and the sign bit is 1 bit
After the conversion, the decimal floating point number [D3, D2] is represented by the mathematical formula →
[D2] X 10[D3]
239 https://en.coolmay.com/
Floating Point
This instruction converts scientific notation stored in devices into binary floating point.
Instruction Operand
Function
format Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
FNC119 S. — 9 steps DEBIN
Operation
EBIN D.
Pulse (Single)
DEBINP
D P Operation
X0
Program
example 1 DEBIN D0 D2
◆ When X0=ON, the decimal floating-point numbers in D1 and D0 are converted into binary floating-point
numbers and stored in D3 and D2.
240 https://en.coolmay.com/
Floating Point
◆ Decimal floating point number [D1, D0] mathematical expression →[D2] X 10[D3]
After the conversion, the binary floating-point number has 23 real numbers, 8 exponents, and 1 sign
Program
example 2
◆ The FLT instruction must be used to convert BIN integers into binary floating-point numbers before performing
floating-point operations. The premise of the conversion is that the converted value must be a BIN integer.
However, the DEBIN instruction can convert floating-point values into binary floating-point numbers.
◆ By DEBIN instruction, a numeric value containing the decimal point can be directly converted into binary
floating point.
◆ When X0=ON, move K3,140 to D0, and move K-3 to D1 to form a decimal floating point number type
(3.14=3,140×10-3)
241 https://en.coolmay.com/
Floating Point
Word device number storing binary floating point data used in addition
S1.
Target Device: D, R, K, H, E, retouch
Word device number storing binary floating point data used in addition Real number
Operand S2.
Target Device: D, R, K, H, E, retouch ( binary )
Data register number storing the addition result
D.
Target Device: D, R, retouch
242 https://en.coolmay.com/
Floating Point
243 https://en.coolmay.com/
Floating Point
244 https://en.coolmay.com/
Floating Point
Word device number storing binary floating point data used in division
S1.
Target Device: D, R, K, H, E, retouch
Word device number storing binary floating point data used in division
S2.
Operand Target Device: D, R, K, H, E, retouch 实数(2 进制)
Data register number storing binary floating point data obtained by
D. division
Target Device: D, R, retouch
245 https://en.coolmay.com/
Floating Point
⚫ An operation error occurs in the following case; The error flag M8067 turns ON, and the error
code is stored in D8067. (error code: K6706)
2-126≦|Operation result|<2128
Program
example
246 https://en.coolmay.com/
Floating Point
◆ When M0 is ON, convert the value of (D1, D0) into a binary floating-point number and store it in the (D11, D10)
register.
◆ When M1 is ON, (D11, D10) is an exponent for EXP operation, and its value is a binary floating point value and
stored in the (D21, D20) register.
◆ When M2 is ON, convert the (D21, D20) binary floating point value into a decimal floating point value and store
it in the (D31, D30) register. (At this time D31 is the 10th power of D30)
Head device number storing binary floating point data used in the
S. natural logarithm operation
Real number
Operand Target Device: D, R, E, retouch
(binary)
Head device number storing the operation result
D.
Target Device: D, R, retouch
⚫ Only a positive value can be set in [S.+1, S.]. (The natural logarithm operation cannot be
executed for a negative value.)
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
1) When a negative value is specified in S. (error code: K6706)
2) When "0" is specified in S. (error code: K6706)
247 https://en.coolmay.com/
Floating Point
Program
example
◆ When M0 is ON, convert the value of (D1, D0) into a binary floating-point number and store it in the (D11, D10)
register.
◆ When M1 is ON, the (D11, D10) register is a true number for LOGE operation, and its value is a binary floating
point value and stored in the (D21, D20) register.
◆ When M2 is ON, the binary floating-point value is converted into a decimal floating-point value and stored in the
(D30, D31) register. (At this time D31 is the 10th power of D30)
Head device number storing binary floating point data used in the
common
S.
logarithm operation Real number
Operand
Target Device: D, R, E, retouch (binary)
Head device number storing the operation result
D.
Target Device: D, R, retouch
248 https://en.coolmay.com/
Floating Point
⚫ Only a positive value can be set in [S.+1, S.]. (The common logarithm operation cannot be
executed for a negative value.)
⚫ An operation error occurs in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
1) When a negative value is specified in S. (error code: K6706)
2) When "0" is specified in S. (error code: K6706)
Program
example
◆ When M0 is ON, convert the value of (D1, D0) into a binary floating-point number and store it in the (D11, D10)
register.
◆ When M1 is ON, find the common logarithm of "15" set in D0, and its value is a binary floating point value and
stored in the (D21, D20) register.
◆ When M2 is ON, the binary floating-point value is converted into a decimal floating-point value and stored in the
(D30, D31) register. (At this time D31 is the 10th power of D30)
249 https://en.coolmay.com/
Floating Point
Instruction for computing the square root (open root) of a binary floating point number.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
FNC127 S. Continuous
— 9 steps DESQR
ESQR D. operation
DESQRP Pulse operation
D P
The starting number of the device holding binary floating-point data that
S. performs square root operation
Devices: D, R, E, K, H, decoration Real number
Operand
Data register number for storing binary floating-point data after square (binary)
D. root operation
Device: D, R, decoration
Explanation of 32-bit operation (DESQR, DESQRP)
Instructions The square root of [S. +1, S.] is calculated (in the binary floating point operation), and the
result is
transferred to [D. +1, D.].
Program
Example 1
◆ When X0 is ON, take the square root of binary floating point numbers (D1, D0) and store the result in the
register specified by (D11, D10).
◆ ( D 1, D 0 ) →(D11, D10)
Program
Example 2
◆ When X2 is ON, take the square root of K1,234 (automatically converted to binary floating point), and store the
result in (D11, D10).
250 https://en.coolmay.com/
Floating Point
This instruction inverts the sign of binary floating point (real number) data.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
FNC128 Continuous
D. — 5 steps DENEG
ENEG operation
DENEGP Pulse operation
D P
Program
Example
◆ When X0 is ON, the sign of the binary floating-point number data of D100 and D101 is inverted and stored in
D100 and D101.
251 https://en.coolmay.com/
Floating Point
This instruction converts binary floating point data into a binary integer which is a normal data format inside
PLCs (binary floating point → binary integer)
Operand
Instruction Functions
type
16-bit Operation 32-bit
Mnemonic Mnemonic Operation condition
instruction condition instruction
Continuous
FNC129 S. 5 steps INT 9 steps DINT Continuous operation
operation
INT D.
Pulse
INTP DINTP Pulse operation
D P operation
Program
Example
252 https://en.coolmay.com/
Floating Point
◆ When X0 = ON, convert binary floating-point numbers (D1, D0) into BIN integers and store the result in (D10).
BIN integer floating-point numbers are cut.
◆ When X1 = ON, convert binary floating point numbers (D21, D20) into BIN integers and store the result in (D31,
D30), BIN integer floating point numbers are cut.
253 https://en.coolmay.com/
Floating Point
Program
Example
◆ When X0 is ON, the radian (RAD) value of the specified binary floating point number (D1, D0) is calculated and
the SIN value is obtained and stored in (D11, D10). The content is binary floating point number.
RAD value (value in degrees X π/180)
S. D1 D0
Binary floating point
SIN value
D. D11 D10
Binary floating point
254 https://en.coolmay.com/
Floating Point
X0
Program DCOS D0 D10
Example
◆ When X0 is ON, the radian (RAD) value of the specified binary floating point number (D1, D0) is calculated and
stored in (D11, D10). The content is a binary floating point number.
RAD value (value in degrees X π/180)
S. D1 D0
Binary floating point
COS value
D. D11 D10
Binary floating point
255 https://en.coolmay.com/
Floating Point
256 https://en.coolmay.com/
Floating Point
Head device number storing a sine value used in the SIN −1 (arc sine)
S. operation.
Real number
Operand Device: D, R, E, decoration
(Binary)
Head device number storing the operation result.
D.
D, R, decoration
⚫ The sine value stored in [S.+1, S.] can be set within the range from −1.0 to +1.0. An operation error
257 https://en.coolmay.com/
Floating Point
is caused in the following case; The error flag M8067 turns ON, and the error code is stored in
D8067. (error code: K6706)
⚫ The angle (operation result) stored in [D.+1, D.] is expressed in radians (from −π/2 to π/2).
X0
Program
DASIN D0 D10
Example
◆ When X0 is ON, specify the binary floating point number (D1, D0) to find the ASIN value and store it in (D11,
D10), the content is binary floating point number.
ASIN value
D. D11 D10
Binary floating point
Head device number storing a cosine value used in the COS −1 (arc
cosine)
S.
operation. Real number
Operand
Device: D, R, E, decoration (binary)
Head device number storing the operation result.
D.
Device: Device: D, R, decoration
Explanation of
Instructions 32-bit operation (DACOS and DACOSP)
An angle is obtained from the cosine value stored in [S.+1, S.], and stored to [D.+1, D.].
A real number can be directly specified as S..
258 https://en.coolmay.com/
Floating Point
⚫ The cosine value stored in [S.+1, S.] can be set within the range from −1.0 to +1.0. An operation
error is caused in the following case; The error flag M8067 turns ON, and the error code is stored
in D8067. (error code: K6706)
⚫ The angle (operation result) stored in [D.+1, D.] is expressed in radians (from 0 to π).
X0
Program
Example DACOS D0 D10
◆ When X0 is ON, specify the binary floating point number (D1, D0) to find the ACOS value and store it in (D11,
D10), the content is binary floating point number.
S. D1 D0 Binary floating point
ACOS value
D. D11 D10
Binary floating point
259 https://en.coolmay.com/
Floating Point
Head device number storing a tangent value used in the TAN −1 (arc
S. tangent) operation
Real number
Operand Device: D, R, E, decoration
(Binary)
Head device number storing the operation result.
D.
Device: D, R, decoration
⚫ The angle (operation result) stored in [D.+1, D.] is expressed in radians (from −π/2 to +π/2).
260 https://en.coolmay.com/
Floating Point
Program
example
◆ In the program example shown above, the TAN −1 value of data (binary floating point) stored in D0 and D1 is
calculated, and the angle is output in 4-digit BCD to Y040 to Y057 when X000 turns ON.。
3) The angle expressed in binary floating point (real number) is converted into an integer (binary) (③)
4) The angle expressed in integer (binary) is output to the display unit (④)
261 https://en.coolmay.com/
Floating Point
Program X0
example DRAD D0 D10
◆ When X0 is ON, specify the angle value of binary floating point number (D1, D0), convert the angle to radian
value and store it in (D11, D10), the content is binary floating point number.
radian
S. D1 D0
Binary floating point
262 https://en.coolmay.com/
Floating Point
X0
Program
DDEG D0 D10
example
◆ When X0 is ON, specify the radian value of the binary floating point number (D1, D0), convert the radian value
to the radian value, and store it in (D11, D10). The content is a binary floating point number.
Radian
S. D1 D0
Binary floating point
263 https://en.coolmay.com/
Data Processing 2
Data Processing 2
Devices
FNC
Instruction Functions 3G 系列 2N 系列 MX2N 系列
NO.
PLC PLC PLC
140 WSUM Sum of Word Data ★
264 https://en.coolmay.com/
Data Processing 2
⚫ In the 32-bit operation, the acquired sum is 64-bit data. FX3U and FX3UC PLCs cannot handle 64-
bit data. When the sum is within the numeric range of 32-bit data (K-2,147,483,648 to
265 https://en.coolmay.com/
Data Processing 2
K2,147,483,647), however, FX3U and FX3UC PLCs can handle the low-order 32 bits of 32-bit data
as the sum while ignoring the high-order 32 bits.
⚫ When D and R are designated as n of 32-bit instruction, the 32-bit value of [n+1, n] will take effect,
so please be careful.
For example, when DWSUM D0 D100 R0, then n=[R1, R0]
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When "n" points starting from S. are outside the specified device range (error code: K6706)
• When "n" is smaller than or equivalent to "0" (error code: K6706)
• When D. are outside the specified device range. (error code: K6706)
266 https://en.coolmay.com/
Data Processing 2
2) "00H" is stored in the high-order byte (8 bits) of each device ( and later) storing the separated
byte data.
3) When "n" is an odd number, only the low-order byte (8 bits) of the final separation source
device is regarded as the target data as shown in the figure below.
For example, when "n" is "5", the data from S. to the low-order byte (8 bits) of (S.+2) is stored in
D. to (D.+4).
⚫ The device that saves the separated source data and the device that saves the separated data
can be reused.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the separation source devices S. to (S. +n/2) are outside the specified device range (error
code: K6706)
When "n" is an odd number, the number of a rounded up value decides the number of devices.
(error code: K6706)
• When the separated data destination devices D. to (D.+n-1) are outside the specified device
range (error code: K6706)
X0
Program
WTOBP D10 D20 K6
example
◆ When X0 is ON, the data stored in D10 to D12 is separated in byte units, and stored in D20 to D25.
267 https://en.coolmay.com/
Data Processing 2
This instruction combines the low-order 8 bits (low-order byte) of consecutive 16-bit data.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S.
FNC142 Continuous
D. 7 steps BTOW —
BTOW operation
n
BTOWP Pulse operation —
P
2) The high-order byte (8 bits) of each combination source 16-bit data ( and later) is ignored.
3) When "n" is an odd number, "00H" is stored in the high-order byte (8 bits) of the final one among the
combination result destination devices as shown below.
For example, when "n" is "5", the low-order byte (8 bits) of S. to (S.+4) is stored in D. to (D.+2), and "00H"
is stored in the high-order byte (8 bits) of D.+2.
268 https://en.coolmay.com/
Data Processing 2
⚫ The device that saves the combined source data and the device that saves the combined data can be
reused.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error code is
stored in D8067.
• When the combination source devices S. to (S. +n-1) are outside the specified device range (error
code: K6706)
• When the combined data destination devices D. to (D.+n/2) are outside the specified device range
(error code: K6706)
When "n" is an odd number, the number of a rounded up value decides the numer of devices. (error code:
K6706)
Program X0
example BTOWP D20 D10 K6
◆ In the program shown below, the low-order byte (8 bits) data stored in D20 to D25 is combined, and stored in
D10 to D12.
269 https://en.coolmay.com/
Data Processing 2
2) Specify a number 1 to 4 in "n". In the case of "n = 0", UNI instruction is not executed.
3) In the case of “1≦n≦3”, the high-order {4×(4-n)} bits of D. are set to ”0”.
For example, when "n" is "3", the low-order 4 bits of S. to (S.+2) are stored in b0 to b11 of D., and the
high-order 4 bits of D. are set to "0".
⚫ An operation error occurs in the following cases; The error flag M8067 turns ON, and the error code is
stored in D8067.
• When S. to (S. +n) are outside the specified device range (error code: K6706)
270 https://en.coolmay.com/
Data Processing 2
• When "n" is outside the range from "0 to 4" (error code: K6706)
X0
Program
UNIP D0 D10 K3
example
◆ In the program below, the low-order 4 bits of D0 to D2 are combined and stored in D10 when X0 turns ON.
Explanation
of 16-bit operation (DIS and DISP)
Instructions 1) 16-bit data stored in S. is separated in 4-bit units, and stored in D. as shown below.
271 https://en.coolmay.com/
Data Processing 2
2) Specify a number 1 to 4 in "n". In the case of "n = 0", DIS instruction is not executed.
3) High-order 12 bits of "n" devices starting from D. are set to "0".
⚫ An operation error occurs in the following cases; The error flag M8067 turns ON, and the error code is
stored in D8067.
• When D. to (D.+n) are outside the specified device range (error code: K6706)
• When "n" is outside the range from "0 to 4" (error code: K6706)
X0
Program
DISP D0 D10 K4
example
◆ In the program below, D0 is separated into 4 bit units and stored in D10 to D13 when X0 turns ON.
272 https://en.coolmay.com/
Data Processing 2
This instruction swaps the high-order 8 bits and low-order 8 bits of a word device.
Opera
Instruction nd Functions
type
16-bit Operation 32-bit
Mnemonic Mnemonic Operation condition
instruction condition instruction
Continuous
FNC147 3 steps SWAP 5 steps DSWAP Continuous operation
S. operation
SWAP
Pulse
SWAPP DSWAPP Pulse operation
D P operation
⚫ When the continuous operation type instruction is used, swapping is executed in each operation
cycle. This instruction works in the same way as the extension function of the XCH (FNC 17)
instruction.
Program
example
◆ When X0 is ON, the high-order 8 bits and low-order 8 bits of D11 are exchanged, and the high-order 8 bits and
low-order 8 bits of D10 are exchanged.
273 https://en.coolmay.com/
Data Processing 2
This instruction sorts a data table consisting of data (lines) and group data (columns) based on a specified
group data (column) sorted by line in either ascending or descending order. This instruction stores the data (lines) in
serial devices facilitating the addition of data (lines).
On the other hand, the SORT (FNC 69) instruction stores the group data (columns) in serial devices, and sorts
a table in ascending order only.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
S. Mnemonic Mnemonic
instruction condition instruction condition
m1
FNC149 Continuous Continuous
m2 11 steps SORT2 21 steps DSORT2
SORT2 operation operation
D.
D P n
Head device number storing the data table [which occupies m1 × m2 points]
S.
Device: D, R
Number of data (lines) [1 to 32]
m1
Device: D, R, K, H
Number of group data (columns) [1 to 6]
m2 BIN16/32
Operand Device: K, H
bit
Head device number storing the operation result [which occupies m1 × m2
D. points]
Device: D, R
Column number of group data (column) used as the basis of sorting [1 to m2]
n
Device: D, R, K, H
274 https://en.coolmay.com/
Data Processing 2
Cautions:
⚫ Do not change the contents of operands and data during operation.
⚫ To execute SORT2 instruction again, set the command input to OFF once, then ON again.
⚫ Limitation in number of SORT2 instructions
Up to two SORT2 instructions can be simultaneously driven in a program.
⚫ Writing during RUN is disabled for a circuit block including SORT2 instruction.
⚫ When the same device is specified in S. and D.
The source data is overwritten with the data acquired by sorting.
Pay close attention not to change the contents of until execution of SORT2 instruction is
completed.
Program
example
◆ When X0=ON, specify to execute the data sorting. When sorting is completed, M8029=ON. Please do not
change the contents of the sorted data during the execution of Instruction. If you want to reorder the data,
please turn OFF and ON again.
1) Sorting result when the instruction is executed with "n = K2 (column No. 2)" (in the case of ascending
order)
275 https://en.coolmay.com/
Data Processing 2
2) Sorting result when the instruction is executed with "n = K3 (column No. 3)" (in the case of descending
order)
Number of groups (m2 = K4)
Column No. 1 2 3 4
Line No. Control number Height Weight Age
1 (D18)3 (D19)160 (D20)70 (D21)30
2 (D14)2 (D15)180 (D16)50 (D17)40
Number of data
3 (D26)5 (D27)150 (D28)50 (D29)45
(m1 = 5)
4 (D10)1 (D11)150 (D12)45 (D13)20
5 (D22)4 (D23)100 (D24)20 (D25)8
276 https://en.coolmay.com/
Positioning Control
Positioning Control
FNC Device
Instruction Function
NO. 3G PLC 2N PLC MX2N PLC
150 DSZR DOG Search Zero Return ★
277 https://en.coolmay.com/
Positioning Control
This instruction executes a zero return, and aligns the mechanical position with a present value register inside
the PLC.
In addition, this instruction enables the following functions not supported by the ZRN (FNC156) instruction:
• DOG search function
• Zero return by the near-point (dog) signal and zero-phase signal
It is not possible, however, to count the zero-phase signal and then determine the zero point.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. instruction condition instruction condition
FNC150 S2. Continuous
9 steps DSZR —
DSZR D1. operation
D2. —
⚫ During RUN, avoid writing while the DSZR (FNC150) instruction is executed (that is, while a pulse
is output).
Note that if writing is executed during RUN to a circuit block including the FNC150 instruction
while pulses are output, the PLC decelerates and stops pulse output.
278 https://en.coolmay.com/
Positioning Control
Pulse operation monitoring M8340 M8350 M8360 M8370 M8151 M8152 M8153 M8154
Clear signal output function is
M8341 M8351 M8361 M8371
effective
Zero return direction specification M8342 M8352 M8362 M8372
Forward limit M8343 M8353 M8363 M8373
Reverse limit M8344 M8354 M8364 M8374
Near-point signal logic inversion M8345 M8355 M8365 M8375
Zero signal logic inversion M8346 M8356 M8366 M8376
Positioning Instruction Drive M8348 M8358 M8368 M8378
Pulse stop bit M8349 M8359 M8369 M8379 M8450 M8451 M8452 M8453
Clear signal device specified
M8464 M8465 M8466 M8467
function is valid
279 https://en.coolmay.com/
Positioning Control
1. For S1., specify the near-point signal (DOG) input device number.
To specify the logic of this near-point signal (DOG), turn the "DOG signal logic reverse" relay on or off as shown
in the following table.
Pulse output
“DOG signal logic
destination device Description
reverse” relay
D1.
Y0 M8345 OFF: Positive logic (Turning on the input will
Y1 M8355 turn on the near-point signal.)
Y2 M8365 ON: Negative logic (Turning off the input will
Y3 M8375 turn on the near-point signal.)
2. For S2., specify the zero-phase signal input number in the range of X000 to X007.
To specify the logic of this zero-phase signal, turn the "Zero-point signal logic reverse" relay on or off as shown
in the following table.
If the same input is specified for both the near-point signal and the zero-phase signal, the logic of the zero-
phase signal will be specified by the device of the near-point signal (DOG), and not by one of the following
devices. In this case, the operation will be performed at the front and rear ends of the near-point signal (DOG)
without using the zero-phase signal. This is similar to the operation of the ZRN instruction.
Pulse output "Zero-point signal
destination device logic Description
D1. reverse" flag
Y0 M8346 OFF: Positive logic (Turning on the input will
Y1 M8356 turn on the near-point signal.)
Y2 M8366 ON: Negative logic (Turning off the input will
Y3 M8376 turn on the near-point signal.)
280 https://en.coolmay.com/
Positioning Control
so that the relation with the other speeds is "bias speed≦zero return speed≦maximum speed".
- If "zero return speed > maximum speed", the operation will be performed at the maximum speed.
Pulse output
Zero return Maximum
destination device Bias speed Initial value
speed speed
D1.
D8347, D8344,
Y0 D8342
D8346 D8343
D8357, D8354,
Y1 D8352
D8356 D8353
5000Hz
D8367, D8364,
Y2 D8362
D8366 D8363
D8377, D8374,
Y3 D8372
D8376 D8373
5. Creep speed
Pulse output
Maximum
destination device Bias speed Creep speed Initial value
speed
D1.
Y0 D8342 D8345 D8344,D8343
Y1 D8352 D8355 D8354,D8353
1000Hz
Y2 D8362 D8365 D8364,D8363
Y3 D8372 D8375 D8374,D8373
281 https://en.coolmay.com/
Positioning Control
If the forward rotation limit and the reverse rotation limit are set, the DOG search function can be used for zero
return. The zero return operation depends on the zero return start position.
282 https://en.coolmay.com/
Positioning Control
f) After detecting the rear end of the DOG, if the first zero-phase signal is detected, the operation will be
stopped.
3. If the start position is in the near-point signal OFF area (after the DOG):
a) When the zero return instruction is executed, zero return will be started.
b) Transfer operation will be started in the zero return direction at the zero return speed.
c) If the reverse rotation limit 1 (reverse rotation limit) is detected, the speed will decelerate, and the operation
will stop.
d) Transfer operation will be started in the opposite direction of the zero return direction at the zero return speed.
e) If the front end of the DOG is detected, the speed will be reduced and the operation will be stopped. (The
workpiece will detect the DOG and then come out of the DOG area.)
f) Transfer operation will be restarted in the zero return direction at the zero return speed. (The workpiece will
enter the DOG area again.)
g) If the front end of the DOG is detected, the speed will be reduced to the creep speed.
h) After detecting the rear end of the DOG, if the first zero-phase signal is detected, the operation will be
stopped.
4. If the limit switch in the zero return direction turns ON (if the start position is at forward rotation limit 1 or reverse
rotation limit 1):
a) When the zero return instruction is executed, zero return will be started.
b) Transfer operation will be started in the opposite direction of the zero return direction at the zero return speed.
c) If the front end of the DOG is detected, the speed will decelerate and the operation will stop. (The workpiece
will detect the DOG and then come out of the DOG area.)
d) Transfer operation will be restarted in the zero return direction at the zero return speed (and the workpiece
will enter the DOG area again).
e) If the front end of the DOG is detected, the speed will be reduced to the creep speed.
f) After detecting the rear end of the DOG, if the first zero-phase signal is detected, the operation will be
stopped.
283 https://en.coolmay.com/
Positioning Control
⚫ During RUN, avoid writing while the DVIT (FNC151) instruction is executed (that is, while a pulse
is output).
Note that if writing is executed during RUN to a circuit block including the FNC151 instruction
while pulses are output, the PLC decelerates and stops pulse output.
284 https://en.coolmay.com/
Positioning Control
1) The rotation direction ON/OFF status of the specified device is shown in the following table.
During instruction execution, however, do not use the output D2. for other purposes.
ON/OFF status of device
specified by D2. Rotation direction (increase/decrease current value)
285 https://en.coolmay.com/
Positioning Control
... ...
5 Specifies X005 for the interrupt input signal.
Specifies a user interrupt input command for the interrupt input signal.
8 Y0 M8460
Y1 M8461
Y2 M8462
Y3 M8463
9~E Do not specify these values.
Set "F" for a pulse output destination device if the device is not used for the Interrupt
F
Positioning (DVIT) instruction.
The interruption positioning operation is described below assuming that Y000 is specified as the pulse output
destination device by D1..
286 https://en.coolmay.com/
Positioning Control
287 https://en.coolmay.com/
Positioning Control
This instruction executes one specified table operation from the data table set in GX Developer (Ver.8.23Z or
later).
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
FNC152 D. Continuous
— 17 steps DTBL
TBL n operation
—
D
❖ Related devices please refer to “18.1 DSZR/ Dog Search Zero Return”.
288 https://en.coolmay.com/
Positioning Control
This instruction reads the absolute position (ABS) data. The data is converted into a pulse when being read.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S.
FNC155 Continuous
D1. — 13 steps DABS
ABS operation
D2.
—
D
Head device number inputting absolute (ABS) data output signal sent
S. from servo amplifier. Three points are occupied from S.. BIN 16 bit
Device: X, Y, M, S, D 口.b, decoration
289 https://en.coolmay.com/
Positioning Control
290 https://en.coolmay.com/
Positioning Control
291 https://en.coolmay.com/
Positioning Control
Instruction for reading absolute position (ZRN) data. The data is read out as pulse converted values.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. instruction condition instruction condition
FNC156 S2. Continuous Continuous
9 steps ZRN 17 steps DZRN
ZRN S3. operation operation
D1. —
D
⚫ During RUN, avoid writing while the ZRN (FNC156) instruction is executed (that is, while pulses
are output).
Note that if writing is executed during RUN to a circuit block including the FNC156 instruction
while pulses are output, the PLC decelerates and stops pulse output.
292 https://en.coolmay.com/
Positioning Control
Function
Send end flag M8029
Instruction
execution
M8329
abnormal end
flag
Pulse operation
M8340 M8350 M8360 M8370 M8151 M8152 M8153 M8154
monitoring
Clear signal
output function M8341 M8351 M8361 M8371
is effective
Forward limit M8343 M8353 M8363 M8373
Reverse limit M8344 M8354 M8364 M8374
Positioning
Instruction M8348 M8358 M8368 M8378
driver
Pulse stop bit M8349 M8359 M8369 M8379 M8450 M8451 M8452 M8453
293 https://en.coolmay.com/
Positioning Control
Clear signal
device specified M8464 M8465 M8466 M8467
function is valid
1) For S3., specify the near-point signal (DOG) input device number (NO contact).
Turning on the near-point signal will reduce the speed to the creep speed. Turning off the near-point signal will
complete the zero return operation.
2) Zero return direction
For this instruction, the zero return direction is set to the reverse rotation direction.
(During zero return operation, the value indicated in the current value register will be decreased.)
To perform zero return in the forward rotation direction, follow the example program below to control the direction
output.
a) Turn on Y□□□ (rotational direction signal).
b) Refresh Y□□□ output using the REF (FNC 50) instruction.
c) Execute the ZRN instruction (zero return instruction).
d) With the execution completion flag (M8029) of the ZRN instruction (zero return instruction), reset Y□□□
(rotational direction signal).
Zero return operation is described below assuming that Y000 is specified as the pulse output destination device
D..
1) Execute the ZRN instruction to carry out zero return.
2) Transfer operation will be performed at the zero return speed specified by S1..
294 https://en.coolmay.com/
Positioning Control
3) If the near-point signal (DOG) specified by S3. is turned on, the speed will be reduced to the creep speed
specified by S2..
4) If the near-point signal (DOG) specified by S3. is turned off, the pulse outputting operation will be immediately
stopped.
5) If the CLEAR signal output function (M8341) is enabled (set to ON), the CLEAR signal (Y004) will be turned
on within 1 ms *1 after the near-point signal (DOG) is turns from ON to OFF, and will be kept ON for "20 ms +
1 scan time (ms)". *2
6) The current value register (D8341, D8340) will be reset to "0" (will be cleared).
7) "Instruction execution complete" flag will be turned on, and the zero return operation will be completed.
18.5.4 Cautions
If the near-point input signal in S3. is specified as X000 to X007, the PLC interruption function will be used
to stop the operation.
Under the following condition, however, operation may be affected by the input filter or the scan time of the
sequence program.
- An input number of X010 or higher (or other device (auxiliary relay, etc.)) is specified.
If input relay X010 or higher is specified for the near-point signal (DOG), the effects of the input filter will be
applied.
If an input X000 to X007 (X000 to X005 for FX 3S PLC) of the main unit is specified for the near-point signal
(DOG), the input cannot be used for the following items:
- High-speed counter
- Input interruption
- Pulse catch
295 https://en.coolmay.com/
Positioning Control
- SPD instruction
- DSZR instruction
- DVIT instruction *1
Properly set the DOG so that the near-point signal (DOG) can be kept ON until the speed is reduced to the
creep speed.
This instruction will start speed reduction at the front end of the DOG, and will stop the operation at the rear
end of the DOG. The current value register will then be cleared (reset to "0").
If the speed is not reduced to the creep speed before detecting the rear end of the DOG, the operation may
not be stopped at the specified position.
The creep speed should be sufficiently slow.
The zero return instruction will not decelerate at the stop point. Therefore, if the creep speed is not slow
enough, the operation may not stop at the specified position due to inertia.
The zero-phase signal of the servo motor cannot be used. For this reason, if fine adjustment of the origin
position is needed, adjust the position of the near-point signal (DOG).
If the instruction activation contact is turned off during zero return operation, the speed will decelerate and
the operation will stop. In this case, the "Instruction execution complete" flag (M8029) will not turn on.
While the "pulse output monitor" (BUSY/READY) flag is on, a positioning instruction (including PLSR and
PLSY) that uses the same output cannot be executed.
If the "pulse output monitor" (BUSY/READY) flag is still on after the instruction activation contact is turned
off, do not execute a positioning instruction (including PLSR and PLSY instructions) that uses the same
output number.
In the following case, the "Instruction execution abnormal end" flag (M8329) will be turned on, and execution
of the instruction will be completed.
- If the forward limit relay or the reverse limit relay is turned on, the speed will decelerate and the operation will
stop. In this case, the "Instruction execution abnormal end" flag (M8329) will be turned on when execution of
the instruction is complete.
- If the limit relay (forward or reverse) on the opposite side of the operation direction is turned on, the speed
will decelerate and the operation will stop.
In this case, the "Instruction execution abnormal end" flag (M8329) will be turned on when execution of the
instruction is complete.。
296 https://en.coolmay.com/
Positioning Control
This instruction outputs variable speed pulses with an assigned rotation direction.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S1.
FNC157 Continuous Continuous
D1. 9 steps PLSV 17 steps DPLSV
PLSV operation operation
D2.
—
D
Note:*1. Setting range: −32768 to +32767 Hz for 16-bit operation, -100,000 to 000 Hz for 32-bit operation.
⚫ During RUN, avoid writing while PLSV (FNC157) instruction is executed (that is, while pulses are
output).
Note that if writing is executed during RUN to a circuit block including FNC157 instruction while
pulses are
output, the PLC executes the operation shown below.
The variable speed pulse output instruction changes the speed while using the rotation direction output.
The acceleration/deceleration function applies for the variable speed pulse output (PLSV) instruction, which
makes it possible to specify whether acceleration/deceleration will be used or not.
If the output pulse frequency S. value is changed after turning the acceleration/deceleration function (M8338)
OFF, the variable speed pulse output (PLSV) instruction will change the output frequency without using
297 https://en.coolmay.com/
Positioning Control
acceleration/deceleration.
If the output pulse frequency S. value is changed after turning the acceleration/deceleration (M8338) ON, the
variable speed pulse output (PLSV) instruction will accelerate or decelerate to the changed output.
298 https://en.coolmay.com/
Positioning Control
• During pulse output operation, if the output pulse frequency is changed to "K0", the PLC will reduce the speed
and then stop the pulse outputting operation if the acceleration/deceleration function is ON.
However, if the acceleration/deceleration function is not activated, the PLC will immediately stop the pulse
299 https://en.coolmay.com/
Positioning Control
outputting operation.
Before outputting pulses again, check that the "pulse output monitor" (BUSY/READY) flag is off, and then wait
until 1 or more cycles of operation have been completed. After that, set (change) the output pulse frequency to a
value other than "K0".
• During pulse outputting operation, do not change the sign attached to the output pulse frequency value S..
If it is necessary to change the sign, stop the servo motor first by setting the output pulse frequency value S. to
"K0", and wait for the motor to stop completely after decelerating to stop. And then, change the sign attached to
the output pulse frequency value S..
If the sign attached to the output pulse frequency value S. is changed during pulse outputting operation, the
operation may be changed as follows, and the machine, therefore, may be damaged:
1) The pulse outputting operation may be stopped.
2) "Pulse output monitor" (BUSY/READY) flag may be turned off.
(The pulse outputting operation may be stopped, but the motor may not be stopped immediately.)
3) Operation may be performed in the specified direction at the frequency specified by the output pulse frequency
value S..
• If the instruction activation contact is turned off during pulse outputting operation while the
acceleration/deceleration function is ON, the speed will decelerate and the operation will stop.
If the instruction activation contact is turned off during pulse outputting operation while the
acceleration/deceleration function is OFF, the operation will stop immediately.
The "Instruction execution complete" flag (M8029) will not turn on.
• If a limit flag (forward rotation or reverse rotation) in the operation direction is turned ON, the speed will decelerate
and the operation will stop in the case that the acceleration/deceleration function is ON. In this case, the
"Instruction execution abnormal end" flag (M8329) will turn on when execution of the instruction is complete.
• If the "pulse output monitor" (BUSY/READY) flag is on, a positioning instruction (including PLSR and PLSY) that
uses the same output cannot be executed.
If the "pulse output monitor" (BUSY/READY) flag is still on after the instruction activation contact is turned off, do
not execute a positioning instruction (including PLSR and PLSY instructions) that uses the same output number.
• After executing the instruction, the rotation direction signal output will turn off.
300 https://en.coolmay.com/
Positioning Control
This instruction executes one-speed positioning by incremental drive. The movement distance from the present
position can be specified with a positive or negative sign.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. instruction condition instruction condition
FNC158 S2. Continuous Continuous
9 steps DRVI 17 steps DDRVI
DRVI D1. operation operation
D2. —
D
Note:*1. Setting range: −32768 to +32767 (except 0) for 16-bit operation, and −999,999 to +999,999 (except
0) for 32-bit operation
*2. Setting range: 10 to 32767 Hz for 16-bit operation, and 10 to 100,000 Hz for 32-bit operation
Explanation of ⚫ During RUN, avoid writing while DRVI (FNC158) instruction is executed (that is, while pulses are
Instructions output).
Note that if writing is executed during RUN to a circuit block including FNC158 instruction while
pulses are
output, the PLC decelerates and stops pulse output.
❖ For related devices, refer to “18.1 DSZR/ Dog Search Zero Return”.
This instruction uses a relative drive method to perform a 1-speed positioning instruction. For this instruction,
the transfer distance from the current position to the target position should be specified together with a plus or
minus sign. This method is also referred to as the incremental (relative) drive method.
301 https://en.coolmay.com/
Positioning Control
The rotation direction ON/OFF status of the specified device is shown in the following table.
ON/OFF status of
Rotation direction (increase/decrease current
device specified by
value)
D2.
If the number of output pulses specified by S1. is a
positive number, the operation will be performed in the
ON forward rotation direction.
Forward rotation (Outputting pulses from D1. will
increase the current value.)
If the number of output pulses specified by S1. is a
negative number, the operation will be performed in
OFF the reverse rotation direction.
Reverse rotation (Outputting pulses from D1. will
decrease the current value.)
If the instruction activation contact is turned off during execution of the instruction, the speed will
decelerate and the operation will stop.
In this case, the "Instruction execution complete" flag (M8029) will not be turned on.
If the limit flag (forward or reverse) in the operation direction is turned on, the speed will decelerate and the
operation will stop.
In this case, the "Instruction execution abnormal end" flag (M8329) will be turned on when execution of the
instruction is complete.
The direction of rotation is specified by the sign of S1..
302 https://en.coolmay.com/
Positioning Control
This instruction uses an absolute drive method to perform a 1-speed positioning instruction.
For this instruction, the distance from the origin (zero-point) to the target position should be specified.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. instruction condition instruction condition
FNC159 S2. Continuous Continuous
9 steps DRVA 17 steps DDRVA
DRVA D1. operation operation
D2. —
D
Note:*1. Setting range: −32768 to +32767 (except 0) for 16-bit operation, and −999,999 to +999,999 (except
0) for 32-bit operation
*2. Setting range: 10 to 32767 Hz for 16-bit operation, and 10 to 100,000 Hz for 32-bit ope
Explanation of ⚫ During RUN, avoid writing while DRVA (FNC159) instruction is executed (that is, while pulses are
Instructions output).
Note that if writing is executed during RUN to a circuit block including FNC159 instruction while
pulses are
output, the PLC decelerates and stops pulse output.
❖ For related devices, refer to “18.1 DSZR/ Dog Search Zero Return”.
This instruction executes one-speed positioning by absolute drive. The movement distance from the zero point
can be specified.
303 https://en.coolmay.com/
Positioning Control
The rotation direction ON/OFF status of the specified device is shown in the following table. During instruction
execution, however, do not use the output for other purposes.
ON/OFF status of
device
Rotation direction (increase/decrease current value)
specified by D2.
If the instruction activation contact is turned off during execution of the instruction, the speed will
decelerate and the operation will stop.
In this case, the "Instruction execution complete" flag (M8029) will not be turned on.
If the limit flag (forward or reverse) in the operation direction is turned on, the speed will decelerate and the
operation will stop. In this case, the "Instruction execution abnormal end" flag (M8329) will be turned on
when execution of the instruction is complete.
304 https://en.coolmay.com/
Real Time Clock Operation
FNC Device
Instruction Function
NO. 3G PLC 2N PLC MX2N PLC
160 TCMP Clock data comparison ★ ★ ★
Clock data interval
161 TZCP ★ ★ ★
comparison
162 TADD Clock data addition ★ ★ ★
305 https://en.coolmay.com/
Real Time Clock Operation
This instruction compares the comparison time with the time data, and turns ON or OFF bit devices according to
the comparison result.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
S1. instruction condition instruction condition
S2. Continuous
FNC160 11 steps TCMP —
S3. operation
TCMP
S. Pulse
TCMPP
P D. operation
306 https://en.coolmay.com/
Real Time Clock Operation
⚫ When utilizing the time (hour, minute, and second) of the real time clock built in a PLC, please use
TRD (FNC 166) Instruction. Read the values of special data registers by TRD (FNC166)
instruction, and then specify those word devices as the operands.
⚫ Program example
◆ When X10=ON, Instruction is executed, the current time of the D20~D22 calendar is compared with the set value
12:20:45, and the result is displayed to M10~M12. When X10 changes from ON→OFF, the instruction is not
executed, but the ON/OFF state before M10~M12 is still maintained.
◆ If you need to get the results of ≧, ≦, ≠, you can get by connecting M10~M12 in series and parallel.
307 https://en.coolmay.com/
Real Time Clock Operation
This instruction compares two comparison time (comparison time zone) with the time data, and turns ON or OFF
the specified bit devices according to the comparison results.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S1.
Continuous
FNC161 S2. 11 steps TZCP —
operation
TZCP S.
Pulse
D. TZCPP
P operation
Specifies "hour" of the lower limit comparison time (hour, minute, and
S1. second). (Three devices are occupied.)
Device: T, C, D, R, decoration
Specifies "hour" of the upper limit comparison time (hour, minute, and
S2. second). (Three devices are occupied.) 16-bit binary
Device: T, C, D, R, decoration
Operand Specifies "hour" of the time data (hour, minute, and second).
S. (Three devices are occupied.)
Device: T, C, D, R, decoration
Turns ON or OFF according to the comparison result.
308 https://en.coolmay.com/
Real Time Clock Operation
⚫ When utilizing the time (hour, minute, and second) of the real time clock built in a PLC Read the
values of special data registers by TRD (FNC166) instruction, and then specify those word
devices as the operands.
⚫ Program Example
This instruction executes addition of two time data, and stores the addition result to word devices.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S1. Continuous
FNC162 7 steps TADD —
S2. operation
TADD
D. Pulse
TADDP
P operation
Specifies "hour" of the time data (hour, minute, and second) used in
S1. addition. (Three devices are occupied.)
Device: T, C, D, R, decoration
Specifies "hour" of the time data (hour, minute, and second) used in
Operand S2. addition. (Three devices are occupied.) 16-bit binary
Device: T, C, D, R, decoration
Stores the addition result (hour, minute, and second) of two time data.
D. (Three devices are occupied.)
Device: T, C, D, R, decoration
309 https://en.coolmay.com/
Real Time Clock Operation
(hour, minute, and second) stored in [S1., S1.+1, S1.+2] , and the addition result (hour, minute,
and second) is stored in [D., D.+1, D.+2].
1) When the operation result exceeds 24 hours, the carry flag turns ON, and the value simply
acquired by addition subtracted by 24 hours is stored as the operation result.
2) When the operation result becomes "0" (0:0:0), the zero flag turns ON.
⚫ When utilizing the time (hour, minute, and second) of the real time clock built in a PLC, read the
values of special data registers using the TRD (FNC166) instruction, and then specify those word
devices as the operands.
X10
Program
TADD D0 D10 D20
example
◆ When X10=ON, TADD Instruction is executed, and the calendar data hours, minutes, and seconds specified by
D0~D2 are added to the calendar data hours, minutes, and seconds specified by D10~D12, and the obtained
results are stored in D20~D22. The hours, minutes, and seconds after the summation are obtained in the
specified register.
D0 8 (hour) D10 6 (hour) D20 14 (hour)
D1 10 (minute) + D11 40 (minute) → D21 50 (minute)
D2 20 (second) D12 6 (second) D22 26 (second)
8:10:20 6:40:6 14:50:26
310 https://en.coolmay.com/
Real Time Clock Operation
This instruction executes subtraction of two time data, and stores the subtraction result to word devices.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S1. Continuous
FNC163 7 steps TSUB —
S2. operation
TSUB
D. Pulse
TSUBP
P operation
Specifies "hour" of the time data (hour, minute, and second) used in
S1. subtraction. (Three devices are occupied.)
Device: T, C, D, R, decoration
Specifies "hour" of the time data (hour, minute, and second) used in
Operand S2. subtraction. (Three devices are occupied.) 16-bit binary
Device: T, C, D, R, decoration
Stores the subtraction result (hour, minute, and second) of two time
D. data. (Three devices are occupied.)
Device: T, C, D, R, decoration
Explanation of 1. 16-bit operation (TSUB, TSUBP)
Instructions The time data (hour, minute, and second) stored in [S2., S2.+1, S2.+2] is subtracted from the time
data (hour, minute, and second) stored in [S1., S1.+1, S1.+2], and the subtraction result (hour,
minute, and second) is stored in [D., D.+1, D.+2].
When the operation result is smaller than 0 hour, the borrow flag turns ON, and the value simply
acquired by subtraction added by 24 hours is stored as the operation result.
When the operation result becomes "0" (0:0:0), the zero flag turns ON.
⚫ When utilizing the time (hour, minute, and second) of the real time clock built in a PLC, read the
values of special data registers using TRD (FNC166) instruction, and then specify those word
devices as the operands.
Program X10
example TSUB D0 D10 D20
311 https://en.coolmay.com/
Real Time Clock Operation
◆ When X10=ON, TSUB Instruction is executed, and the calendar data hours, minutes, and seconds specified by
D0~D2 are subtracted from the calendar data hours, minutes, and seconds specified by D10~D12, and the
obtained result is stored in the register hours, minutes and seconds specified by D20~D22.
D0 20 (hour) D10 14 (hour) D20 5 (hour)
D1 20 (minute) - D11 30 (minute) → D21 49 (minute)
D2 5 (second) D12 8 (second) D22 57 (second)
20:20:5 14:30:8 5:49:57
This instruction converts the time data in units of "hour, minute, and second" into data in units of "second".
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous Continuous
FNC164 S. 5 steps HTOS 9 steps DHTOS
operation operation
HTOS D.
Pulse
HTOSP DHTOSP Pulse operation
D P operation
Head device number storing the time data (hour, minute and second)
before
S. 16-bit binary
conversion
Operand
Device: KnX, KnY, KnM, KnS, T, C, D, R, decoration
Device number storing the time data (second) after conversion 16- or 32-bit
D.
Device: KnY, KnM, KnS, T, C, D, R, decoration binary
312 https://en.coolmay.com/
Real Time Clock Operation
⚫ An operation error is caused in the following case; The error flag M8067 turns ON, and the error
code is
stored in D8067.
• When the data of S., S.+1, S.+2 is outside the allowable range (error code: K6706)
Program
example
◆ In the program shown above, the time data read from the real time clock built in a PLC is converted into data in
units of "second", and stored to D100 and D101 when X020 turns ON.
1) Clock data reading operation by TRD (FNC166) instruction
Real time clock → D10 2020 Year
D11 4 Month
D12 16 Day
D13 20 Hour
D14 21 Minute
D15 23 Second
D16 4 Day of week
313 https://en.coolmay.com/
Real Time Clock Operation
This instruction converts the time data in units of "second" into data in units of "hour, minute, and second".
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous Continuous
FNC165 S. 5 steps STOH 9 steps DSTOH
operation operation
STOH D.
Pulse
STOHP DSTOHP Pulse operation
D P operation
Device number storing the time data (second) before conversion 16- or 32-bit
S.
Device: KnX, KnY, KnM, KnS, T, C, D, R, decoration binary
Head device number storing the time data (hour, minute and second)
Operand
after
D. 16-bit binary
conversion
Device: KnY, KnM, KnS, T, C, D, R, decoration
Explanation of 1. 16-bit operation (STOH and STOHP)
Instructions The time data in units of "second" stored in S. is converted into data in units of "hour, minute, and
second", and stored to [D.,D.+1,D.+2] (hour, minute, and second).
⚫ An operation error is caused in the following case; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the data of S. is outside the allowable range (error code: K6706)
Program
example
◆ In the program shown above, the time data in units of "second" stored in D0 and D1 is converted into data in
units of "hour, minute, and second", and stored to D100, D101, and D102 when X020 turns ON.。
314 https://en.coolmay.com/
Real Time Clock Operation
Converting the data in second into the data in hour, minute and second using STOHP instruction (when "40,000
seconds" is specified by D1 and D0)
D1,D0 D100 11 hour
40,000 → D101 6 minute
D102 40 second
This instruction reads the clock data of the real time clock built in a PLC.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous
FNC166 3 steps TRD —
D. operation
TRD
Pulse
TRDP
P operation
This instruction reads the real time clock data in a PLC, and transfers it to seven data registers.
Device Item Clock data Device Item
0~99 (lower two
D8018 Year → D. Year
digits)
Special data register
315 https://en.coolmay.com/
Real Time Clock Operation
This instruction writes the clock data to the real time clock built in a PLC.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous
FNC167 3 steps TWR —
S. operation
TWR
Pulse
TWRP
P operation
Specifies the head device number to which the clock data is written.
Operand S. (Seven devices are occupied.) 16-bit binary
Device: T, C, D, R, decoration
316 https://en.coolmay.com/
Real Time Clock Operation
Program
example
◆ In the program example shown above, the real time clock is set (to 15:20:30 on Wednesday, April 15, 2020).
◆ The contents of D0~D6 is set as time of the new calendar.
◆ X0=ON is to change the current time of the calendar clock to the set value.
◆ Every time X1 is set to ON, the current time can be corrected by ±30 seconds. The correction is that when the
second hand is between 1~29, it will be automatically classified as "0" seconds and the minute hand will not
change. When it is 30~59, it will also be automatically classified as "0" seconds and the minute hand plus 1
minute.
◆ D8018 will specify the 4-digit year mode in the second scan and later after the PLC mode is changed to RUN.
- A PLC is normally operating in the 2-digit year mode. When the above instruction is executed and "K2000
(fixed value)" is transferred to D8018 (year) in only one operation cycle after the PLC mode was changed
to RUN, the year mode is switched to the 4-digit mode.
- Execute this program every time the PLC mode is changed to RUN. Even if "K2000" is transferred, only the
display format is changed to the 4-digit year mode. The current date and time are not affected.。
- In the 4-digit year mode, the set values "80 to 99" correspond to "1980 to 1999", and "00 to 79" correspond
to "2000 to 2079".
Examples: "80" indicates 1980. "99" indicates 1999. "00" indicates 2000. "79" indicates 2079.
317 https://en.coolmay.com/
Real Time Clock Operation
This instruction measures the ON time of the input contact in units of hour.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
S.
FNC169 Continuous Continuous
D1. 7 steps HOUR 13 steps DHOUR
HOUR operation operation
D2.
D
S.: Time after which D2. is set to ON. Specify a value in units of hour.
D1.: Current value in units of hour
D1.+1: Current value less than one hour (unit: second)
D2.: Alarm output destination. It turns ON when the current value D1. exceeds the time specified
in S..
⚫ Specify a latched (battery backed) type data register as so that the current value data can be
318 https://en.coolmay.com/
Real Time Clock Operation
Program
example
◆ When X0=ON, Y10 turns on and starts timing. When it reaches 100 hours, Y0 turns on, and D0 will record the
current time value (unit: hour) during the measurement, and D1 will record the current time value less than 1
hour during the measurement. 0 ~3599 (unit: second)
319 https://en.coolmay.com/
External Devices
External Devices
FNC Device
Instruction Function
NO. 3G PLC 2N PLC MX2N PLC
Decimal to Gray
170 GRY ★
Code Conversio
Gray Code to
171 GBIN ★
Decimal Conversion
172 —
173 —
174 —
175 —
★ Modbus communication to read slave
Read form Dedicated data
176 RD3A ★
Analog Block (Note: The read function of the original
Mitsubishi analog module is not available)
★ Modbus communication write data to
Write to Dedicated slave
177 WR3A ★
Analog Block (Note: The original Mitsubishi analog
module write function is not available)
178 —
179 —
320 https://en.coolmay.com/
External Devices
This instruction converts a binary value into a gray code, and transfers it.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous Continuous
FNC170 S. 5 steps GRY 9 steps DGRY
operation operation
GRY D.
Pulse
GRYP DGRYP Pulse operation
D P operation
Conversion source data or word device storing conversion source data 16- or 32-bit
S.
Device: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, decoration binary
Operand
Word device storing data after conversion 16- or 32-bit
D.
Device: KnY, KnM, KnS, T, C, D, R, V, Z, decoration binary
Program
example
◆ When X0=ON, convert the constant K6513 to Gray code and store it in K4Y20.
321 https://en.coolmay.com/
External Devices
This instruction converts a gray code into a binary value, and transfers it.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous Continuous
FNC171 S. 5 steps GBIN 9 steps DGBIN
operation operation
GBIN D.
Pulse
GBINP DGBINP Pulse operation
D P operation
Conversion source data or word device storing conversion source data 16- or 32-bit
S.
Device: KnX, KnY, KnM, KnS, T, C, D, R, V, Z, K, H, decoration binary
Operand
Word device storing data after conversion 16- or 32-bit
D.
Device: KnY, KnM, KnS, T, C, D, R, V, Z, decoration binary
⚫ When an input relay (X) is specified as S., the response relay will be “Scan time of PLC + Input
filter constant”.
The input filter value in X000 to X017 *1 can be converted using the REFF (FNC51) instruction or
D8020 (filter adjustment) so that the delay caused by the filter constant is eliminated.
322 https://en.coolmay.com/
External Devices
Program
example
◆ When X0=ON, convert the gray code of the absolute position encoder connected to the X0~X17 input points
into BIN values and store them in D10.
323 https://en.coolmay.com/
Other Instructions
Other Instructions
FNC Device
Instruction 功能
NO. 3G PLC 2N PLC MX2N PLC
181 —
182 COMRD Read device comment data ★
183 —
184 RND Random Number Generation ★
185 —
186 DUTY Timing pulse generation ★
187 —
188 CRC Cyclic Redundancy Check ★
189 HCMOV High speed counter move
324 https://en.coolmay.com/
Other Instructions
This instruction reads the comment data for registered devices written to the PLC by programming software
such as GX Developer.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
Continuous
FNC182 S. 5 steps COMRD —
operation
COMRD D.
Pulse
COMRDP —
P operation
⚫ M8091=ON, D.+8=0000H
M8091=OFF, D.+8 does not change
⚫ Specify a device number in device S. for which a comment is registered in the PLC.
If a comment is not registered for the device S., "20H" (space) is stored in D. and later for the
number of characters in the comment (16 half-width characters).
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When a comment is not registered for the device S. (error code: K6706)
• When the range of points used from D. for the comment exceeds the corresponding device
range (error code: K6706)
325 https://en.coolmay.com/
Other Instructions
Program
example
◆ X10=ON, the comment "Target Line A" registered to D100 is stored in ASCII code in D0 when M8091 is OFF.
326 https://en.coolmay.com/
Other Instructions
Program
example
◆ In the program example shown below, a random number is stored to D100 every time X010 turns ON.
When the PLC mode switches from STOP to RUN, the time data converted into seconds and added by the
value “(Year + Month) × Day” is written to D8311 and D8310.
327 https://en.coolmay.com/
Other Instructions
This instruction generates the timing signal whose one cycle corresponds to the specified number of operation
cycles.
Operand
Instruction Functions
type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
instruction condition instruction condition
n1
FNC186 Continuous
n2 7 steps DUTY —
DUTY operation
D.
—
2) D8330~D8Specify either one among M8330 to M8334 as the timing clock output destination
device D..
The counted number of scans stored in either one among D8330 to D8334 is reset when the
counted value reaches "n1+n2" or when the command input (instruction) is set to ON.
Timing clock output destination device D. Scan counting device
M8330 D8330
M8331 D8331
M8332 D8332
M8333 D8333
M8334 D8334
3) When the command input is set to ON, the operation is started. The timing clock output
destination device D. is set to ON or OFF by END instruction.
Even if the command input is set to OFF, the operation is not stopped. In the STOP mode, the
328 https://en.coolmay.com/
Other Instructions
operation is suspended. When the power of the PLC is turned OFF, the operation is stopped.
4) When "n1" and "n2" are set to "0", the device D. is set to the following status:
n1/n2 status D. ON/OFF status
Program
example
◆ In the program shown below, when X0 is set to ON, M8330 is set to ON for 1 scan and OFF for 3 scans.
329 https://en.coolmay.com/
Other Instructions
This CRC instruction calculates the CRC (cyclic redundancy check) value which is an error check method used
in communication.
In addition to CRC value, there are other error check methods such as parity check and sum check. For
obtaining the horizontal parity value and sum check value, CCD (FNC 84) instruction is available.
CRC instruction uses [X16+X15+X2+1] as a polynomial for generating the CRC value (CRC-16).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S. Continuous
7 step CRC —
FNC188 D. Operation
CRC n Pulse
CRCP (Single) —
P
Operation
Head device number storing data for which the CRC value is generated
S.
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, Modify
Device number storing the generated CRC value
Operand D.
Applicable devices: KnY, KnM, KnS, T, C, D, R, Modify BIN16 bit
number
Number of 8-bit (1-byte) data for which the CRC value is generated or
n the device number storing the number of data
Applicable devices: D, R, K, H
Instruction 1. 16-bit operation(CRC)
Explanation CRC value is generated for “n” 8-bit data (unit: byte) starting from a device specified in S., and
stored to D..
The 8-bit conversion mode and 16-bit conversion mode are available in this instruction, and the
mode can be switched by turning ON/OFF of M8161. For the operation in each mode, refer to the
following pages.
[X16+X15+X2+1] is used as a polynomial for generating the CRC value (CRC-16).
In this mode, the operation is executed for high-order 8 bits (1 byte) and low-order 8 bits (1 byte)
of a device specified in S..
The operation result is stored to one 16-bit device specified in D..
In this mode, the operation is executed only for low-order 8 bits (low-order 1 byte) of a device
specified by S..
330 https://en.coolmay.com/
Other Instructions
With regard to the operation result, low-order 8 bits (1 byte) are stored to a device specified by D.,
and high-order 8 bits (1 byte) are stored to a device specified by D.+1.
⚫ In this instruction, [X16+X15+X2+1]” is used as a polynomial for generating the CRC value (CRC-
16).
There are many other standard polynomials for generating the CRC value. Note that the CRC
value completely differs if an adopted polynomial is different.
Name Polynomial
CRC-12 X12+X11+X3+X2+X+1
CRC-16 X16+X15+X2+1
CRC-32 X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1
CRC-CCITT X16+X12+X5+1
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When any digits other than 4 digits are specified as S. or D. in digit specification of bit device
(error code: K6706)
• n is outside the allowable range (1 to 256) (error code: K6706)
M8001
Program M8161 16-bit conversion mode
Example 1
X
0 CRC D100 D0 K7
Data content
Registers (High/Low
byte)
D100 3130H
D101 3332H
Device storing data for which CRC value is generated
D102 3534H
D103 3736H
◆ X0=ON, the CRC value of the ASCII code “0123456” stored in D100 to D106 is generated and stored to D0.
M8000
Program M8161 8-bit conversion mode
Example 2
X
0 CRC D100 D0 K7
331 https://en.coolmay.com/
Other Instructions
Data content
Registers (High/Low
byte)
D100 30H
D101 31H
D102 32H
Device storing data for which CRC
D103 33H
value is generated
D104 34H
D105 35H
D106 36H
◆ X0=ON, the CRC value of the ASCII code “0123456” stored in D100 to D106 is generated and stored to D0.
332 https://en.coolmay.com/
Other Instructions
This instruction updates the current value of a specified high speed counter or ring counter.
Operand
Instruction Function
Type
16-bit Operation 32- Operation
Mnemonic Mnemonic
Instruction Condition bitInstruction Condition
S.
FNC189 Continuous
D. 13 steps DHCMOV
HCMOV Operation
n
D
1) The current value of a high speed counter or ring counter specified in S. is transferred to [D.+1,
D.].
High speed counter C235~C255 Current value of high speed counter S.→[D.+1, D.]
2) After transfer, the current value of the high speed counter or ring counter is processed as
shown in the table below depending on the set value of "n":
333 https://en.coolmay.com/
Other Instructions
- When the current value of a high speed counter is compared using CMP, ZCP or
comparison contact instruction (not using a designated high speed counter comparison instruction), a
hardware counter does not change into a software counter.
- When the number of high speed software counter comparison instructions is reduced, the
- When it is necessary to execute comparison and change an output contact (Y) as soon as
the current value of a high speed counter changes, use a designated high speed counter comparison
instruction (HSCS, HSCR or HSZ).
3. Cautions
When programming DHCMOV instruction in an input interrupt program, the following points
should be observed.
1) Program EI (FNC 04) and FEND (FNC 06) instructions in the main program. They are
necessary to execute an input interrupt program.
2) When programming DHCMOV instruction in the 1st line in an input interrupt program, make
sure to use the pattern program shown below.
Make sure to use the command contact M8394.
3) If two or more DHCMOV instructions are used in one input interrupt program, only the first
instruction (just after the interrupt pointer) is executed when the interrupt is generated.
The rest of the interrupt, including additional DHCMOV instructions, is executed according to
normal interrupt processing.
334 https://en.coolmay.com/
Other Instructions
Do not use M8394 as the command contact for the DHCMOV instructions following the first.
4) It is not permitted to use DHCMOV instruction for the same counter in two or more input
interrupt programs.
5) While input interrupts are disabled by the interrupt disable flags (shown in the table below),
DHCMOV instructions are not executed when they are placed inside a corresponding interrupt.
Input interrupt pointer
Input Interrupt disable flag
Rising edge interrupt Falling edge interrupt
X000 I001 I000 M8050
X001 I101 I100 M8051
X002 I201 I200 M8052
X003 I301 I300 M8053
X004 I401 I400 M8054
X005 I501 I500 M8055
6) If an input interrupt is generated while input interrupts are disabled by something other than the
interrupt disable flags M8050 to M8055 (after execution of DI instruction and before execution of EI
instruction),DHCMOV instruction is immediately executed, but execution of the interrupt program is
held. The interrupt program will be executed after EI instruction is executed and interrupts are
enabled.
⚫ An operation error occurs in the following case; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When a device specified in S.、[D.+1, D.] is outside the allowable range (error code: K6705)
Program
Example 1
*1. K0: The current value of the high speed counter is not cleared when DHCMOV instruction is executed.
K1: The current value of the high speed counter is cleared when DHCMOV instruction is executed.
◆ In the program example below, the current value of the high speed counter C235 is compared in each
operation cycle, and then the output Y000 is set to ON if the current value is "K500" or more (when the current
value of C235 is not cleared).
335 https://en.coolmay.com/
Other Instructions
Program
Example 2
*1. K0: K0: The current value of the high speed counter is not cleared when DHCMOV instruction is executed.
K1: The current value of the high speed counter is cleared when DHCMOV instruction is executed.
◆ In the program example shown below, the current value of C235 is transferred to D201 and D200, and the
current value of C235 is cleared when X001 turns from OFF to ON.
336 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
337 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
2. 32-bit operation(DBK+,DBK+P)
1) "2n" 32-bit binary data starting from [S2.+1, S2.] are added to "2n" 32-bit binary data starting
from [S1.+1, S1.], and the operation result is stored in "2n" points starting from [D.+1, D.].
338 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
- 16-bit operation
- 32-bit operation
Program X2
Example 2 0 BK+ D100 D150 D200 D0
◆ In the program shown below, the specified number of data stored in D150 to D0 are added to the specified
number of data stored in D100 to D0 when X020 is set to ON, and the operation result is stored in D200 and later.
339 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
2. 32-bit operation(DBK-,DBK-P)
1) "2n" 32-bit binary data starting from[S2.+1, S2.] are subtracted from "2n" 32-bit binary data
starting from [S1.+1, S1.], and the operation result is stored in "2n" points starting from[D.+1, D.].
340 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
- 16-bit operation
- 32-bit operation
Program X1
Example 0 BK-P D100 K8765 D200 K3
◆ In the program shown below, the constant "8765" is subtracted from the data stored in D100 to D102 when X010
is set to ON, and the operation result is stored in D200 and later.
b15——b0 b15——b0
D100 K12345 b15——b0 D200 K3580
D101 K8701 - K8765 D201 K-64
D102 K3502 D202 K-5263
341 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
These instructions compare block data in the comparison condition set in each instruction.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1.
Continuous Continuous
FNC194 S2. 9 steps BKCMP= 17 steps DBKCMP=
Operation Operation
BKCMP= D.
Pulse (Single) Pulse (Single)
n BKCMP=P DBKCMP=P
D P Operation Operation
342 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
343 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
4) When the comparison result is ON (1) in all of "n" points starting from D., M8090 (block
comparison signal) turns ON.
2. 32-bit operation((DBKCMP=,>,<,<>,<=,>=/DBKCMP=P,>P,<P,<>P,<=P,>=P)
1) "n" 32-bit binary data starting from [S1.+1, S1.] are compared with "n" 32-bit binary data
starting from [S2.+1, S2.], and the comparison result is stored in "n" points starting from D.
2) A constant can be directly specified in [S1.+1, S1.].
3. When the comparison result is ON (1) in all “block compare signal, M8090, data block
instruction” turns ON.
⚫ When using 32-bit counters (including 32-bit high speed counters)
For comparing 32-bit counters and 32-bit high speed counters (C200 to C255), make sure to
use an instruction for 32-bit operation (DBKCMP=, DBKCMP>, DBKCMP<, DBKCMP<>,
DBKCMP<=, or DBKCMP>=).
If an instruction for 16-bit operation (BKCMP=, BKCMP>, BKCMP<, BKCMP<>, BKCMP<=, or
BKCMP>=) is used, an operation error is caused (error code: K6705).
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the
error code is stored in D8067.
• When the range of "n" ("2n" in 32-bit operation) points starting from S1.,S2. exceeds the
corresponding device range (error code: K6706)
• When the range of "n" points starting from D. exceeds the corresponding device range (error
code: K6706)
• When data registers starting from D. specified as "D.b" overlap "n" ("2n" in 32-bit operation)
points starting from S1. (error code: K6706)
• When data registers starting from D. specified as "D.b" overlap "n" ("2n" in 32-bit operation)
points starting from S2. (error code: K6706)
• When a 32-bit counter (C200 to C255) is specified in S1.,S2. in 16-bit operation (error code:
K6705)
For comparing 32-bit counters, make sure to use an instruction for 32-bit operation
(DBKCMP=,DBKCMP>, DBKCMP<, DBKCMP<>, DBKCMP<=, or DBKCMP>=).
344 https://en.coolmay.com/
Block Data Operation – FNC190 to FNC199
Program
Example 1
◆ In the program shown below, four 16-bit binary data starting from D100 are compared with four 16-bit binary
data starting from D200 by BKCMP= (FNC194) instruction when X020 is set to ON, and the comparison result
is stored in four points starting from M10.
When the comparison result is "ON (1)" in all of the four points starting from M10, Y000 is set to ON.
Y0 OFF
(When M10~m13 are
on,Y0=ON)
Program
Example 2
◆ In the program shown below, the constant K1000 is compared with four data starting from D10 when X010 is set
to ON, and the comparison result is stored in b4 to b7 of D0.
b15 b7 b4 b0
D10 K2000 D0 before 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0
operation
K1000 <> D11 K1000
D12 K1000
D13 K2222 b15 b7 b4 b0
D0 after 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0
operation
345 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
346 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction converts binary data into character strings (ASCII codes).
On the other hand, the ESTR (FNC116) instruction converts floating point data into character strings.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7steps STR 17steps DSTR
FNC200 Operation Operation
S2.
STR Pulse
D. Pulse (Single)
STRP (Single) DSTRP
D P Operation
Operation
- As the sign, "space" (20H) is stored when the 16-bit binary data stored in S2. is positive, and "-
"(2DH) is stored when the 16-bit binary data stored in S2. is negative.
- When the number of digits of the decimal part S1.+1 is set to any value other than "0", the
decimal point ".(2EH)" is automatically added in "number of digits of decimal part S1.+1"the
digit. When the number of digits of the decimal part +1 is set to "0", the decimal point is not
347 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
added.
- When the number of digits of the decimal part S1.+1 is larger than the number of digits of
16-bit binary data stored in S2., "0" (30H) is automatically added, and the data is shifted to the
right end during conversion.
- When the number of all digits stored in S1. excluding the sign and decimal point is larger than
the number of digits of 16-bit binary data stored in S2., "space" (20H) is stored in each digit
between the sign and the numeric value.
When the number of all digits stored in S1. excluding the sign and decimal point is smaller than
the number of digits of 16-bit binary data stored in S2., an error is caused.
- "00H" indicating the end of a character string is automatically stored at the end of a converted
character string. When the number of all digits is even, "0000H" is stored in the device after the
last character. When the number of all digits is odd, "00H" is stored in the high-order byte (8 bits)
of the device storing the final character.
2. 32-bit operation(DSTR、DSTRP)
1) All digits (specified by S1.) of 32-bit binary data stored in [S2.+1, S2.] are converted into ASCII
codes while the decimal point is added to the position specified by the device storing the number
of digits of the decimal part ( S1.+1), and stored in D. and later.
2) Set the number of all digits S1. in the range from 2 to 13.
3) Set the number of digits of the decimal part S1.+1 in the range from 0 to 10.
Make sure to satisfy "Number of digits of decimal part <= (Number of all digits -3)".
4) 32-bit binary data (BIN)S2. to be converted ,should be within the range from -2,147,483,648 to
+2,147,483,647.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the range of "n" ("2n" in 32-bit operation) points starting from S1.,S2.,D. exceeds the
corresponding device range (error code: K6706)
• When "n" points starting from S1. and "n" points starting from D. repeat ("2n" in 32-bit
operation). (error code: K6706)
• When "n" points starting from S2. and "n" points starting from D. repeat ("2n" in 32-bit
operation). (error code: K6706)
Program
Example
348 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
◆ When X000=ON, Convert the BIN data (16 bits) saved in D10 to character string according to the number of
digits specified in D0 and D1, and then store it to D20~D23 Program.
This instruction converts a character string (ASCII codes) into binary data.
On the other hand, EVAL (FNC117) instruction converts a character string (ASCII codes) into floating point data.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S. 7 steps VAL 13 steps DVAL
FNC201 Operation Operation
D1.
VAL Pulse
D2. Pulse (Single)
VALP (Single) DVALP
D P Operation
Operation
2. 32-bit operation(DVAL,DVALP)
A character string stored in S. and later is converted into 32-bit binary data. The number of all
349 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
digits of the binary data acquired for conversion is stored in D1., the number of digits of the
decimal part is stored in D1.+1, and the binary data is stored in [D2.+1, D2.].
In conversion from a character string into binary data, the data from S. to a device number storing
"00H" is handled as a character string in byte units.
Number “0(30H)”~“9(39H)”
2) D1. stores the number of all digits. The number of all digits indicates the number of all
characters (including the number, sign and decimal point).
3) D1.+1 stores the number of digits of the decimal part. The number of digits of the decimal part
indicates the number of all characters after the decimal point "." (2EH).
4) D2./[D2.+1, D2.] stores 16-bit data (bin) converted from a character string with the decimal
point ignored.
For the character string located in and later, the "space" (20H) and "0" (30H) characters between
the sign and the first number other than "0" are ignored in the conversion to 32-bit binary data.
⚫ Store sign data, "space (20H)" or "- (2DH)", must be stored in the 1st byte (lower order 8 bits of
the head device set in S.).
Only the ASCII code data "0 (30H)" to "9 (39H)", "space (20H)" and "decimal point (2EH)" can be
stored from the 2nd byte to the "00H" at the end of the character string in S..
If "- (2DH)" is stored in the 2nd byte or later, an operation error (error code: K6706) occurs.
350 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
Program
Example 1
◆ X0=ON, the character string data stored in D20 to D22 is regarded as an integer value, converted into a binary
value, and stored in D0
Program
Example 2
◆ X0=ON,the character string data stored in D20 to D24 is regarded as an integer value,converted into a binary
value, and stored in D0
351 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
Head device number storing the link source data (character string) or
S1. directly specified character string
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, Modify
Operand Head device number storing the link data (character string) or directly Character
number S2. specified Character string string
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, Modify
Head device number storing the linked data (character string)
D.
Applicable devices: KnY, KnM, KnS, T, C, D, R, Modify
1) In linking, “00H” indicating the end of a character string specified in S1. is ignored, and a
character string specified in S2. is linked to the last character specified in S1. .When a character
string is linked, “00H” is automatically added at the end.
- When the number of characters after linking is odd, “00H” is stored in the high-order byte of
the device storing the last character.
- When the number of characters after linking is even, “0000H” is stored in the device after the
352 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
last character.
Program
Example
◆ X0=ON, a character string stored in D10 to D12 (abcde) is linked to the character string “ABCD”, and the result
is stored to D100
353 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction detects the number of characters (bytes) of a specified character string.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps LEN —
FNC203 S. Operation
LEN D. Pulse
LENP (Single) —
P
Operation
⚫ This instruction can handle character codes other than ASCII codes, but the character string
length is handled in byte units (8 bits). Accordingly, in the case of character codes in which 2
bytes express 1 character such as shift JIS codes, the length of 1 character is detected as “2”.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by S. (error
code: K6706)
• When the detected number of characters is “32768” or more (error code: K6706)
354 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
Program
Example 2
◆ X0=ON, the length of a character string stored in D0 and later is output in 4-digit BCD to Y10 to Y27.
b15---b8 b7---b0
D0 49H(I) 4DH(M)
D1 53H(S) 54H(T)
Conversion
D2 42H(B) 55H(U) D10 Y10~Y27
into BCD
D3 53H(S) 49H(I) 10 0 0 1 0
D4 49H(I) 48H(H) Characters BCD value
D5 61H(a) 00H “abc...”
after “00H”
D6 63H(c) 62H(b) are
ignored.
...
355 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction extracts a specified number of characters from the right end of a specified character string.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S. 5 steps RIGHT —
FNC204 Operation
D.
RIGHT Pulse
n
RIGHTP (Single) —
P
Operation
- When the number of extracted characters is odd, “00H” is stored in the high-order byte of a
- When the number of extracted characters is even, “0000H” is stored in the device after the last
character.
⚫ When handling character codes other than ASCII codes, note the following contents:
• The number of characters is handled in byte units (8 bits). Accordingly, in the case of character
codes in which 2 bytes express 1 character such as shift JIS codes, the length of 1 character is
detected as “2”.
• When extracting characters from a character string including character codes in which 2 bytes
express 1 character such as shift JIS codes, consider the number of characters to be extracted in
units of character codes for 1 character.
Note that the expected character code is not given if only 1 byte is executed out of a 2-byte
356 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
character code.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by S. (error
code:K6706)
• When “n” exceeds the number of characters specified by S. (error code: K6706)
• When the number of devices after a device number specified by D. is smaller than the number of
devices required to store extracted “n” characters (that is, when “00H” cannot be stored after all
character strings and the last character) (error code: K6706)
• When “n” is a negative value (error code: K6706)
Program
Example
◆ X0=ON, 4 characters are extracted from the right end of the character string data stored in R0 and later, and
stored to D0 and later
357 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction extracts a specified number of characters from the left end of a specified character string.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S. 7 steps LEFT —
FNC205 Operation
D.
LEFT Pulse
n
LEFTP (Single) —
P
Operation
- When the number of extracted characters is odd, “00H” is stored in the high-order byte of a
- When the number of extracted characters is even, “0000H” is stored in the device after the last
character.
⚫ When handling character codes other than ASCII codes, note the following contents:
• The number of characters is handled in byte units (8 bits). Accordingly, in the case of character
codes in which 2 bytes express 1 character such as shift JIS codes, the length of 1 character is
detected as “2”.
• When extracting characters from a character string including character codes in which 2 bytes
express 1 character such as shift JIS codes, consider the number of characters to be extracted in
units of character codes for 1 character.
358 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
Note that the expected character code is not given if only 1 byte is executed out of a 2-byte
character code.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by S. (error
code: K6706)
• When “n” exceeds the number of characters specified by S. (error code: K6706)
• When the number of devices after a device number specified by D. is smaller than the number
of devices required to store extracted “n” characters (that is, when “00H” cannot be stored after
all character strings and the last character) (error code: K6706)
• When “n” is a negative value (error code: K6706)
X10
Program LEFTP D100 R10 D0
Example 2
◆ X10=ON,the number of characters which is equivalent to the number stored in D0 are extracted from the left
end of the character string data stored in D100 and later, and stored to R10 and later.
359 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction extracts a specified number of characters from arbitrary positions of a specified character string.
Operand
Instruction Function
Type
16 -bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S1. 7s MIDR —
FNC206 Operation
D.
MIDR Pulse
S2.
MIDRP (Single) —
P
Operation
⚫ When handling character codes other than ASCII codes, note the following contents:
• The number of characters is handled in byte units (8 bits). Accordingly, in the case of character
codes in which 2 bytes express 1 character such as shift JIS code, the length of 1 character is
regarded as 2 characters.
• When extracting characters from a character string including character codes in which 2 bytes
express 1 character such as shift JIS codes, consider the number of characters to be extracted in
360 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by S1.
(error code: K6706)
• When the value specified by S2. exceeds the number of characters specified by S1. (error
code: K6706)
• When the number of characters specified by [S2.+1] from the position specified by D. exceeds
the device range specified by D. (error code: K6706)
• When the number of devices after a device number specified by D. is smaller than the number
of devices required to store extracted characters as many as the number specified by [S2.+1]
(that is, when “00H” cannot be stored after all character strings and the last character) (error
code: K6706)
• When “n” is a negative value (error code: K6706)
• When S2.+1 specifies “-2” or less (error code: K6706)
• When S2.+1 specifies a number larger than the number of characters specified by S1. (error
code: K6706)
X0
Program
MIDRP D10 D0 R0
Example
2
◆ X0=ON,four characters are extracted from the 3rd character from the left end of the character string data stored
in D10 and later, and then stored to D0.
361 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction replaces the characters in arbitrary positions inside designated character string with a specified
character string.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S1. 7 steps MIDW —
FNC207 Operation
D.
MIDW Pulse
S2.
MIDWP (Single) —
P
Operation
⚫ This instruction can handle character codes other than ASCII codes, but please note the
following:
• The number of characters is handled in byte units (8 bits). Accordingly, in the case of character
codes in which 2 bytes express 1 character such as shift JIS code, the length of 1 character is
regarded as 2 characters.
• When overwriting a character string including character codes in which 2 bytes express 1
character such as shift JIS codes, consider the number of characters to be extracted in units of
character codes for 1 character.
Note that the expected character code is not given if only 1 byte is overwritten out of a 2-byte
character code.
362 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by S1. or
D. (error code: K6706)
•When the value specified by S2. exceeds the number of characters of the character string stored
in D. and later (error code: K6706)
• When S2. n specifies a negative value (error code: K6706)
• When S2.+1 specifies “-2” or less (error code: K6706)
• When the number of characters specified by S2.+1 exceeds the number of characters specified
by S1. (error code: K6706)
Program X10
Example MIDWP D0 D100 R0
◆ X10=ON,4 characters are extracted from the character string data stored in D0 and later, and stored to the 3rd
character (from the left end) and later for the character string data stored in D100 and later
363 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
This instruction searches a specified character string within another character string.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous
9 steps INSTR —
FNC208 S2. Operation
INSTR D. Pulse
n INSTRP (Single) —
P
Operation
2) When the searched character string is not detected, "0" is stored in D..
3) When the search start position "n" is a negative number or "0", search processing is not
executed.
364 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the search start position "n" exceeds the number of characters stored in S2.(error code:
K6706).
• When "00H (NULL)" is not located within the corresponding device range starting from S1./S2.
(error code: K6706)
X0
Program
Example INSTR D0 R0 D100 K5
2
◆ X0=ON,the character string "CI23" (D0 and later) is searched from the 5th character from the left end (head
character) of the character string "CI2312CIM" (R0 and later),The search result is stored in D100.
365 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
Even if the device range [S.~S.+n] storing the transfer source character string data overlaps the
device range [S.~S.+n/2] storing the transferred character string data, transfer is executed.
⚫ When “00H” is stored in the low-order byte of S.+n, “00H” is stored to both the high-order byte
and low-order byte of D.+n.
366 https://en.coolmay.com/
Character String Control – FNC200 to FNC209
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When “00H” does not exist in the range specified from device S. (error code: K6706)
• When the specified character string cannot be stored in devices from the device specified by D.
to the last device (error code: K6706)
X
Program 0 $MOV D10 D20
Example
2
367 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
368 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
⚫ The device range used in a data table should be controlled by the user.
The data table has D. data starting from the next device ( D.+1) after D. indicating the number
of stored data.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the table position "n" of the data to be deleted exceeds the amount of data stored (error
code: K6706)
• When the value "n" exceeds the device range of the data table D. (error code: K6706)
369 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
• When the FNC210 instruction is executed under the condition "n ≤ 0" (error code: K6706)
• When the amount of data stored specified in D. is "0" (error code: K6706)
• When the data table range exceeds the corresponding device range (error code: K6706)
Program
Example
◆ The 2nd data entry is deleted from the data table stored in D100 to D105, and the deleted data is stored in D0.
When the amount of data stored is "0", however, the FDEL (FNC210) instruction is not executed. (The device
range used in the data table is D100~D107).
370 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
⚫ The device range used in a data table should be controlled by the user.
The data table has D. data starting from the next device ( D.+1) after D. indicating the number of
stored data.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the table position "n" for data insertion exceeds the amount of stored data plus 1(error
code: K6706)
• When the value "n" exceeds the device range of the data table D. (error code: K6706)
• When FNC211 instruction is executed under the condition "n ≤ 0" (error code: K6706)
• When the data table range exceeds the corresponding device range (error code: K6706)
371 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
Program
Example
◆ X010=ON,data stored in D100 is inserted into the 3rd position of the data table stored in D0 to D4.
When the amount of data stored exceeds "7", however, the FINS (FNC211) instruction is not executed.
(The device range used in the data table is D0 to D7)
372 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
This instruction reads the last data written by shift write (SFWR) instruction for FILO control.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
S. 7 steps POP —
FNC212 Operation
D.
POP Pulse
n
POPP (Single) —
P
Operation
Applicable devices: K, H
Description
S. Pointer data (amount of data stored)
S.+1
S.+2
S.+3
Data area
...
(First-in data written by shift write (SFWR) instruction)
S.+n-3
S.+n-2
S.+n-1
1) Every time the instruction is executed for the word devices [S.~S.+n-1], a device “S.+ Pointer
data S.” is read to D.. (The last data entry written by the shift write (SFWR) instruction for first-in
373 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
⚫ the zero flag M8020, when current value of the pointer S.=0, It turns ON after executing
Instruction.
⚫ When this instruction is programmed in the continuous operation type, the instruction is executed
in every operation cycle. As a result, an expected operation may not be achieved.
Usually, program this instruction in the “pulse operation type”, or let this instruction be executed
by a “pulsed command contact”.
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
Program
Example
◆ X0=ON, Among values stored in D20 input first to D101 to D106, the last value input is stored to D10, and “1” is
subtracted from the number of stored data (pointer D100)
◆ When the first-in data are as shown in the table below
Pointer D100 K3
D101 H1234
D102 H5678
D103 HABCD
Data
D104 H0000
D105 H0000
D106 H0000
374 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
This instruction shifts 16 bits stored in a word device rightward by “n” bits.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps SFR —
FNC213 D. Operation
SFR n Pulse
SFRP (Single) —
P
Operation
375 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
Program
Example 2
◆ X020=ON,the contents of Y010 to Y023 are shifted rightward by the number of bits specified by D0
This instruction shifts 16 bits stored in a word device leftward by “n” bits.
Operand
Instruction Function
Type
16-bit Operation 32-bt Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous
5 steps SFL —
FNC214 D. Operation
SFL n Pulse
SFLP (Single) —
P
Operation
376 https://en.coolmay.com/
Data Operation 3 – FNC210 to FNC219
2) The ON (1)/OFF (0) status of the “n+1”th bit (bit “n”) in the word device is transferred to the
carry flag M8022.
3) “0” is set to “n” bits from the least significant bit.
Program
Example 2
◆ X020=ON, the contents of Y010 to Y017 are shifted leftward by the number of bits specified by D0
377 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
378 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
These instructions compare numeric values, and set a contact to ON when the condition agrees so that an
operation is started.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC224 S1. Continuous Continuous
5 steps LD= 9 steps LDD=
LD= S2. Operation Operation
379 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
16-bit 32-bit
ON condition OFF condition
instruction instruction
1. Negative value
When the most significant bit is "1" in the data stored in S1. or S2. , it is regarded as a negative
value in comparison.
•In the 16-bit operation: bit 15
• In the 32-bit operation: bit 31
2. When using 32-bit counters (including 32-bit high speed counters)
Make sure to execute the 32-bit operation (such as "LDD=", "LDD>" and "LDD<") when
comparing 32-bit counters (C200 to C255).
If a 32-bit counter is specified in the 16-bit operation (such as "LD=", "LD>" and "LD<"), a
program error or operation error will occur.
3. Programming of data comparison instructions
When programming in GX Developer, symbols "≤" and "≥" cannot be input.
Separate "≤" into "<" and "=", and separate "≥" into ">" and "=" in input.
380 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
Program
Example
381 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
These instructions compare numeric values, and set a contact to ON when the condition agrees.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC232 S1. Continuous Continuous
5 steps AND= 9 steps ANDD=
AND= S2. Operation Operation
382 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
16-bit 32-bit
ON condition OFF condition
instruction instruction
1. Negative value
When the most significant bit is "1" in the data stored in S1.or S2. , it is regarded as a negative
value in comparison.
• In the 16-bit operation: bit 15
• In the 32-bit operation: bit 31
2. When using 32-bit counters (including 32-bit high speed counters)
Make sure to execute the 32-bit operation (such as "ANDD=", "ANDD>" and "ANDD<") when
comparing 32- bit counters (C200 to C255).
If 16-bit operation (such as "AND=", "AND>" and "AND<") is specified , a program error or
operation error will occur.
3. Programming of data comparison instructions
When programming in GX Developer, symbols "≤" and "≥" cannot be input.
Separate "≤" into "<" and "=", and separate "≥" into ">" and "=".
The input procedure is described below:
383 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
Operating procedure
a) Display the circuit program edit window, and put the cursor in a position where a data
comparison instruction is to be used.
b) Input "Instruction" → "space" → "value or device" → "space" → "value or device".
For an input example, refer to "Instruction input window in GX Developer" shown below.
c) Click the [OK] button.
d) Input other contacts and coil drive units consecutively.
Program
Example 2
384 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
These instructions compare numeric values, and set a contact to ON when the condition agrees.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
FNC240 S1. Continuous Continuous
5 steps OR= 9 steps ORD=
OR= S2. Operation Operation
385 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
16-bit 32-bit
ON condition OFF condition
instruction instruction
1. Negative value
When the most significant bit is "1" in the data stored in S1. or S2. , it is regarded as a negative
value in comparison.
• In the 16-bit operation: bit 15
• In the 32-bit operation: bit 31
2. When using 32-bit counters (including 32-bit high speed counters)
Make sure to execute the 32-bit operation (such as "ORD=", "ORD>" and "ORD<") when
comparing 32-bit counters (C200 to C255).
If a 32-bit counter is specified in the 16-bit operation (such as "ORD=", "OR>" and "OR<"), a
program error or operation error will occur.
3. Programming of data comparison instructions
When programming in GX Developer, symbols "≤" and "≥" cannot be input.
Separate "≤" into "<" and "=", and separate "≥" into ">" and "=".
The input procedure is described below:
386 https://en.coolmay.com/
Data Comparison – FNC220 to FNC249
Operating procedure
a) Display the circuit program edit window, and put the cursor in a position where a data
comparison instruction is to be used.
b) Input "Instruction" → "space" → "value or device" → "space" → "value or device".
For an input example, refer to "Instruction input window in GX Developer" shown below.
c) Click the [OK] button.
d) Input other contacts and coil drive units consecutively.
Program
Example
387 https://en.coolmay.com/
Data table operation
388 https://en.coolmay.com/
Data table operation
This instruction provides the upper limit value and lower limit value for an input numeric value, and controls the
output value using these limit values.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous Continuous
9 steps LIMIT 17 steps DLIMIT
FNC256 S2. Operation Operation
LIMIT S3. Pulse
Pulse (Single)
D. LIMITP (Single) DLIMITP
D P Operation
Operation
389 https://en.coolmay.com/
Data table operation
2. 32-bit operation(DLIMIT,DLIMITP)
Depending on how the input value (32-bit binary value) specified by [S3.+1, S3.] compares to the
range between [S1.+1, S1.] and [S2.+1, S2.], the output value [D.+1, D.] is controlled.
⚫ An operation error is caused when the instruction is executed in the setting status shown below;
The error flag M8067 turns ON, and the error code (K6706) is stored in D8067.
—16-bit operation, S1.>S2.
—32-bit operation, [S1.+1, S1.]>[S2.+1, S2.]
Program
Example
◆ X0=ON, the BCD data set in X020 to X037 is controlled by the limit values 500~5000,and the controlled value
is stored in D1.
• D0 < 500, D1=500.
390 https://en.coolmay.com/
Data table operation
This instruction provides the upper limit value and lower limit value.
Operand
Instruction Function
Type
16-bit Operation 32bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous Continuous
9 steps BAND 17 steps DBAND
FNC257 S2. Operation Operation
BAND S3. Pulse
Pulse (Single)
D. BANDP (Single) DBANDP
D P Operation
Operation
2. 32-bit operation(DBAND,DBANDP)
Depending on how the input value (32-bit binary value) specified by [S3.+1, S3.] compares to the
dead band range between [S1.+1, S1.] and [S2.+1, S2.], the output value [D.+1, D.] is controlled.
The output value is controlled as shown below:
391 https://en.coolmay.com/
Data table operation
- 16-bit operation
The output value is a 16-bit binary value with sign. Accordingly, if the operation result is outside
the range from -32768 to +32767, it is handled as follows:
Lower limit value of dead band Output value= -32, 768 - 10
S1.=10 =8000H-AH
Input value S3. =-32,768 =7FF6H
=32,758
- 32-bit operation
The output value is a 32-bit binary value with sign. Accordingly, if the operation result is outside
the range from -2,147,483,648 to +2,147,483,647, it is handled as follows:
⚫ An operation error is caused when the instruction is executed in the setting status shown below;
The error flag M8067 turns ON, and the error code (K6706) is stored in D8067.
—16-bit operation, S1.>S2.
—32-bit operation, [S1.+1, S1.]>[S2.+1, S2.]
392 https://en.coolmay.com/
Data table operation
Program
Example
◆ X000=ON, the BCD data set in X020 to X037 is controlled by the dead band from “-1000” to “+1000”, and a
controlled value is output to D1
• D0<(-1000),“D0 - (-1000)” is output to D1.
393 https://en.coolmay.com/
Data table operation
Depending on how the input value compares to positive or negative, the output value is controlled by the bias value
specified.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
S1. Continuous Continuous
9 steps ZONE 17 steps DZONE
FNC258 S2. Operation Operation
ZONE S3. Pulse
Pulse (Single)
D. ZONEP (Single) DZONEP
D P Operation
Operation
2. 32-bit operation(DZONE,DZONEP)
The bias value specified by [S1.+1, S1.] or [S2.+1, S2.] is added to the input value specified by
394 https://en.coolmay.com/
Data table operation
- 16-bit operation
The operation result is a 16-bit binary value with sign. Accordingly, if the output value is
outside the range from -32768 to +32767, it is handled as follows:
- 32-bit operation
The output value is a 32-bit binary value with sign. Accordingly, if the operation result is
outside the range from -2,147,483,648 to +2,147,483,647, it is handled as follows:
395 https://en.coolmay.com/
Data table operation
Program
Example
◆ X000=ON, the BCD data set in X020 to X037 is controlled by the zone from “-1000” to “+1000”, and the
controlled value is output to D1
• D0<0,“D0 + (-1000)” is output to D1.
• D0=0,“0” is output to D1.
• 0<D0,“D0 + 1000” is output to D1.
396 https://en.coolmay.com/
Data table operation
This instruction executes scaling of the input value using a specified data table, and outputs the result.
SCL2 (FNC269) is also available with a different data table configuration for scaling.
Operand
Instruction Function
Type
16-bit Operation 33-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps SCL 13 steps DSCL
FNC259 Operation Operation
S2.
SCL Pulse
D. Pulse (Single)
SCLP (Single) DSCLP
D P Operation
Operation
Input value used in scaling or device number storing the input value
S1.
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, K, H, Modify
Operand Head device number storing the conversion table used in scaling
S2. BIN16/32 bit
number Applicable devices: D, R, Modify
Device number storing the output value controlled by scaling
D.
Applicable devices: KnY, KnM, KnS, T, C, D, R, Modify
2. 32-bit operation(DSCL,DSCLP)
The input value specified in [S1.+1, S1.] is processed by scaling for the specified conversion
characteristics, and stored to a device number specified in [D.+1, D.]. Conversion for scaling is
executed based on the data table stored in a device specified in [S2.+1, S2.] and later.
If the output data is not an integer, however, the number in the first decimal place is rounded.
397 https://en.coolmay.com/
Data table operation
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the Xn data is not set in the ascending order in the data table (error code: K6706)
The data table is searched from the low-order side of device numbers in the data table in the
operation. Accordingly, even if only some Xn data is set in the ascending order in the data table,
the instruction is executed without operation error up to the area of the data table in which the Xn
data is set in the ascending order.
• When S1. is outside the data table (error code: K6706)
• When the value exceeds the 32-bit data range in the middle of operation (error code: K6706)
In this case, check whether the distance between points is not “65535” or more.
398 https://en.coolmay.com/
Data table operation
Program
Example
◆ the value input to D0 is processed by scaling based on the conversion table for scaling set in R0 and later, and
output to D10.
Setting
Set item Device content
s
Number of coordinate
R0 K6
points
X coordinate R1 K0
Point 1
Y coordinate R2 K0
X coordinate R3 K10
Point 2
Y coordinate R4 K50
X coordinate R5 K30
Point 3
Y coordinate R6 K100
X coordinate R7 K40
Point 4
Y coordinate R8 K45
X coordinate R9 K50
Point 5
Y coordinate R10 K30
X coordinate R11 K60
Point 6
Y coordinate R12 K0
399 https://en.coolmay.com/
Data table operation
This instruction converts numeric data expressed in decimal ASCII codes (30H to 39H) into binary data.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps DABIN 9steps DDABIN
FNC260 S Operation Operation
DABIN D. Pulse
Pulse (Single)
DABINP (Single) DDABINP
D P Operation
Operation
2. 32-bit operation(DDABIN,DDABINP)
Data stored in S.~S.+55 expressed in decimal ASCII codes (30H to 39H) is converted into 32-bit
binary data, and stored in [D.+1, D.].
3. Data explanation
400 https://en.coolmay.com/
Data table operation
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the sign data stored in S. (low byte) is any value other than "20H (space)" or "2DH (-)" (error
code: K6706)
• When an ASCII code for each digit stored in S.~S.+2(5) is any value other than "30H" to
"39H","20H (space)", or "00H (NULL)" (error code: K6706)
• When the numeric range of S.~S.+2(5) exceeds the device range (error code: K6706)
Program
Example
◆ X0=ON, the sign and decimal ASCII codes in five digits stored in D20 to D22 are converted into a binary value
and stored in D0
b15---b8 b7---b0
D20 20H(space) 2DH(-) D0
D21 32H(2) 20H(space) -276
(regarded as BIN
D22 36H(6) 37H(7)
-00276) value
401 https://en.coolmay.com/
Data table operation
This instruction converts binary data into decimal ASCII codes (30H to 39H).
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
5 steps BINDA 9 steps DBINDA
FNC261 S. Operation Operation
BINDA D. Pulse
Pulse (Single)
BINDAP (Single) DBINDAP
D P Operation
Operation
2. 32-bit operation(DBINDA,DBINDAP)
Each digit of 32-bit binary data stored in [S.+1, S. ] is converted into an ASCII code (30H to
39H),and stored in D. and later.
402 https://en.coolmay.com/
Data table operation
3. Data explanation
1) The numeric range of 16-bit binary data stored in is from -32768 to +32767;
The numeric range of 32-bit binary data stored in [S.+1, S. ] is from -2,147,483,648 to
+2,147,483,647. S.+5 high-order byte is ignored.
⚫ An operation error is caused in the following case; The error flag M8067 turns ON, and the error
code is stored in D8067
• When the occupied device point of storing the ASCII code character string exceeds the
corresponding device rang (error code: K6706).
Program
Example
2
◆ X000=ON, 16-bit binary data stored in D1000 is converted into decimal ASCII codes.and the ASCII codes
converted by PR (FNC 77) instruction are output one by one in the time division method to Y040 to Y051.
By setting to OFF the output character selector signal M8091 and setting PR mode flag M8027 ON, ASCII
codes up to "00H" are output.
403 https://en.coolmay.com/
Data table operation
This instruction executes scaling of the input value using a specified data table, and outputs the result.
SCL (FNC259) is also available with a different data table configuration for scaling.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
Mnemonic Mnemonic
Instruction Condition Instruction Condition
Continuous Continuous
S1. 7 steps SCL2 13 steps DSCL2
FNC269 Operation Operation
S2.
SCL2 Pulse
D. Pulse (Single)
SCL2P (Single) DSCL2P
D P Operation
Operation
Input value used in scaling or device number storing the input value
S1.
Applicable devices: KnX, KnY, KnM, KnS, T, C, D, R, K, H, Modify
Operand Head device number storing the conversion table used in scaling
S2. BIN16/32 bit
number Applicable devices: D, R, Modify
Device number storing the output value controlled by scaling
D.
Applicable devices: KnY, KnM, KnS, T, C, D, R, Modify
Instruction 1. 16-bit operation(SCL2,SCL2P)
Explanation The input value specified in S1. is processed by scaling for the specified conversion
characteristics, and stored to a device number specified in D.. Conversion for scaling is executed
based on the data table stored in a device specified in S2. and later.
If the output data is not an integer, however, the number in the first decimal place is rounded.
2. 32-bit operation(DSCL2,DSCL2P)
The input value specified in [S1.+1, S1.]is processed by scaling for the specified conversion
characteristics, and stored to a device number specified in [D.+1, D.]. Conversion for scaling is
executed based on the data table stored in a device specified in [S2.+1, S2.]and later.
If the output data is not an integer, however, the number in the first decimal place is rounded.
404 https://en.coolmay.com/
Data table operation
⚫ An operation error is caused in the following cases; The error flag M8067 turns ON, and the error
code is stored in D8067.
• When the Xn data is not set in the ascending order in the data table (error code: K6706)
The data table is searched from the low-order side of the device numbers in the data table in the
operation. Accordingly, even if only some Xn data is set in the ascending order in the data table,
the instruction is executed without operation error up to the area of the data table in which the Xn
data is set in the ascending order.
• When S1. is outside the data table (error code: K6706)
• When the value exceeds the 32-bit data range in the middle of operation (error code: K6706)
In this case, check whether the distance between points is not “65535” or more.
If the distance is “65535” or more, reduce the distance between points.
405 https://en.coolmay.com/
Data table operation
Program
Example
◆ The value input to D0 is processed by scaling based on the conversion table for scaling set in R0 and later, and
output to D10.
Setting
Set item Device content
s
Number of coordinate points R0 K6
Point 1 R1 K0
Point 2 R2 K10
Point 3 R3 K30
X coordinate
Point 4 R4 K40
Point 5 R5 K50
Point 6 R6 K60
Point 1 R7 K0
Point 2 R8 K50
Point 3 R9 K100
Y coordinate
Point 4 R10 K45
Point 5 R11 K30
Point 6 R12 K0
406 https://en.coolmay.com/
High Speed Processing 2
407 https://en.coolmay.com/
High Speed Processing 2
This instruction compares the current value of a high speed counter with a data table of comparison points,and then
sets or resets up to 16 output devices.
Operand
Instruction Function
Type
16-bit Operation 32-bit Operation
S1. Mnemonic Mnemonic
Instruction Condition Instruction Condition
m
FNC280 Continuous Continuous
S2. 9 steps HSCT 21 steps DHSCT
HSCT Operation Operation
D.
D n
408 https://en.coolmay.com/
High Speed Processing 2
S1.+3m-2,
m-1 S1.+3m-1
S1.+3m-3
1) When this instruction is executed, the data table is set as the comparison target.
2) When the current value of the high speed counter, specified in S2., becomes equivalent to the
comparison value in the data table, the corresponding operation output specified in the data table
is output to D.~D.+n-1.
If an output (Y) is specified in D., the output processing is executed immediately without waiting for
the output refresh executed by the END instruction.
When specifying an output (Y), make sure that the least significant digit of the device number is “0”.
Examples: Y000, Y010 and Y020
3) Immediately after step 2), “1” is added to the current table counter value D8138.
4) The next comparison point is set as the comparison target data.
5) Steps 2) and 3) are repeated until the current value of the table counter D8138 becomes "m".
When the current value becomes "m", the instruction execution complete flag M8138 turns ON, and
the execution returns to step 1). At this time, the table counter D8138 is reset to "0".
6) When the command contact is set to OFF, execution of the instruction is stopped and the table
counter D8138 is reset to “0”.
⚫ Related device
Device Name Description
HSCT(FNC280) instruction Turns ON when the operation for the final table No.
M8138
execution complete flag "m-1" is completed
Stores the comparison point number handled as the
D8138 HSCT(FNC280) table counter
comparison target.
⚫ Cautions
• This instruction can be executed only once in a program.
If this instruction is programmed two or more times, an operation error is caused by the second
instruction and later, and the instruction will not be executed. (error code: K6765)
• This instruction constructs the data table at the END instruction of the first execution of the
instruction.
Accordingly, the operation output works after the second scan and later.
409 https://en.coolmay.com/
High Speed Processing 2
⚫ An operation error occurs in the following cases; The error flag M8067 turns ON, and the error code
is stored in D8067.
• When any devices other than high speed counters C235 to C255 are specified in S2. (error code:
K6706)
• When the “3m-1”th device from a device specified in S1. exceeds the last number of the device
(error code: K6706)
• When the “n”th device from a device specified in D. exceeds the last number of the device (error
code: K6706)
• When this instruction is used two or more times in a program (error code: K6765)
• DHSCT Instruction(FNC280), DHSCS Instruction(FNC53), DHSCR Instruction(FNC54) and
DHSZ Instruction (FNC55) up to 32 instructions can be executed in one operation cycle. An
operation error is caused by the 33rd instruction and later, and the instruction will not be executed.
(error code: K6705)
Program
Example
◆ The current value of C235 (counting X000) is compared with the comparison data table set in R0 and later, and
410 https://en.coolmay.com/
High Speed Processing 2
◆ Operation
Comparison data SET/RESET pattern
Comparis Operation
Compariso Table counter D8138
on point Device Device output set
n value
value
0 R1,R0 K100 R2 H0007 0↓
1 R4,R3 K150 R5 H0004 1↓
2 R7,R6 K200 R8 H0003 2↓
3 R10,R9 K250 R11 H0006 3↓
4↓ (Repeated from
4 R13,R12 K300 R14 H0008
“0↓”)
411 https://en.coolmay.com/