04 Logic operation

Last modified by Wecon on 2025/09/03 21:03

NEG/16-bit complement

NEG(P)

After inverting the sign of the BIN 16-bit device specified in (D), store it in the device specified in (D).

-[NEG (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(D)The start device that stores the data complement of 2-32768 to 32767Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSD[D]XXP
NEGParameter 1

Features

• Invert the sign of the BIN 16-bit device specified in (D), and store it in the device specified in (D).

• Used when inverting positive and negative signs.

07-2 Basic instructions_html_e312c1e31069e2d4.gif

Note:  If the continuous execution (NEG) instruction is used, every operation cycle will be inverted, so care should be taken.

Error code

Error codeContent
4085HThe output results of (D) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

In the two examples below, if D2=K4 and D4=K8, or D2=K8 and D10 is always K4.

Each time M0 is set, the device value specified in D0 is reversed.

07-2 Basic instructions_html_2132585087342c30.png

Take the absolute value of the difference of the subtraction operation.

If D2>D4, M10=On. If D2=D4, M11=On. If D2 <D4, M12=On. This ensures that D10 is positive.

It can also be represented by the following program:

07-2 Basic instructions_html_556a8b0e76d56e69.png

When bit15 of D10 is "1" (indicating that D10 is a negative number), M10 = On, use NEG instruction to complement D10 to obtain the absolute value of D10.

In the above two examples, if D2=K4, D4=K8; or D2=K8, D4=K4, the result of D10 is K4.

07-2 Basic instructions_html_7f069b4614002759.png

DNEG/32-bit complement

DNEG(P)

After inverting the sign of the BIN 32-bit device specified in (D), store it in the device specified in (D).

-[DNEG (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(D)The start device that stores the data complement of 2-2147483648 to 2147483647Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSC[D]XXP
DNEGParameter 1

Features

• Invert the sign of the BIN 32-bit device specified in (D) and store it in the device specified in (D).

• Used when inverting positive and negative signs.

07-2 Basic instructions_html_2c49bdf6350757d4.gif

Note:  If you use continuous execution (DNEG) instructions, every operation cycle will be inverted, so care should be taken.

Error code

Error codeContent
4085HThe output results of (D) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_74a6d3ba81b63aee.png

Each time M0 is set, the device value specified in (D1, D0) is reversed.

WOR/16-bit data logical OR

WOR(P)

Perform a logical OR operation on the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

-[WOR (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Stores data for logical OR operation or a device that stores data-32768 to 32767Signed BIN16ANY16_S
(S2)Stores data for logical OR operation or a device that stores data-32768to 32767Signed BIN16ANY16_S
(D)Device for storing logic or result Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
WORParameter 1
Parameter 2
Parameter 3   

Features

• Perform a logical OR operation on the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_577fdb83f8f4ac27.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_5053e0a466bb7318.png

When M0 is set, (D0) and (D2) are logically performed, and the value is stored in (D4), that is (D0)∨(D2) → (D4)

DOR/32-bit data logical OR

DOR(P)

After inverting the sign of the BIN 32-bit device specified in (D), store it in the device specified in (D).

-[DOR (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Stores data for logical OR operation or a device that stores data-2147483648 to 2147483647Signed BIN32ANY32_S
(S2)Stores data for logical OR operation or a device that stores data-2147483648 to 2147483647Signed BIN32ANY32_S
(D)Device for storing logic or result Signed BIN32ANY32_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DORParameter 1
Parameter 2
Parameter 3   

Features

Perform a logical OR operation on the BIN 32-bit data of the device specified in (S1) and the BIN 32-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_bb912c99e5c93989.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_423c26ee78752585.png

When M0 is set, (D1, D0) and (D3, D2) are logically performed, and the value is stored in (D5, D4), that is, (D1, D0)∨(D3, D2) → (D5, D4) ).

WAND/16-bit data logic AND

WAND(P)

Perform a logical AND operation on each bit of the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

-[WAND (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Store the data for logical AND operation or the device storing the data-32768to 32767Signed BIN16ANY16_S
(S2)Store the data for logical AND operation or the device storing the data-32768 to 32767Signed BIN16ANY16_S
(D)Device for storing logic and result Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
WANDParameter 1
Parameter 2
Parameter 3   

Features

Perform a logical AND operation on each bit of the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_747116a5868e9cae.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_ec0f27d69e3af67c.png

When M0 is set, the logical AND operation of (D0) and (D2) is performed, and the value is stored in (D4), that is, (D0) ∧ (D2) → (D4).

DAND/32-bit data logic AND

DAND(P)

Perform a logical AND operation on each bit of the BIN 32-bit data of the device specified in (S1) and the BIN 32-bit data of the device specified in (S2), and store the result in the device specified in (D).

-[DAND (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Store the data for logical AND operation or the device storing the data-2147483648 to +2147483647Signed BIN32ANY32_S
(S2)Store the data for logical AND operation or the device storing the data-2147483648 to +2147483647Signed BIN32ANY32_S
(D)Device for storing logic and result Signed BIN32ANY32_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DANDParameter 1
Parameter 2
Parameter 3   

Features

Perform a logical AND operation on each bit of the BIN 32-bit data of the device specified in (S1) and the BIN 32-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_d9420065526258ca.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_e15899d53dfb9234.png

When M0 is set, perform logical AND operation of (D1, D0) and (D3, D2), and store the value in (D5, D4), (D1, D0) ∧ (D3, D2) → (D5, D4) .

WXOR/16-bit data logic exclusive OR

WXOR(P)

Perform an exclusive OR operation on the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

-[WXOR (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Store the data for exclusive OR operation or the device storing the data-32768 to 32767Signed BIN16ANY16_S
(S2)Store the data for exclusive OR operation or the device storing the data-32768 to +32767Signed BIN16ANY16_S
(D)Device for storing XOR result Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
WXORParameter 1
Parameter 2
Parameter 3   

Features

• Perform logical exclusive OR operation on the BIN 16-bit data of the device specified in (S1) and the BIN 16-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_b773cd9541896655.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2) in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

Example 1: When M0 is set, (D0) and (D2) are XOR operation, and the value is stored in (D4), (D0)∀(D2)→(D4).

07-2 Basic instructions_html_a370b8b6c3ff8c95.png

Example 2: When used with the CML instruction, it can realize the logic exclusive OR (XORNOT) operation:

07-2 Basic instructions_html_298dc006a2888d78.png

DXOR/32-bit data logic exclusive OR

DXOR(P)

Perform an exclusive OR operation on the BIN 32-bit data of the device specified in (S1) and the BIN 32-bit data of the device specified in (S2), and store the result in the device specified in (D).

-[DXOR (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Store the data for exclusive OR operation or the device storing the data-2147483648 to 2147483647Signed BIN32ANY32_S
(S2)Store the data for exclusive OR operation or the device storing the data-2147483648 to 2147483647Signed BIN32ANY32_S
(D)Device for storing XOR result Signed BIN32ANY32_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DXORParameter 1
Parameter 2
Parameter 3   

Features

Perform an exclusive OR operation on the BIN 32-bit data of the device specified in (S1) and the BIN 32-bit data of the device specified in (S2), and store the result in the device specified in (D).

07-2 Basic instructions_html_9cde57a858c39bd1.png

In the case of bit devices, bit devices after the number of points specified by the number of digits will be calculated as 0.

Error code

Error codeContent
4085HThe output results of (S1) and (S2)in the read application instruction exceed the device range
4086HThe output result of (D) in the write application instruction exceeds the device range

Example

07-2 Basic instructions_html_4e59503bb60bc285.png

When M0 is set, (D1, D0) and (D3, D2) are XOR operation, and the value is stored in (D5, D4), that is, (D1, D0) ∀ (D3, D2) → (D5, D4) )

PRUN/8 digit transmission (16-bit data)

PRUN(P)

After processing the device numbers of (s) and (d) with designated digits as octal numbers, transfer the data.

-[PRUN (s) (d)]

Content, range and data type

ParameterContentRangedataData type (label)
(s)Digit designation*1-BIN16 bitANY16
(d)Transfer destination device number*1-BIN16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnM[D]XXP
PRUNParameter 1 
Parameter 2 

Features

• 8-digit device → decimal device

image-20220614162329-1.jpeg

• Decimal digit device → octal digit device

image-20220614162416-2.jpeg

Error code

Error codeContent
4085HWhen reading the specified device range exceeds the corresponding device range
4086HWhen the specified device range for writing exceeds the range of the corresponding device

Example

image-20220614162440-3.jpeg

As shown in the above Circuit program:

X0 to X17 take the value of octal digits and pass it to the Devices corresponding to M.

image-20220614162445-4.jpeg

Data processing instructions

BCC/BIN16 and BIN8 bit data addition, subtraction and exclusive check

BCC (P)

Specify the calculation method of BCC in (S1), specify the destination start address in (S2), and specify the destination data length in (S3), and then store the operation result in the device specified in (D).

- [BCC (S1) (S2) (S3) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)16-bit constant or the calculation method of 16-bit regions (block check code)0 to 2BIN16 bitANY16_S
(S2)Calculate the initial 16-bit regions of BCC-BIN16 bitANY16_S
(S3)16-bit constant or 16-bit regions (specify the number of bytes calculated by BCC)0 to 32767BIN16 bitANY16_S
(D)Stores 16-bit regions of BCC results-BIN16 bitANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
BCC(S1)
(S2)      
(S3)
(D)   

Features

According to the calculation method specified by S1, starting from the 16-bit data specified by S2, calculate the ASCII block check code (BCC) of the number of bytes specified by S3, and then store the result of BCC code in the low byte of 16-bit data specified by D.

S1: Specify the calculation method of BCC.

K0: Addition operation

K1: Subtraction operation

K2: Exclusive or operation

S2 and s3: Specify the destination data

For example, if the destination is the 12 bytes data starting from D0, the settings are as below.

S2: D0

S3: K12 (specify the data by decimal)

The modes used in the calculation of this instruction are 16-bit conversion mode and 8-bit conversion mode. For the actions of each mode, refer to the followings.

(1) 16-bit conversion mode (When SM161 is OFF)

Calculate the high 8-bit (byte) and low 8-bit (byte) of device that started from (S2) and specify the byte length by (S3), and store the low 8-bit of device specified by (D). The conversion result is as below.

07-2 Basic instructions_html_8cb7ada16163d6a7.png

(2) 8-bit conversion mode (When SM161 is ON)

Calculate the low 8-bit (byte) of device that started from (S2) and specify the byte length by (S3), and store the low 8-bit of device specified by (D). The conversion result is as below.

07-2 Basic instructions_html_310b05f64338abad.png

Error code

Error codeContent
4084HThe read application instructions (S1) and (S3) input the data that exceeds the specified range
4085HThe device specified in the read application instructions (S1), (S2) and (S3) exceeds the corresponding device range
4086HThe device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_26b1cac4afae1305.png

When the trigger M0 is ON, calculate the a block check code (BCC) of 12-bit bytes of ASCII data starting from data register D0 by “exclusive or operation”. The block check code (BCC) is stored in the low bit byte of data register D6.

Application example

In the example ,calculate the BCC code and send as information after adding to the string “%01→RC”.

The data transmission is carried out in the form of ASCII codes.

CC calculations use logical exclusive OR, addition, and subtraction.

The information is stored as follows:

Data registerD6D2D1D0
ASCII hexadecimal code 4 3 5 22 3 3 13 0 2 5
ASCII code C R# 10 %

07-2 Basic instructions_html_800b1f152ebd3c70.gif

BCC check code 6 byte

BCC instruction is as below: Execution or operation

abOR result
000
011
101
110

07-2 Basic instructions_html_ec59337ad73345e4.gif 07-2 Basic instructions_html_dedf1eee74413c2a.gif 07-2 Basic instructions_html_6c451ef3b051808.gif 07-2 Basic instructions_html_d2b694e8d9d82696.gif

07-2 Basic instructions_html_495775c10e5895c7.png

S1: logic exclusive OR

S2: The start of destination data

S3: destination data lengt

D: calculation result

After the execution BCC code is stored in the last byte of D6.

How to calculate block check code (BCC)

Calculate block check code (BCD) with XOR for each ASCII code.

07-2 Basic instructions_html_632af1db3189c584.gif

BCC code

ASCII hexadecimal code1 6
ASCII binary code0 0 0 10 1 1 0

The calculation result is stored in the low bit byte of D6

MAX/BIN16 bit the maximum value of 16-bit data

MAX (P)

Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).

- [MAX (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Device that stores the start address when getting the max data-32768 to 32767Signed BIN16ANY16_S
(S2)Device that stores the end address when getting the max data-32768 to 32767Signed BIN16ANY16_S
(D)Stores the max value between the device data of (S1) and (S2)-32768 to 32767Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

TCDRSD[D]XXP
MAX(S1)
(S2)
(D)

Note

1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.

2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, MAX D1 D5 D10 works, but MAX D5 D1 D10 doesn't.

Features

Use the BIN16 bit data specified in (S1) as the start address, and use the BIN16 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).

Error code

Error codeContent
4084HThe read application instructions (S1) and (S2) input the data that exceeds the specified range
4085HThe device specified in the read application instructions (S1) and (S2) exceeds the device range
4086HThe device specified in the write application instruction (D) exceeds the device range
4093HThe specified ranges (S1) and (S2) are not the same device
4094HThe sequence of specified ranges (S1) and (S2) is abnormal

Example

07-2 Basic instructions_html_a388b58f840bcae9.png

Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.

DMAX/BIN32 bit the maximum value of 32-bit data

DMAX (P)

Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).

- [DMAX (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Device that stores the start address when getting the max data-2147483648 to 2147483647Signed BIN32ANY32_S
(S2)Device that stores the end address when getting the max data-2147483648 to 2147483647Signed BIN32ANY32_S
(D)Stores the max value between the device data of (S1) and (S2)-2147483648 to 2147483647Signed BIN32ANY32_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

TCDRSDLCHSC[D]XXP
DMAX(S1)
(S2)
(D)

Features

Use the BIN32 bit data specified in (S1) as the start address, and use the BIN32 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).

Note

1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.

2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, DMAX D1 D5 D10 works, but DMAX D5 D1 D10 doesn't.

Error code

Error codeContent
4084HThe read application instructions (S1) and (S2) input the data that exceeds the speicified range
4085HThe device specified in the read application instructions (s1) and (S2) exceeds the device range
4086HThe device specified in the write application instruction (D) exceeds the device range
4093HThe specified ranges (S1) and (S2) are not the same device
4094HThe sequence of specified ranges (S1) and (S2) is abnormal

Example

Use (D1) as the start address, and use (D7) as the end address to get the max value between them and store the result in (D9). As the figure above, the max value between (D1) and (D7) is the value in (D7) which is stores in (D9) for output.

07-2 Basic instructions_html_48178d8f933d20cb.png

MIN/BIN16 bit the minimum value of 16-bit data

MIN (P)

Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).

- [MIN (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Device that stores the start address when getting the minimum data-32768 to 32767Signed BIN16ANY16_S
(S2)Device that stores the end address when getting the minimum data-32768 to 32767Signed BIN16ANY16_S
(D)Stores the minimum value between the device data of (S1) and (S2)-32768 to 32767Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

TCDRSD[D]XXP
MIN(S1)
(S2)
(D)

Features

Use the BIN16 bit data specified in (S1) as the start address, and use the BIN16 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).

Note

1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.

2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, MAX D1 D5 D10 works, but MAX D5 D1 D10 doesn't.

Error code

Error codeContent
4084HThe read application instructions (S1) and (S2) input the data that exceeds the specified range
4085HThe device specified in the read application instructions (S1) and (S2) exceeds the device range
4086HThe device specified in the write application instruction (D) exceeds the device range
4093HThe specified ranges (S1) and (S2) are not the same device
4094HThe sequence of specified ranges (S1) and (S2) is abnormal

Example

Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.

07-2 Basic instructions_html_a388b58f840bcae9.png

DMIN/BIN32 bit the minimum value of 32-bit data

DMIN (P)

Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).

- [DMIN (S1) (S2) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S1)Device that stores the start address when getting the minimum data-2147483648 to 2147483647Signed BIN16ANY16_S
(S2)Device that stores the end address when getting the minimum data-2147483648 to 2147483647Signed BIN16ANY16_S
(D)Stores the minimum value between the device data of (S1) and (S2)-2147483648 to 2147483647Signed BIN16ANY16_S

Device used

InstructionParameterDevices

Offset modification

Pulse extension

TCDRSD[D]XXP
DMIN(S1)
(S2)
(D)

Features

Use the BIN32 bit data specified in (S1) as the start address, and use the BIN32 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).

Note

1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.

2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, MAX D1 D5 D10 works, but MAX D5 D1 D10 doesn't.

Error code

Error codeContent
4084HThe read application instructions (S1) and (S2) input the data that exceeds the specified range
4085HThe device specified in the read application instructions (S1) and (S2) exceeds the device range
4086HThe device specified in the write application instruction (D) exceeds the device range
4093HThe specified ranges (S1) and (S2) are not the same device
4094HThe sequence of specified ranges (S1) and (S2) is abnormal

Example

Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.

07-2 Basic instructions_html_a388b58f840bcae9.png

ANS/alarm settings

ANS(P)

Used to set alarm instructions.

-[ANS (S) (N) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Timer number for judging time-Signed BIN 16 bitANY16
(N)Data that judges time1 to 32767Signed BIN 16 bitANY16
(D)The set alarm device-BitANY16_BOOL

Device used

InstructionParameterDevices

Offset modification

Pulse extension

SKnXKnYKnMKnSTCDRSDKH[D]XXP
ANSParameter 1           
Parameter 2 
Parameter 3           

Features

When the instruction input continues to be ON for the judgment time [(N)×100ms, timer (S)], set (D). If the instruction time turns off below the judgment time [(N)×100ms], the current value of the judgment timer (S) is reset, and (D) is not set. In addition, if the instruction input turns off, the judgment timer will be reset.

07-2 Basic instructions_html_cc92e9a1f43558bd.png

07-2 Basic instructions_html_e332fbc503049d2f.png

1. Judge the time ((N)X 100ms or less)

2. Judgment time or more (inclusive) ((N) X 100ms or more (inclusive))

Related device

DevicesNameContent
SM249Signal alarm is validAfter SM249 is ON, the following SM248 and SD249 act.
SM248Signal alarm actionSM249 is ON, when any one of the states S900 to S999 is active, SM248 is ON
SD249Signal alarm ON state minimum numberSave the smallest number of actions in S900 to S999.

Error code

Error codeContent
4084HThe value specified in (N1) and (N2) exceeds the range of 0 to 32767
The timer number is not in the range of T0 to T199.
The signal alarm is not in the range of S900 to S999.
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

The fault number is displayed by the signal alarm.

Monitoring is effective after SM249 is turned ON

As shown below, when you write a program for diagnosing external faults, such as monitoring the content of SM249 (the smallest number in the ON state), the smallest number in the ON state among S900 to S999 will be displayed. When multiple faults occur at the same time, the next fault number can be obtained after eliminating the fault with the smallest number.

Detect X1 for 2 seconds, turn ON, set S900

X4 is detected for 1 second, turn ON, set S901

SM248 will act after any one of S900 to S999 is ON, and the output fault display YY6 will act

Display the fault number to the D0 device

Through the external fault diagnosis program, use the reset button M0 to turn off the activated state. Each time M0 turns ON, the action status of the new number is set in turn, and the new number that is already ON is reset.

07-2 Basic instructions_html_da49122879984485.png

ANR/Alarm reset

ANR(P)

The instruction to reset the small number that is ON in the alarm.

-[ANR]

Content, range and data type

ParameterContentRangeData typeData type (label)
NoNo parameter setting---

Device used

InstructionParameterDevicesOffset modification

Pulse extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
ANRNoNo object device

Features

If the instruction input is ON, reset the active alarm in the alarm.

If multiple alarms are operating, reset the smaller number. If the input instruction is turned ON again, the next small number in the alarm that is operating will be reset.

07-2 Basic instructions_html_878efe4b5d9b7937.png

Related device

DevicesNameContent
SM249Signal alarm is validAfter SM249 is ON, the following SM248 and SD249 act.
SM248Signal alarm actionSM249 is ON, when any one of the states S900 to S999 is active, SM248 is ON.
SD249Signal alarm ON state minimum numberSave the smallest number of actions in S900 to S999.

Note: 

If you use the ANR instruction, reset in sequence every cycle.

If the ANRP instruction is used, it will be executed in only one operation cycle.

Error code

No operation error.

Example

The fault number is displayed by the signal alarm.

As shown below, when you write a program for diagnosing external faults, such as monitoring the content of SM249 (the smallest number in the ON state), the smallest number in the ON state among S900 to S999 will be displayed. When multiple faults occur at the same time, the next fault number can be obtained after eliminating the fault with the smallest number.

Monitoring is effective after SM249 is turned ON

Detect X1 for 2 seconds, turn ON, set S900

X4 is detected for 1 second, turn ON, set S901

SM248 will act after any one of S900 to S999 is ON, and the output fault display YY6 will act

Display the fault number to the D0 device

Through the external fault diagnosis program, use the reset button M0 to turn off the activated state. Each time M0 turns ON, the action status of the new number is set in turn, and the new number that is already ON is reset.

07-2 Basic instructions_html_da49122879984485.png

BON/16-bit data bit judgment

BON(P)

Check whether the state of the BIN 16-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).

-[BON (S) (N) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Data storage destination word device number-Signed BIN 16 bitANY16
(D)Bit device number of drive-BitANY16_BOOL
(N)The position of the bit to be judged0 to 15Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

YMSSMD.bKnXKnYKnMKnSTCDRSDKH[D]XXP
BONParameter 1     
Parameter 2        
Parameter 3     

Features

Check whether the state of the BIN 16-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).

If the above result is ON, then (D)=ON, if it is OFF, then (D)=OFF.

If a constant (K) is specified in the device specified in (S), it will be automatically converted to BIN.

07-2 Basic instructions_html_3b129068b54a368f.png

Error code

Error codeContent
4084HThe data input in (N) exceeds the specified range of 0 to 15.
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_901a83d57e680bcb.png

When n in D0 = the third bit is 1 (ON), M0 is set to 1 (ON).

07-2 Basic instructions_html_b667504fab3e5a62.png

DBON/32-bit data bit judgment

DBON(P)

Check whether the state of the BIN 32-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).

-[DBON (S) (N) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Data storage destination word device number-Signed BIN 32 bitANY32
(D)Bit device number of drive-BitANY32_BOOL
(N)The position of the bit to be judged0 to 31Signed BIN 32 bitANY32

Device used

InstructionParameterDevices

Offset modification

Pulse extension

YMSSMD.bKnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DBONParameter 1     
Parameter 2          
Parameter 3     

Features

Check whether the BIN 32-bit data (N) bit status of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).

If the above result is ON, then (D)=ON, if it is OFF, then (D)=OFF.

If a constant (K) is specified in the device specified in (S), it will be automatically converted to BIN.

07-2 Basic instructions_html_a2388083bdb6b3d7.png

Error code

Error codeContent
4084HThe data input in (N) exceeds the specified range of 0 to 31.
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

When n in D0 = the third bit is 1 (ON), M0 is set to 1 (ON).

07-2 Basic instructions_html_5ea1a2a6191d7209.png

07-2 Basic instructions_html_4191aeacce9b050e.png

ENCO/Encode

ENCO(P)

Encode the data of the 2th (N)th power from (S) and store it in (D).

-[ENCO (S) (N) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Start device for storing coded data-Bit/Signed BIN 16 bitANY_ELEMENTARY
(D)Device number storing the encoding result-Signed BIN 16 bitANY_ELEMENTARY
(N)Effective bit length0 to 8Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

XYMSSMKnXKnYKnMKnSTCDRSDKH[D]XXP
ENCOParameter 1      
Parameter 2        
Parameter 3     

Features

The BIN value corresponding to the bit from 2 (N) bits of (S) to 1 is stored in (D).

07-2 Basic instructions_html_32b79f884e7c01e0.png

When (N)=0, it will be no processing, and the content of the device specified in (D) will not change.

Bit devices are treated as 1 bit, and word devices are treated as 16 bits.

When multiple digits are 1, it will be processed at the upper position.

Error code

Error codeContent
4084HIn the bit device specification of (S), when (N) is other than 0 to 8.
In the word device specification of (S), when (N) is other than 0 to 4.
When the data of 2(N) bits starting from (S) are all 0.
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_e70340d3db54a0d6.png

When M20 is turned ON, the D0 device is 16 after encoding.

DECO/Decode

DECO(P)

Decode the lower (N) bits of the device specified in (S), and store the result in the 2 (N)th power of the device specified in (D).

-[DECO (S) (N) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Decoded data or the device number storing the decoded data-Bit/Signed BIN 16 bitANY_ELEMENTARY
(D)The start device storing the decoding result-Signed BIN 16 bitANY_ELEMENTARY
(N)Effective bit length0 to 8Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

XYMSSMKnXKnYKnMKnSTCDRSDKH[D]XXP
DECOParameter 1 
Parameter 2       
Parameter 3     

Features

Turn ON the position of (D) corresponding to the BIN value specified in the lower (N) bit of (S).

When (N)=0, it will be no processing, and the content of the device specified in (D) will not change.

Bit devices are treated as 1 bit, and word devices are treated as 16 bits.

07-2 Basic instructions_html_676fed9d696c6525.png

Error code

Error codeContent
4084HIn the bit device specification of (D), when (N) is other than 0 to 8.
In the word device specification of (D), when (N) is other than 0 to 4.
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_e0ad47112aecfe84.png

When M20 is ON, M3 will be turned ON.

SUM/The ON bits of 16-bit data

SUM(P)

Store the total number of bits at 1 in the BIN 16-bit data of the device specified in (S) to the device specified in (D).

-[SUM (S) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number that counts the total number of bits at 1-Signed BIN 16 bitANY16
(D)The device start number of the total number of storage bits-Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
SUMParameter 1
Parameter 2   

Features

Store the total number of bits at 1 in the BIN 16-bit data of the device specified in (S) to the device specified in (D).

When the BIN 16-bit data of the device specified in (S) is all 0, the zero flag (SM153) turns on.

The total number of 1 (ON) is stored in BIN.

There are 8 in the example on the left.

07-2 Basic instructions_html_d0ff863c8a916f52.png

Error code

Error codeContent
4085HWhen the device specified in the read application instructions (S) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_604fe690248c20c4.png

When M0 is ON, the number of ON bits in D0 is counted and stored in D1. The value after D1 is executed is 4.

DSUM/The ON bits of 32-bit data

DSUM(P)

Store the total number of bits at 1 in the BIN 32-bit data of the device specified in (S) to the device specified in (D).

-[SUM (S) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number that counts the total number of bits at 1-Signed BIN 32 bitANY32
(D)The device start number of the total number of storage bits-Signed BIN 32 bitANY32

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DSUMParameter 1
Parameter 2   

Features

Store the total number of bits at 1 in the BIN 32-bit data of the device specified in (S) to the device specified in (D).

When the BIN 32-bit data of the device specified in (S) is all 0 (OFF), the zero flag (SM153) turns on.

The total number of 1 (ON) is stored in BIN.

There are 16 in the example on the left.

07-2 Basic instructions_html_c50dbc953689f502.png

Note:  When the instruction input is OFF, the instruction will not be executed, and the output of the ON digits of the action will remain the same as before.

Error code

Error codeContent
4085HWhen the device specified in the read application instructions (S) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_f362ddb84e2d24a2.png

When M0 is ON, the number of ON bits in D0 is counted and stored in D10, and the value after D10 is executed is 4.

MEAN/Mean value of 16-bit data

MEAN(P)

Store the total number of bits at 1 in the BIN 16-bit data of the device specified in (S) to the device specified in (D).

-[MEAN (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number storing the data for average calculation-Signed BIN 16 bitANY16
(D)The device start number storing the average value-Signed BIN 16 bitANY16
(N)Number of data or the device number storing the number of data1 to 32767Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
MEANParameter 1  
Parameter 2   
Parameter 3

Features

Calculate the average value of the 16-bit data at (N) points starting from the device specified in (S) and store it in the device specified in (D).

The total is calculated from the algebraic sum and divided by (N).

The remainder is rounded off.

07-2 Basic instructions_html_6d7059ace00e2f07.png

Error code

Error codeContent
4084HThe data input by (N) in the application instruction exceeds the specifiable range. N≤0
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_13566d51340cd9ac.png

Add the data of D0, D1, and D2 and save the value obtained after dividing by 3 in D10. The calculated average value is 6.

DMEAN/Mean value of 16-bit data

DMEAN(P)

Store the total number of bits at 1 in the BIN 32-bit data of the device specified in (S) to the device specified in (D).

-[DMEAN (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number storing the data for average calculation-Signed BIN 32 bitANY32
(D)The device start number storing the average value-Signed BIN 32 bitANY32
(N)Number of data or the device number storing the number of data1 to 2147483647Signed BIN 32 bitANY32

Device used

InstructionParameterDevicesOffset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DMEANParameter 1  
Parameter 2   
Parameter 3

Features

Calculate the mean value of BIN 32-bit data at (N) points starting from the device specified in (S) and store it in the device specified in (D).

The total is calculated from the algebraic sum and divided by (N).

The remainder is rounded off.

07-2 Basic instructions_html_ba33fd31e81f4c99.png

Note:  When the device number exceeds, (N) is handled as a smaller value within the allowable range.

Error code

Error codeContent
4084HThe data input in (N) exceeds the specifiable range. N≤0
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_2c823dad156101dc.png

Add the data of D0, D2, and D4, and save the value obtained after dividing by 3 in D10 and D11, and the calculated average value is 6.

SQR/16-bit square root

SQR(P)

Calculate the square root of the BIN 16-bit data specified in (S), and store the calculation result in (D).

-[SQR (S) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The data device storing for square root calculation0 to +32767Signed BIN 16 bitANY16
(D)The device storing the calculated square root-Signed BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse extension

DRSDKH[D]XXP
SQRParameter 1
Parameter 2  

Features

Calculate the square root of the BIN 16-bit data specified in (S), and store the calculation result in (D).

07-2 Basic instructions_html_3ee4c015d89635f5.png

Note:  The decimal point of operation result will be rounded off and become an integer. If rounding occurs, SM152 (borrow flag) turns ON.

When the operation result is really 0, SM153 (zero flag) turns ON.

Error code

Error codeContent
4084HWhen a negative value is specified in (S).
4085HWhen the device specified in the read application instructions (S) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_92245aa43f6ffa87.png

The square root of D0 is stored in D2, and the value of D0 is 100, so the value of D2 is 10.

DSQR/32-bit square root

DSQR(P)

Calculate the square root of the BIN 32-bit data specified in (S), and store the calculation result in (D).

-[DSQR (S) (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The data device storing for square root calculation0 to 2147483647Signed BIN 32 bitANY32
(D)The device storing the calculated square root-Signed BIN 32 bitANY32

Device used

InstructionParameterDevicesOffset modification

Pulse extension

DRSDLCHSCKH[D]XXP
DSQRParameter 1
Parameter 2  

Features

Calculate the square root of the BIN 32-bit data specified in (S) and store the calculation result in (D).

07-2 Basic instructions_html_51d10bf1ab821717.png

Note: The decimal point of operation result will be rounded off and become an integer. If rounding occurs, SM152 (borrow flag) turns ON.

When the operation result is really 0, SM153 (zero flag) turns on.

Error code

Error codeContent
4084HWhen a negative value is specified in (S).
4085HWhen the device specified in the read application instructions (S) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_d7c5cf75a5e766d2.png

The square root of D0 is stored in D2, and the value of D0 is 110, so the value in the D2 soft component is 10 (the fractional part is discarded), and the borrow flag SM152 is turned ON.

WSUM/The sum value of 16-bit data

WSUM(P)

After adding all the BIN 16-bit data of point (n) starting from the device specified in (S), it is stored in the device specified in (D).

-[WSUM (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number storing the data for sum value calculation-Signed BIN 16 bitANY16
(D)The device start number storing the sum value-Signed BIN 32 bitANY32
(N)Number of data-Signed BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
WSUMParameter 1      
Parameter 2   
Parameter 3

Features

After adding all the BIN 16-bit data of point (N) starting from the device specified in (S), it is stored in the device specified in (D).

07-2 Basic instructions_html_7495632d1d596fe7.png

Error code

Error codeContent
4084HWhen a negative value is specified in (N).
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_8e8f6bedc6333b2f.png

When M0=ON, the total of 16-bit data of D0 to D2 is saved in [D100, D101], and the accounting result is 18.

DWSUM/The sum value of 32-bit data

DWSUM(P)

Add all the 32-bit BIN data of point (N) starting from the device specified in (S) and store it in the device specified in (D).

-[DWSUM (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number storing the data for total value calculation-Signed BIN 32 bitANY32
(D)The device start number storing the total value-Signed BIN64 bitANY64
(N)Number of data-Signed BIN 32 bitANY32

Device used

InstructionParameterDevicesOffset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DWSUMParameter 1      
Parameter 2   
Parameter 3

Features

Add all the 32-bit BIN data of point (n) starting from the device specified in (s) and store it in the device specified in (d).

07-2 Basic instructions_html_f752f81c0b00f696.png

Note: When the number of bits is specified in (D), the value of n ranges from 1 to 8, such as K8 (32-bit instructions, such as K8M0) without K16 (64-bit instructions).

Error code

Error codeContent
4084HWhen a negative value is specified in (N).
4085HWhen the device specified in the read application instructions (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_baf1223bd45a93dd.png

When M0=ON, the total of 16-bit data of D0 to D2 is saved in [D100, D101], and the accounting result is 18.

SORT/16-bit data sorting

SORT

Sort the data rows in ascending order based on the group data of column (N3) in the BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S) and store them in the specified in (D) (N1×N2) points in the BIN 16-bit data table (after sorting).

-[SORT (S) (N1) (N2) (D) (N3)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device number storing the data table-Signed BIN 16 bitANY16
(N1)Number of data (rows)1 to 32Signed BIN 16 bitANY16
(N2)Number of group data (columns)1 to 6Signed BIN 16 bitANY16
(D)The start device number storing the operation result-Signed BIN 16 bitANY16
(N3)The column number of the group data (column) as the sorting basis-Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
SORTParameter 1       
Parameter 2 
Parameter 3 
Parameter 4       
Parameter 5 

Features

The BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S), based on the group data of column (N3), sort the data rows in ascending order, and store them in (D). The (N1×N2) point of the BIN 16-bit data table (after sorting).

Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).

 Number of groups (N2) ((N2)=K4)
Column NO. 1Column NO. 2Column NO. 3Column NO. 4
Management numberHeightWeightAge
When the number of data (N1)=3Line NO.1(S)(S) +3(S) +6(S) +9
Line NO.2(S)+1(S) +4(S) +7(S) +10
Line NO.3(S)+2(S) +5(S) +8(s) +11

Data alignment starts when instruction input is ON, data alignment ends after (N1) scan, instruction execution end flag SM229 is set to ON. According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.

 Number of groups (N2) ((N2)=K4)
Column NO. 1Column NO. 2Column NO. 3Column NO. 4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(S)(S) +5(S) +10(S) +15
11504520
Line NO.2(S)+1(S) +6(S) +11(S) +16
21805040
Line NO.3(S)+2(S) +7(S) +12(S) +17
31607030
Line NO.4(S) +3(S) +8(S) +13(S) +18
4100208
Line NO.5(S) +4(S) +9(S) +14(S) +19
51505045

Press (N3)=K2 (column number 2) to execute the sorting result.

 Number of groups (N2) ((N2)=K4)
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(D)(D) +5(D) +10(D) +15
4100208
Line NO.2(D) +1(D) +6(D) +11(D) +16
11504520
Line NO.3(D) +2(D) +7(D) +12(D) +17
51505045
Line NO.4(D) +3(D) +8(D) +13(D) +18
31607030
Line NO.5(D) +4(D) +9(D) +14(D) +19
21805040

Press (N3)=K3 (column number 3) to execute the sorting result.

 Number of groups (N2) ((N2)=K4)
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(D)(D) +5(D) +10(D) +15
4100208
Line NO.2(D) +1(D) +6(D) +11(D) +16
11504520
Line NO.3(D) +2(D) +7(D) +12(D) +17
21805040
Line NO.4(D) +3(D) +8(D) +13(D +18
51505045
Line NO.5(D) +4(D) +9(D) +14(D) +19
31607030

Note: only ascending order is supported by SORT instruction .

Do not change the operand and data content during operation.

When executing again, the instruction input should be turned OFF once.

SORT instruction can drive at most one in the program.

When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.

Error code

Error codeContent
4084HWhen the value specified in (N1) exceeds the range of 1 to 32
When the value specified in (N2) exceeds the range of 1 to 6
When the value specified in (N3) exceeds the range of 1 to n2
4085HWhen the device specified in read application instruction (S), (N1), (N2 )and (N3) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range
4087HWhen the (D) parameter in the application instruction uses an unsupported device
4089HThe number of application instructions exceeds the limit.

Example

Refer to the function description example.

07-2 Basic instructions_html_2b87a0892241f0a3.png

SORT2/16-bit data sorting

SORT2(P)

Sort the data rows in ascending or descending order based on the group data in column (N3), and store them in (D), based on the BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S) In the BIN 16-bit data table (after sorting) of the specified (N1×N2) points.

-[SORT2 (S) (N1) (N2) (D) (N3)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device number storing the data table-Signed BIN 16 bitANY16
(N1)Number of data (rows)1 to 32Signed BIN 16 bitANY16
(N2)Number of group data (columns)1 to 6Signed BIN 16 bitANY16
(D)The start device number storing the operation result-Signed BIN 16 bitANY16
(N3)The column number of the group data (column) as the sorting basis-Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
SORT2Parameter 1       
Parameter 2 
Parameter 3 
Parameter 4       
Parameter 5 

Features

Sort the data rows in ascending or descending order based on the group data in column (N3) and store them in (D) (N1×N2) point specified in the BIN 16-bit data table (after sorting).

Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1)=3Line NO.1(S)(S)+1(S) +2(S) +3
Line NO.2(S) +4(S) +5(S) +6(S) +7
Line NO.3(S) +8(S) +9(S) +10(S) +100

Sequence is set by the ON/OFF status of SM165

 Sort order setting instruction
SM165=ONDescending
SM165=OFFAscending

Data alignment starts when instruction input is ON, data alignment ends after (N1) scan, instruction execution end flag SM229 is set to ON.

According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(S)(S)+1(S) +2(S) +3
11504520
Line NO.2(S) +4(S) +5(S) +6(S) +7
21805040
Line NO.3(S) +8(S) +9(S) +10(S) +100
31607030
Line NO.4(S) +12(S) +13(S) +14(S) +15
4100208
Line NO.5(S) +16(S) +17(S) +18(S) +19
51505045

Press (N3)=K2 (column number 2) to execute the sorting result (SM165=OFF in the case of ascending order)

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(D)(D) +1(D) +2(D) +3
4100208
Line NO.2(D) +4(D) +5(D) +6(D) +7
11504520
Line NO.3(D) +8(D) +9(D) +10(D) +100
51505045
Line NO.4(D) +12(D) +13(D) +14(D) +15
31607030
Line NO.5(D) +16(D) +17(D) +18(D) +19
21805040

Press (N3)=K3 (column number 3) to execute the sorting result (SM165=ON in the case of ascending order)

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1) = 5Line NO.1(D)(D) +1(D) +2(D) +3
31607030
Line NO.2(D) +4(D) +5(D) +6(D) +7
21805040
Line NO.3(D) +8(D) +9(D) +10(D) +100
51505045
Line NO.4(D) +12(D) +13(D) +14(D) +15
11504520
Line NO.5(D) +16(D) +17(D) +18(D) +19
4100208

Note:  Do not change the operand and data content during operation.

When executing again, the instruction input should be turned OFF once.

The SORT2 instruction can only be written in the program to drive 2 at most.

When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.

Do not overlap the source data and the sorted data.

07-2 Basic instructions_html_d78408a5465eaf25.gif

Error code

Error codeContent
4084HWhen the value specified in (N1) exceeds the range of 1 to 32
When the value specified in (N2) exceeds the range of 1 to 6
When the value specified in (N3) exceeds the range of 1 to n2
4085HWhen the device specified in read application instruction (S), (D), (N1), (N2 )and (N3) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range
4089HThe number of application instructions exceeded the limit.

Example

Refer to the function description example.

07-2 Basic instructions_html_3a995438f23dce64.png

DSORT2/32-bit data sorting

DSORT2(P)

Sort the data rows in ascending or descending order based on the group data of column (N3) in the BIN 32-bit data table (sorting source) of (N1×N2) points specified in (S) and store them in (D) The specified (N1×N2) point BIN 32-bit data table (after sorting).

-[DSORT2 (S) (N1) (N2) (D) (N3)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device number storing the data table-Signed BIN 32 bitANY32
(N1)Number of data (rows)1 to 32Signed BIN 32 bitANY32
(N2)Number of group data (columns)1 to 6Signed BIN 32 bitANY32
(D)The start device number storing the operation result-Signed BIN 32 bitANY32
(N3)The column number of the group data (column) as the sorting basis-Signed BIN 32 bitANY32

Device used

InstructionParameterDevicesOffset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DSORT2Parameter 1       
Parameter 2 
Parameter 3 
Parameter 4       
Parameter 5 

Features

Sort the data rows in ascending or descending order based on the group data in the (N3) column of the (N1×N2) point BIN 32-bit data table (sorting source) specified in (S), and store to (d) (N1×N2) specified in the BIN 32-bit data table (after sorting).

Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberHeightWeightAge
When the number of data (N1)=3Line NO.1(S)+1, (S)(S)+3, (S)+2(S)+5, (S)+4(S) +7, (S) +6
Line NO.2(S) +9, (S) +8(S)+11, (S)+10(S) +13, (S) +12(S) +15, (S) +14
Line NO.3(S) +17, (S) +16(S) +19, (S) +18(S) +21, (S) +20(S) +23, (S) +22

Sequence is set by the ON/OFF status of SM165

 Sort order setting instructions
SM165=ONDescending
SM165=OFFAscending

Data alignment starts when instruction input is ON, data alignment ends after (n1) scan, instruction execution end flag SM229 is set to ON.

According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberheightbody weightage
When the number of data (N1) = 5Line NO.1(S)+1, (S)(S)+3, (S)+2(S)+5, (S)+4(S) +7, (S) +6
11504520
Line NO.2(S) +9, (S) +8(S)+11, (S)+10(S) +13, (S) +12(S) +15, (S) +14
21805040
Line NO.3(S) +17, (S) +16(S) +19, (S) +18(S) +21, (S) +20(S) +23, (S) +22
31607030
Line NO.4(S) +25, (S) +24(S) +27, (S) +26(S) +29, (S) +28(S) +31, (S) +30
4100208
Line NO.5(S) +33, (S) +32(S) +35, (S) +34(S) +37, (S) +36(S) +39, (S) +38
51505045

Press (N3)=K2 (column NO.2) to execute the sorting result (SM165=OFF in the case of ascending order)

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberheightbody weightage
When the number of data (N1) = 5Line NO.1(S)+1, (S)(S)+3, (S)+2(S)+5, (S)+4(S) +7, (S) +6
4100208
Line NO.2(S) +9, (S) +8(S)+11, (S)+10(S) +13, (S) +12(S) +15, (S) +14
11504520
Line NO.3(S) +17, (S) +16(S) +19, (S) +18(S) +21, (S) +20(S) +23, (S) +22
51505045
Line NO.4(S) +25, (S) +24(S) +27, (S) +26(S) +29, (S) +28(S) +31, (S) +30
31607030
Line NO.5(S) +33, (S) +32(S) +35, (S) +34(S) +37, (S) +36(S) +39, (S) +38
21805040

Press (N3)=K3 (column NO.3) to execute the sorting result (SM165=ON in the case of ascending order)

 When the number of groups (N2) (N2) = K4
Column NO.1Column NO.2Column NO.3Column NO.4
Management numberheightbody weightage
When the number of data (N1) = 5Line NO.1(S)+1, (S)(S)+3, (S)+2(S)+5, (S)+4(S) +7, (S) +6
31607030
Line NO.2(S) +9, (S) +8(S)+11, (S)+10(S) +13, (S) +12(S) +15, (S) +14
21805040
Line NO.3(S) +17, (S) +16(S) +19, (S) +18(S) +21, (S) +20(S) +23, (S) +22
51505045
Line NO.4(S) +25, (S) +24(S) +27, (S) +26(S) +29, (S) +28(S) +31, (S) +30
11504520
Line NO.5(S) +33, (S) +32(S) +35, (S) +34(S) +37, (S) +36(S) +39, (S) +38
4100208

Note:  Do not change the operand and data content during operation.

When executing again, the instruction input should be turned OFF once.

The SORT2 instruction can only be written twice in the program.

When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.

Do not overlap the source data and the sorted data.

07-2 Basic instructions_html_d78408a5465eaf25.gif

Error code

Error codeContent
4084HWhen the value specified in (N1) exceeds the range of 1 to 32
When the value specified in (N2) exceeds the range of 1 to 6
When the value specified in (N3) exceeds the range of 1 to n2
4085HWhen the device specified in read application instruction (S), (D), (N1), (N2 )and (N3) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range
4089HThe number of application instructions exceeded the limit.

Example

Refer to the function description example.

07-2 Basic instructions_html_1f225b781e4ba2f.png

SWAP/16-bit data high and low byte swap

SWAP(P)

Swap the high and low 8-bit value of the device specified in (D).

-[SWAP (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(D)Word device with high and low byte swap-Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnYKnMKnSTCDRSD[D]XXP
SWAPParameter 1

Features

Convert the high and low 8-bit value of the device specified in (D).

07-2 Basic instructions_html_3716816d1bf23d09.png

Error code

Error codeContent
4085HWhen the device specified in the read application instruction (D) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_4955b8e80583b752.png

When the rising edge of M0 is triggered, swap the low 8 bits and high 8 bits of D0 to get H8F2A.

DSWAP/32-bit data high and low byte swap

DSWAP(P)

The devices specified in (D) and (D)+1 will be converted to the high and low 8-bit values respectively.

-[DSWAP (D)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(D)Word device with high and low byte swap-Signed BIN 32 bitANY32

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnYKnMKnSTCDRSDLCHSC[D]XXP
DSWAPParameter 1

Features

The devices specified in (D) and (D)+1 will be converted to the upper and lower 8-bit values respectively.

07-2 Basic instructions_html_4d64dcd321d22f11.png

Note:  If continuous execution instructions are used, conversion will be performed every scan cycle.

Error code

Error codeContent
4085HWhen the device specified in the read application instruction (D) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_81e3d6e4b87b8c93.png

When the rising edge of M0 is triggered, the low 8 bits and the high 8 bits of D0 and D1 are swapped, and D0=H8F2A, D1=H3412 are obtained.

07-2 Basic instructions_html_80e0730a6f8e691a.png

BTOW/Byte unit data merge

BTOW(P)

Combine the low 8 bits of (N) bytes of BIN 16-bit data stored after the device number specified in (S) into word units and store it after the device number specified in (D).

-[BTOW (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device that stores the data merging in byte units-Signed BIN 16 bitANY16
(D)The start device that stores the result of merging in byte units-Signed BIN 16 bitANY16
(N)Number of byte data merged0-32767Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
BTOWParameter 1      
Parameter 2      
Parameter 3

Features

After the device number specified in (s), the lower 8 bits of the 16-bit BIN data stored in (n) bytes are combined into word units and stored in the device number specified in (d) or later.

The upper 8 bits of (n) word data stored after the device number specified in (s) will be ignored. In addition, when (n) is an odd number, 0 is stored in the upper 8 bits of the device storing the (n)th byte of data.

07-2 Basic instructions_html_f7abd03fc8a46b74.png

£: the £th byte data;

(1): Ignore the high byte

*1: Carry below the decimal point.

Example

When (N)=5, the data up to the lower 8 bits of (S)+(S)+4 is stored in (D)+(D)+2.

07-2 Basic instructions_html_50df057d754891b2.png

(1): When (N)=5

(2): Change to 00H

By setting the number of bytes in (N), the range of byte data specified in (S) and the range of the device storing the combined data specified in (D) will be automatically determined.

When the number of bytes specified in (N) is 0, no processing is performed.

The upper 8 bits of the byte data storage device specified in (S) will be ignored, and the lower 8 bits will be the target.

Example

When the low 8 bits of D11 to D16 is stored in D12 to D14.

07-2 Basic instructions_html_9e8f8fd8cc532de.png

Even if the device range storing the data before merging overlaps the device rangestoring merged data, it will be handled as normal.

Device range storing the data before mergingDevice range for storing merged data
(S)+0 to (S)+(N)-1(D) to (D) + (N/2-1)

Error code

Error codeContent
4084HThe value specified in (N) exceed range of 0 to 32767
4085HWhen the device specified in the write application instruction (S),(D) and (N) exceeds the corresponding device range

Example

07-2 Basic instructions_html_5451ed9cd96c7f44.png

When M0 is ON, the data of D20 to D25 is separated according to byte units, and then stored in D10 to D12.

07-2 Basic instructions_html_952713e3b4e74083.png

WTOB/Byte unit data separation

WTOB(P)

After separating the BIN 16-bit data stored after the device number specified in (S) into (N) bytes, store it after the device number specified in (D).

-[WTOB (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device that stores the data separation in byte unit-Signed BIN 16 bitANY16
(D)The start device that stores the result of separation in byte unit-Signed BIN 16 bitANY16
(N)Number of byte data separated0-32767Signed BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse extension

TCDRSDKH[D]XXP
WTOBParameter 1  
Parameter 2  
Parameter 3  

Features

After separating the BIN 16-bit data stored after the device number specified in (S) into (N) bytes, store it after the device number specified in (D).

07-2 Basic instructions_html_7c0bf2832b8707c3.png

  1. High byte;
  2. Low byte;
  3. High byte data;
  4. Low byte data;
  5. *1: Carry below the decimal point.

Example

In the case of (N)=5, store the data up to the lower 8 bits of (S) to (S)+2 in (D) to (D)+4:

07-2 Basic instructions_html_fe50c08e8ade2455.png

  1. (N)=5 is ignored.
  2. (N)=5.

By setting the number of bytes in (N), the range of BIN 16-bit data specified in (S) and the range of the device storing the byte data specified in (D) will be automatically determined.

When the number of bytes specified in (N) is 0, no processing is performed.

00H is automatically stored in the upper 8 bits of the byte data storage device specified in (D).

Example

When D12 to D14 is stored in the low 8 bits of D11 to D16

07-2 Basic instructions_html_e3a3ed7cb6d9e035.png

Even if the device range storing the data before merging overlaps the device rangestoring merged data, it will be handled as normal.

Device range storing the data before mergingDevice range storing separated data
(S) to (S) + (N/2-1)(D)+0 to (D)+(N)-1

Error code

Error codeContent
4084HThe value specified by (N) exceed the range of 0 to 32767
4085HWhen the device specified in read application instruction (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_da482b8ab5a3e35a.png

When M0 is ON, the data of D10 to D12 are separated according to byte units, and then stored in D20 to D25.

07-2 Basic instructions_html_9da7a305c36b78d1.png

DIS/4-bit separation of 16-bit data

DIS(P)

Store the data of the low (N) bits (1 bit of 4 bits) of the BIN 16-bit data specified in (S) into the low 4-bit of the (N) point starting from the device specified in (D).

-[DIS (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device storing the data before separation-Signed BIN 16 bitANY16
(D)The start device storing separated data-Signed BIN 16 bitANY16
(N)Separation number (0 means no processing)0-4Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
DISParameter 1
Parameter 2      
Parameter 3

Features

Store the low-(N) bit (1 bits of 4 bits) of the BIN 16-bit data specified in (S) in the low 4-bit of the (N) point starting from the device specified in (D).

07-2 Basic instructions_html_5938199acdc55dc1.png

The hig-12 bit of the point (N) starting from the device specified in (S) will become 0.

When (N)=0, it will become no processing, and the content of point (N) starting from the device of (D) will not change.

Error code

Error codeContent
4084HThe data in (N) exceed the range of 0 to 4
4085HWhen the device specified in read application instruction (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_c0329da3be0da41.png

When M0 is ON, D0 is separated every 4 bits and stored in D10 to D12. The result is D10 = HF, D11 = H8, D12 = HA.

UNI/4-bit combination of 16-bit data

UNI(P)

Combine the low 4 bits of the BIN 16-bit data of point (N) starting from the device specified in (S) into the BIN 16-bit device specified in (D).

-[UNI (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The start device storing the data before merging-Signed BIN 16 bitANY16
(D)The start device storing the merged data-Signed BIN 16 bitANY16
(N)Number of merger0-4Signed BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
UNIParameter 1      
Parameter 2   
Parameter 3

Features

Combine the low 4 bits of the BIN 16-bit data at point (N) starting from the device specified in (S) into the BIN 16-bit device specified in (D).

07-2 Basic instructions_html_ac539a0af5621485.png

The high (4-N) bits of the device specified in (D) will become 0.

When (N)=0, it will become no processing, and the content of the device in (D) will not change.

Error code

CodeContent
4084HThe data in (N) exceed the range of 0 to 4
4085HWhen the device specified in read application instruction (S) and (N) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (D) exceeds the corresponding device range

Example

07-2 Basic instructions_html_c01aef986a0a77b0.png

When M0 is ON, the low 4 bits of D0 to D3 are combined and stored in D10, the value is H236F.

ZRST/Data batch reset

ZRST(P)

Perform a batch reset between the devices specified in (d1) and (d2) of the same type. It is used when interrupting operation, performing initial operation, or resetting control data.

-[ZRST (d1) (d2)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(d1)The start bit or word device number of batch reset-Bit/Signed BIN 16 bitANY_ELEMENTARY
(d2)The final bit or word device number of batch reset-Bit/Signed BIN 16 bitANY_ELEMENTARY

Device used

InstructionParameterDevices

Offset modification

Pulse extension

YMSSMKnXKnYKnMKnSTCDRSDLCHSC[D]XXP
ZRSTParameter 1
Parameter 2

Features

Perform batch reset between the devices specified in (d1) and (d2) of the same type.

When (d1) and (d2) are bit devices, write OFF (reset) in the entire device range of (d1) to (d2).

07-2 Basic instructions_html_6a643f895dce5dcf.png

When (d1) and (d2) are word devices, write K0 in the entire device range of (d1) to (d2).

07-2 Basic instructions_html_4e253e658fd251d8.png

As a separate reset instruction for the device, the RST instruction can be used for bit devices or word devices.

Reset M0

Reset D0

Reset the current value of T0

07-2 Basic instructions_html_db7123fa756a328e.png

The batch write instruction of constant (for example: K0) has FMOV (P) instruction, which can write 0 to word devices (including bit device specification).

Write K0 in D0 to D99.

07-2 Basic instructions_html_edf867a50a714481.png

Note: Please specify the same type number for (d1) and (d2), and make (d1) number <(d2) number. When (d1) number ≥ (d2) number, only 1 point will be reset for the device specified in (d1).

ZRST(P) instruction is a 16-bit instruction, which can specify (LC) and (HSC) devices for (d1) and (d2).

Error code

Error codeContent
4084HWhen the device type specified in (d1) is different from the device type specified in (d2).
4085HWhen the device specified in the read application instruction (d1) and (d2) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (d1) exceeds the corresponding device range

Example

07-2 Basic instructions_html_f78d26cb1f6908b7.png

The function of this Circuit program instruction is to set the value of the D0 to D100 device to 0.

ZSET/Data batch set

ZSET(P)

Perform a batch set between the devices specified in (d1) and (d2) of the same type.

07-2 Basic instructions_html_da64e5c21415b34f.png

Content, range and data type

ParameterContentRangeData typeData type(label)
(d1)The start bit device number of batch set-BitANY_BOOL
(d2)The final bit device number of batch set-BitANY_BOOL

Device used

InstructionParameterDevicesOffset modification
YMSSMD.b[D]
ZSETParameter 1
Parameter 2

Features

·Perform a batch set between the devices specified in (d1) and (d2) of the same type.

·Write ON (set) in the entire device range of (d1) to (d2)

07-2 Basic instructions_html_6c035079ef5cc84b.png

·As a separate set instruction for the device, the SET instruction can be used for bit devices.

Set M1

Set Y1

Set S1

07-2 Basic instructions_html_e8901e24a4d0b868.png

Note:  Please specify the same type number for (d1) and (d2), and make (d1) number <(d2) number. When (d1) number ≥ (d2) number, only 1 point will be set for the device specified in (d1).

Error code

Error codeContent
4084HWhen the device type specified in (d1) is different from the device type specified in (d2).
4085HWhen the device specified in the read application instruction (d1) and (d2) exceeds the corresponding device range
4086HWhen the device specified in the write application instruction (d1) exceeds the corresponding device range
4087HWhen the device type specified in (d1) and (d2) are not bit device.

Example

07-2 Basic instructions_html_b7756e9ffdc0d901.png

The function of this LAD instruction is to set the value of the M1 to M4 device to ON.

CRC/cyclic redundancy check instruction

CRC(P)

Calculate the CRC (Cyclic Redundancy Check) value, which is one of the error checking methods used in communications. In addition to CRC, error checking methods include parity and

Sum check (checksum), calculate horizontal parity check value and sum check value can use CCD(P) instruction . And this instruction is used in the generator polynomial that generates the CRC value (CRC-16)

"X 16 +X 15 +X 2 +1".

-[CRC(P) (S) (D) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)The device start number storing the data of CRC value generated objects-Signed BIN16ANY16
(D)The destination device number of the generated CRC value-Signed BIN16ANY16
(N)The number of 8-bit data (bytes) for calculating the CRC value or the number of the device storing the number of data1 to 256Unsigned BIN16ANY16_U

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
CRCParameter 1  
Parameter 2   
Parameter 3 

Features

Start with the device specified in (S), generate the CRC value of 8-bit data (byte unit) at (N) point, and store it in (D).

The mode used by this instruction in calculation includes 16-bit conversion mode and 8-bit conversion mode. For the operation of each mode, please refer to the following content.

1. 16-bit conversion mode (when SM161=OFF)

Calculate the upper 8 bits (byte) and lower 8 bits (byte) of the (S) device. The result is stored in 16 bits of 1 point of the device specified in (D). In the case of the following program, perform the conversion as shown below.

07-2 Basic instructions_html_860919febd080a5a.gif

 Example (s)=D100, (d)=D0, (n)=6
DevicesContent of object data
8-bit16-bit
CRC value generation target data storage destination(s)Low byteD100 low01H0301H
High byteD100 high03H 
(s)+1Low byteD101 low03H0203H
High byteD101 high02H 
(s)+2Low byteD102 low00H1400H
High byteD102 high14H 
...
(S)+(N)/2-1Low byte
High byte
CRC value storage target(d)Low byteD0 lowE4H41E4H
High byteD0 high41H 

2. 8-bit conversion mode (when SM8161=ON)

In 8-bit conversion mode, only the lower 8 bits (lower byte) of the (s) device are operated on. As a result, 2 points are used starting from the device specified in (d), the lower 8 bits (bytes) are stored in (d), and the upper 8 bits (bytes) are stored in (d)+1.

In the case of the following program, perform the conversion as shown below.

07-2 Basic instructions_html_e6f8991549727060.gif

 Example) (s)=D100, (d)=D0, (n)=6
DevicesContent of object data
CRC value generation target data storage destination(s)Low byteD100 low01H
(s)+1Low byteD101 low03H
(s)+2Low byteD102 low03H
(s)+3Low byteD103 low02H
(s)+4Low byteD104 low00H
(s)+5Low byteD105 low14H
...
(S)+(N)-1Low byte
CRC value storage target(d)Low byteD0E4H
(d)+1Low byteD141H

In the CRC(P) instruction, the generator polynomial of the CRC value (CRC-16) uses "X16+X15+X2+1", but there are also many standardized generator polynomials for the CRC value. If the generator polynomial is different, it will become a completely different CRC value, which should be noted. The main CRC value generator polynomials are shown below.

NameGenerator polynomial
CRC-12X12+X11+X3+X2+X+1
CRC-16X16+X15+X2+1
CRC-32X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1
CRC-CCITTX16+X12+X5+1

Note: 

When (s1) use KnX, KnY, KnM, KnS, n must be specified as 4.

Error code

Error codeContent
4084HThe range of (N) exceeds 1 to 256
4085HThe data address of (S) to be converted exceeds the device range
4086HThe (D) write address exceeds the device range
4087HUnsupported device type is used by (S) and (D)

Example

1. 16-bit conversion mode

07-2 Basic instructions_html_8440fd092cae48b0.gif

2. 8-bit conversion mode

07-2 Basic instructions_html_b95cce31a754112b.gif