6.08 Data Conversion instruction

Last modified by Iris on 2025/10/23 15:37

BCD/BIN → BCD

BCD(P)

Convert the BIN data of the device specified in (s) to BCD, and store it in the device specified in (d).

The calculation of the CPU module uses BIN (binary number) data for processing, which is used to display values in a 7-segment display equipped with a BCD decoder.

-[BCD  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)BIN data or start device storing BIN data0 to 9999Signed BIN16ANY16
(d)Start device for storing BCD data-BCD 4 digitsANY16

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
BCDParameter 1             
Parameter 2              

Features

The BIN 16-bit data (0 to 9999) of the device specified in (s) is converted to BCD 4-bit data and stored in the device specified in (d).

The data specified in (s) can be converted within the range of 0 to 9999 (BCD).

When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below.

1760515828495-204.png

The data specified in (s) can be converted in the range of K0 to K9999 by BCD (decimal number).

When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below.

1760515993069-622.png

(d)DigitsData range
K1Y01-bit0 to 9
K2Y02-bit00 to 99
K3Y03-bit000 to 999
K4Y04-bit0000 to 9999

✎Note

The four arithmetic operations (+-×÷), increment, decrement instructions and other operations in the CPU module are all performed by BIN (binary number). Therefore, when sending BCD (decimal) digital switch information to the CPU module, please use the BIN(P) instruction (BCD→BIN conversion transfer instruction). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) instruction (BIN→BCD conversion transmission).

Error code

Error codeContent
4084HThe data input in the application instruction (s) exceeds the specified range
4085HThe output result of the read application instruction (s) exceeds the device range
4086HThe output result of the write application instruction (d) exceeds the device range

Example

1760516200225-646.png

When M0 is set, the BIN value of D200 is converted into BCD and stored in K1Y0.

BIN/4-bit BCD → BIN

BIN(P)

Convert the BCD data of the device specified in (s) to BIN and store it in the device specified in (d).

Similar to the digital switch, it converts the value set in BCD (decimal number) to BIN (binary number) that can be operated by the CPU module and is used for reading.

-[BIN  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)BCD data or start device storing BIN data0 to 9999BCD 4 digitsANY16
(d)Start device for storing BIN data-Signed BIN16ANY16

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
BINParameter 1             
Parameter 2                

Features

BCD 4-bit data (0 to 9999) of the device specified in (s) is converted into BIN 16-bit data and stored in the device specified in (d).

1760516268370-140.png

 The data specified in (s) can be converted within the range of 0 to 9999 (BCD).

 When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below.

1760516329466-296.png

(d)DigitsData range
K1X01-bit0 to 9
K2X02-bit00 to 99
K3X03-bit000 to 999
K4X04-bit0000 to 9999

✎Note

The calculations in the CPU module such as the four arithmetic operations (+-×÷), increment and decrement instructions are all performed by BIN (binary number). Therefore, when sending BCD (decimal) digital switch information to the CPU module, please use the BIN(P) instruction (BCD→BIN conversion transfer instruction). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) instruction (BIN→BCD conversion transmission).

Error code

Error codeContent
4084HThe data input in the application instruction (s) exceeds the specified range
4085HThe output result of the read application instruction (s) exceeds the device range
4086HThe output result of the write application instruction (d) exceeds the device range

Example

1760516369609-652.png

When M0 is set, the BCD value of K1Y0 is converted into BIN and stored in D200.

DBIN/8-bit BCD → BIN

DBIN(P)

Convert the BCD data of the device specified in (s) to BIN and store it in the device specified in (d).

Similar to the digital switch, it converts the value set in BCD (decimal number) to BIN (binary number) that can be operated by the CPU module and is used for reading.

-[DBIN  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)BCD data or start device storing BIN data0 to 99999999BCD 8 digitsANY32
(d)Start device for storing BIN data-Signed BIN32ANY32

Device used

instructionParameterDevicesIndex modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DBINParameter 1           
Parameter 2                

Features

BCD 8-bit data (0 to 99999999) of the device specified in (s) is converted to BIN 32-bit data and stored in the device specified in (d).

1760516454645-987.png

 The data specified in (s) can be converted within the range of 0 to 99999999 (BCD).

 When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below.

1760516560154-107.png

(d)BitData range
K1X01-bit0 to 9
K2X02-bit00 to 99
K3X03-bit000 to 999
K4X04-bit0000 to 9999
K5X05-bit00000 to 99999
K6X06-bit000000 to 999999
K7X07-bit0000000 to 9999999
K8X08-bit00000000 to 99999999

✎Note

The calculations in the CPU module such as the four arithmetic operations (+-×÷), increment and decrement instructions are all performed by BIN (binary number). Therefore, when sending BCD (decimal) digital switch information to the CPU module, please use the BIN(P) instruction (BCD→BIN conversion transfer instruction). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) instruction (BIN→BCD conversion transmission).

Error code

Error codeContent
4084HThe data input in the application instruction (s) exceeds the specified range
4085HThe output result of the read application instruction (s) exceeds the device range
4086HThe output result of the write application instruction (d) exceeds the device range

Example

1760516760461-209.png

When M0 is set, the BCD value of K8Y0 is converted into BIN and stored in D200.

FLT/BIN Integer → Binary Floating Point Number

FLT(P)

An instruction to convert a BIN 16-bit integer value into a binary floating point number (real number).

-[FLT  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The data register number that saves the BIN integer value-Signed BIN 16 bitANY16
(d)The data register number that saves the binary floating-point number (real number)-Single precision real numberANYREAL_32

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
FLTParameter 1             
Parameter 2                 

Features

The signed 16-bit data specified in (s) is converted into a binary floating point data and stored in (d)+1, (d).

1760516821297-118.png

✎Note

In each binary floating point number (real number) operation instruction, the specified K and H values will be automatically converted into a binary floating point number (real number), so there is no need to use the FLT instruction for conversion.

The inverse conversion instruction of this instruction is INT (convert a binary floating point value into a BIN integer).

Error code

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

Example

Four arithmetic using binary floating point operations

(1) Calculation example

1760516859697-895.png

(2) Sequence control program

1760517173347-405.png

DFLT/BIN Integer → Binary Floating Point Number

DFLT(P)

An instruction to convert a BIN 32-bit integer value into a binary floating point number (real number).

-[DFLT  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The data register number that saves the BIN32 integer value-Signed BIN 32 bitANY32
(d)The data register number that saves the binary floating-point number (real number)-Single precision real numberANYREAL_32

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DFLTParameter 1           
Parameter 2                 

Features

 Convert the signed BIN 32-bit data specified in (s) to binary floating point data and store them in (d)+1, (d).

1760517259004-868.png

✎Note

In each binary floating-point number (real number) operation instruction, the specified K and H values are automatically converted into a binary floating-point number (real number), so there is no need to use the DFLT instruction for conversion.

The inverse conversion instruction of this instruction is INT (convert a binary floating point value into a BIN integer).

Error code

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

Example

1760517298248-607.png

When M2=ON, convert the BIN 32-bit integer -7963590 in [D1, D0] into a single-precision floating point number -7963590.0 and store it in the [D101, D100] device.

VAL/ String → BIN 16-bit Data Conversion

VAL(P)

After converting the character string stored in the device number specified in (s) and later into BIN 16-bit data, store the number of digits in (d1) and store the BIN data in (d2).

[VAL  (s)  (d1)  (d2)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The character string converted to BIN data or the start device that stores the character string-StringANYSTRING_SINGLE
(d1)The start device that stores the number of digits of converted BIN data-Signed BIN 16 bitANY16_S_ARRAY
(d2)Start device for storing converted BIN data-Signed BIN 16 bitANY16_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
VALParameter 1                   
Parameter 2                
Parameter 3                

Features

After converting the character string stored in the device number specified in (s) and later into BIN 16-bit data, store the number of digits in (d1) and store the BIN data in (d2). In the conversion from character string to BIN, the data from the device number specified in (s) to the device number storing 00H is treated as a character string.

The total number of digits stored in (d1) stores the number of all characters (including signs and decimal points) representing the value. The number of decimal places stored in (d1)+1 stores the number of characters representing the decimal part after 2EH(.). For the BIN 16-bit data stored in (d2), the character string ignoring the decimal point is converted into a BIN value and stored.

1760517373906-417.png

Error code

Error codeContent
4082H

The character string specified by (s) could not be converted into a numeric value

For example:

The first character is not a negative sign or a space, space appears in the middle of the number, decimal point appears twice. Except for the first character that appears non-characters and decimal points, the number in the symbolic string with the decimal point is removed and the range between -32768 and 32767 is exceeded

Except for the first character, there are non-character and decimal Signs

For example, 3.4000 is 34000 after removing the decimal point, which is out of range.

4085H(s) read address exceeds the device range
408AHWhen the character number of character string the specified in (s) is other than 2 to 8.
408BHThe maximum range of the device is read when (s) taking character string, but 00H is not found as the end
4086HWhen using offset, the offset address of (d) exceeds the device range

Example

1760517421103-521.png

The result obtained above:

D0 corresponds to str length is 7.

D1 corresponds to a decimal point length of 3.

1760517499439-697.png

D10 corresponds to -12356 ignoring the decimal point.

1760517525868-463.png

DVAL/String → BIN32-bit Data Conversion

DVAL(P)

After converting the character string stored in the device number specified in (s) into BIN 32-bit data, store the number of digits in (d1) and store the BIN data in (d2).

-[DVAL  (s)  (d1)  (d2)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The character string converted to BIN data or the start device that stores the character string-StringANYSTRING_SINGLE
(d1)The start device that stores the number of digits of converted BIN data-Signed BIN 16 bitANY16_S_ARRAY
(d2)Start device for storing converted BIN data-Signed BIN 32 bitANY32_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DVALParameter 1                   
Parameter 2                
Parameter 3              

Features

After converting the character string stored in the device number specified in (s) into BIN 32-bit data, store the number of digits in (d1) and store the BIN data in (d2). In the conversion from character string to BIN, the data from the device number specified in (s) to the device number storing 00H is treated as a character string.

The total number of digits stored in (d1) stores the number of all characters (including signs and decimal points) representing the value. The number of decimal places stored in (d1)+1 stores the number of characters representing the decimal part after 2EH(.). For the BIN 32-bit data stored in (d2), the character string ignoring the decimal point is converted into a BIN value and stored.

1760517594117-892.png

Error code

Error codeContent
4082H

The character string specified by (s) could not be converted into a numeric value.

For example: The first character is not a negative sign or a space, space appears in the middle of the number, decimal point appears twice. Except for the first character that appears non-characters and decimal points, the number in the symbolic string with the decimal point is removed and the range between -2147483648 and 2147483647 is exceeded

Except for the first character, there are non-character and decimal Signs

For example, 3.000000000 is 3000000000 after removing the decimal point, which is out of range.

4085H(s) read address exceeds the device range
408AHWhen the character number of character string the specified in (s) is other than 2 to 13.
408BHThe maximum range of the device is read when (d1) and (d2) taking character string, but 00H is not found as the end
4086HWhen using offset, the offset address of (d) exceeds the device range

Example

1760517675391-831.png

The result obtained above

D0 corresponds to str length is 7.

D1 corresponds to a decimal point length of 3.

1760517745942-979.png

D10 corresponds to -12356 ignoring the decimal point

1760517809643-353.png

ASCI/HEX Code Data →ASCII Conversion

ASCI(P)

After the n characters (bits) in the HEX code data specified in (s) are converted into ASCII codes, they are stored after the device number specified in (d).

-[ASCI  (s)  (d)  (n)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The start number of the device storing the HEX code to be converted-BIN16 bitANY16
(d)The start number of the device storing the converted ASCII code-StringANYSTRING_SINGLE
(n)The number of characters (digits) of the HEX code to be converted1to256BIN16 bitANY16_U

Device used

InstructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
ASCIParameter 1             
Parameter 2                
Parameter 3                    

Features

The number of characters (bits) specified by (n) in the HEX code data specified in (s) is converted into ASCII code and stored in the device number specified in (d) or later.

ASCI(P) instruction uses 16-bit mode and 8-bit mode when converting. For the operation of each mode, please refer to the following content.

(1) 16-bit conversion mode (when SM8161=OFF)

Convert the digits of the HEX code after the device specified in (s) into ASCII, and transfer to the upper and lower 8 bits (bytes) of the device specified in (d). When using in 16-bit conversion mode, SM161 should always be turned OFF.  

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

1760517879658-305.png

Specify the number of bits (characters) and the conversion result

(n)K1K2K3K4K5K6K7K8K9
(d)
Under D200CBC043218
D200 on CBC04321
Under D201  CBC0432
D201 on   CBC043
Under D202    CBC04
D202 on Unchanged  CBC0
Under D203      CBC
D203 on       CB
Under D204        C

Bit structure in the case of (n)=K4

1760518002883-747.png

(2) 8-bit conversion mode (when SM161=ON) 

Convert the digits of the HEX code after the device specified in (s) into ASCII, and transfer to the lower 8 bits (bytes) of the device specified in (d). When using in 8-bit conversion mode, SM161 should always be set to ON for use.

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

1760518024863-940.png

If SM161 is set to ON, it will become 8-bit mode,

Perform conversion processing as shown below.

1760518128297-536.png

(n)K1K2K3K4K5K6K7K8K9
(d)
D200CBC043218
D201 CBC04321
D202  CBC0432
D203   CBC043
D204    CBC04
D205 Unchanged  CBC0
D206      CBC
D207       CB
D208        C

Bit structure in the case of (n)=K2

1760518162828-183.png

Error code

Error codeContent
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range
4084HWhen the value specified in (n) exceeds the range of 1 to 256

Example

1760518190168-651.png

• 16-bit conversion mode (when SM161=OFF)

Convert the digits of the HEX code after the device specified in d100 into ASCII, and transfer to the upper and lower 8 bits (bytes) of the device specified in d200. When using in 16-bit conversion mode, SM161 should always be turned OFF.

HEX/ASCII → HEX Code Data Conversion

HEX(P)

After the device number specified in (s), the ASCII data stored in the number of characters specified in (n) is converted to HEX code, and then stored in the device number specified in (d) or later.

-[HEX  (s)  (d)  (n)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The start device that stores the ASCII data converted to HEX code-StringANYSTRING_SINGLE
(d)The start device that stores converted HEX code-BIN16 bitANY16
(n)Number of characters (bytes) of converted ASCII data1 to 256BIN16 bitANY16_U

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
HEXParameter 1             
Parameter 2                
Parameter 3                    

Features

• After the device number specified in (s), the ASCII data stored in the number of characters specified in (n) is converted to HEX code, and then stored in the device number specified in (d) or later. The HEX(P) instruction uses 16-bit conversion mode and 8-bit conversion mode when converting. For the operation of each mode, please refer to the following content.

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

After converting the ASCII data stored in the upper and lower 8 digits (bytes) of the device specified in (s) into HEX code, it transmits every 4 digits to the device specified in (d). The number of characters to be converted is specified in (n).

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16-bit conversion mode, please always set SM161 to OFF.

SM161 is cleared when RUN→STOP.

In addition, it is necessary to store the ASCII data in the 16-bit conversion mode in the upper 8 bits of the device specified in (s).

In the following program, the conversion will be performed in the following manner.

1760518243532-544.png

Transform the source data

(s)ASCII dataHEX conversion
Under D20030H0
D200 on41HA
Under D20142HB
D201 on43HC
Under D20231H1
D202 on32H2
Under D20333H3
D203 on34H4
Under D20435H5

Bit structure in the case of (n)=K4

1760518318672-792.png

The number of characters specified and the conversion result becomes 0.

(n)123456789
(d)D102Unchanged    ...OH
D101...OH..OAH.OABHOABCHABC1H
D100...OH..OAH.OABHOABCHABC1HBC12HC123H1234H2345H

(2) 8-bit conversion mode (when SM161=ON)

After converting the ASCII data stored in the lower 8 digits of the device specified in (s) into HEX code, it will be transmitted to the device specified in (d) every 4 digits.

The number of characters to be converted is specified in (n).

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 8-bit conversion mode, please always turn on SM161.

SM161 is cleared when RUN→STOP.

In the following program, the conversion will be performed in the following manner.

1760518359500-132.png

Transform the source data

(s)ASCII dataHEX conversion
D20030H0
D20141HA
D20242HB
D20343HC
D20431H1
D20532H2
D20633H3
D20734H4
D20835H5

Bit structure in the case of (n)=K2

1760518380601-932.png

The number of characters specified and the conversion result becomes 0.

(n)123456789
(d)D102Unchanged    ...OH
D101...OH..OAH.OABHOABCHABC1H
D100...OH..OAH.OABHOABCHABC1HBC12HC123H1234H2345H

Error code

Error codeContent
4084HWhen the value specified in (n) exceeds the range.
When ASCII codes other than 30H to 39H and 41H to 46H are set in (s).
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760518408811-430.png

After converting the ASCII data stored in the upper and lower 8 digits (bytes) of the device specified in (s) into HEX code, it transmits every 4 digits to the device specified in (d). The number of characters to be converted is specified in (n).

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16-bit conversion mode, please always set SM161 to OFF.

CCD/Check Code

CCD(P)

Calculate the horizontal parity value and the sum check value of the error checking method used in communication and the like. In addition to these error checking methods, there are CRC (Cyclic

Redundancy Check). To calculate the CRC value, use the CRC(P) instruction.

-[CCD  (s)  (d)  (n)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)The start number of object device-BIN16 bitANY16
(d)The start number of the storage destination device of the calculated data-BIN16 bitANY16_ARRAY (number of elements: 2)
(n)Number of data1 to 256BIN16 bitANY16_U

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
CCDParameter 1               
Parameter 2                
Parameter 3                    

Features

Calculate the addition data and horizontal parity data of the data stored in (s) to (s)+(n)-1, and store the addition data in (d), horizontal parity

The data is stored in (d)+1. The modes used by this instruction in calculation are 16-bit mode and 8-bit mode. For the operation of each mode, please refer to the following content.

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

Regarding the data at point (n) starting with (s), the addition data and horizontal parity data of the high and low 8-bit data are stored in the Devicess (d) and (d)+1.

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16 bits, always set to OFF for use.

SM161 is cleared when RUN→STOP.

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

1760518549836-396.png

1760518595510-661.png

(2) 8-bit conversion mode (when SM161=ON)

Regarding (s) as the starting point (n) data (lower 8 bits only), its addition data and horizontal parity data are stored in the devices (d) and (d)+1.

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. If it is used in 8 bits, it should always be set to ON for use.

SM161 is cleared when RUN→STOP.

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

1760518650396-504.png

1760518681791-265.png

Error code

Error codeContent
4084HWhen the value specified in (n) exceed the range of 1 to 256.
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760518721394-977.png

Regarding D10 as the initial 10-point data, the addition data and horizontal parity data of the high and low 8-bit data are stored in the Devices of D0 and D0+1.

SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16 bits, always set to OFF for use.

GBIN/Gray code → BIN 16-bit Data Conversion

GBIN(P)

Convert the BIN 16-bit Gray code data stored in the device specified in (s) into BIN 16-bit data, and store it in the device specified in (d).

-[GBIN  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)Gray code data or the start device that stores Gray code0 to 32767BIN16 bitANY16_S
(d)The start device that stores the converted BIN data-BIN16 bitANY16_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
GBINParameter 1             
Parameter 2                

Features

Convert the BIN 16-bit Gray code data stored in the device specified in (s) into BIN 16-bit data, and store it in the device specified in (d).

1760518798409-907.png

GRY→BIN Mathematical Algorithm: Starting from the second bit from the left, XOR each bit with the decoded value of the left bit as the decoded value of the bit (the leftmost bit remains unchanged).

Error code

Error codeContent
4084HWhen the value specified in (s) exceeds the range
4085HWhen the specified device range is read to exceed the range of the corresponding device
4086HWhen the specified device range is written to exceed the range of the corresponding device

Example

1760518822792-557.png

It could be used when the encoder of Gray code method is used to detect the absolute position.

For S, the numerical are valid in the range of 0 to 32767.

DGBIN/Gray Code → BIN32-bit Data Conversion

DGBIN(P)

Convert the BIN32-bit Gray code data stored in the device specified in (s) to BIN 32-bit data and store it in the device specified in (d).

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)Gray code data or the start device that stores Gray code0 to 2147483647BIN32 bitANY32_S
(d)The start device that stores converted BIN data-BIN32 bitANY32_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DGBINParameter 1           
Parameter 2              

Features

Convert the BIN32-bit Gray code data stored in the device specified in (s) into BIN 32-bit data, and store it in the device specified in (d).

1760518892993-298.png

(s)+1: high 16 bits

(s): low 16 bits

GRY→BIN Mathematical Algorithm: Starting from the second bit from the left, XOR each bit with the decoded value of the left bit as the decoded value of the bit (the leftmost bit remains unchanged).

Error code

Error codeContent
4084HWhen the value specified in (s) exceeds the range
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760518916894-252.png

GRY/BIN 16-bit Data → Gray Code Conversion

GRY(P)

After converting the BIN 16-bit data of the device specified in (s) to BIN 16-bit Gray code data, it is stored in the device specified in (d).

-[GRY  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)BIN data or the start device that stores BIN data0 to 32767BIN16 bitANY16_S
(d)The start device that stores the converted Gray code-BIN16 bitANY16_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
GRYParameter 1             
Parameter 2                

Features

Convert the BIN 16-bit data specified in (s) into BIN 16-bit Gray code, and store it in the device specified in (d).

1760518963231-603.png

BIN→GRY Mathematical Algorithm: Starting from the rightmost bit, XOR each bit with the left bit as the value corresponding to the GRY bit, and the leftmost bit remains unchanged (equivalent to 0 on the left) .

Error code

Error codeContent
4084HWhen the value specified in (s) exceeds the range
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760519299493-121.png

As shown in the above ladder diagram:

1760519319104-654.png

For S, the range of 0 to 32767 is valid.

DGRY/BIN 32-bit Data → Gray Code Conversion

DGRY(P)

After converting the BIN 16-bit data of the device specified in (s) to BIN 16-bit Gray code data, it is stored in the device specified in (d).

-[GRY  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)BIN data or the start device that stores BIN data0 to 2147483647BIN32 bitANY32_S
(d)The start device that stores the converted Gray code-BIN32 bitANY32_S

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DGRYParameter 1           
Parameter 2              

Features

Convert the BIN32-bit data specified in (s) into BIN32-bit Gray code and store it in the device specified in (d)

1760519357374-958.png

(s)+1: high 16 bits

(s): low 16 bits

BIN→GRY Mathematical Algorithm: Starting from the rightmost bit, XOR each bit with the left bit as the value corresponding to the GRY bit, and the leftmost bit remains unchanged (equivalent to 0 on the left) .

Error code

Error codeContent
4084HWhen the value specified in (s) exceeds the range
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760519378928-755.png

As shown in the above ladder diagram:

1760519409066-947.png

PRUN/Octal digit transmission (16-bit data)

PRUN(P)

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

-[PRUN  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)Custom variable type
(s)Digit specification*1-BIN16 bitANY16--
(d)Transfer target device number*1-BIN16 bitANY16--

Device used

InstructionParameterDevicesIndex modificationPulse expansion
XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
PRUNParameter 1                      
Parameter 2                      

Function

• Octal digit device→ decimal digit device

1760519463939-108.png

• Decimal digit device → octal digit device

1760519565692-716.png

Error code

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

Example

1760519583756-167.png

As shown in the above ladder diagram: X0~X17 takes the value of octal digits and pass it to the devices corresponding to M.

1760519614678-176.png

DPRUN/Otal Digit Transmission (32-bit data)

DPRUN(P)

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

-[PRUN  (s)  (d)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(s)Digit specification*1-BIN32 bitANY32
(d)Transfer destination device number*1-BIN32 bitANY32

Device used

instructionParameterDevices

Index

modification

Pulse

extension

XYMSSMT(bit)C(bit)LC(bit)HSC(bit)D.bKnXKnYKnMKnSTCDRSDLCHSCKHE[D]XXP
DPRUNParameter 1                      
Parameter 2                      

Features

• Octal digit device to decimal digit device

1760519664128-168.png

• Decimal digit device → octal digit device

1760519688020-796.png

Error code

Error codeContent
4085HWhen the specified device range is read to exceed the corresponding device range
4086HWhen the specified device range is written to exceed the corresponding device range

Example

1760519705881-806.png

As shown in the above ladder diagram:

X0 to X27 take the value of octal digits and pass them to the Devices corresponding to M.