09 Data conversion

Version 1.1 by Wecon on 2025/09/03 21:03

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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[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.

(1): Must be set to 0.

07-4 Basic instructions_html_60d682f7d62a0273.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.

07-4 Basic instructions_html_c5510424f376f967.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) command (BCD→BIN conversion transfer command). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) command (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

07-4 Basic instructions_html_6928ca1c58786081.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[D]XXP
BINParameter 1
Parameter 2   

Features

The 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).

(1): Must become 0.

07-4 Basic instructions_html_e50b96acd9fbf853.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.

07-4 Basic instructions_html_aee0a24ea566ee4a.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) command (BCD→BIN conversion transfer command). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) command (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

07-4 Basic instructions_html_6ba5c12c1cca40ef.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

InstructionParameterDevicesOffset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[D]XXP
DBINParameter 1
Parameter 2     

Features

The 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).

(1): Must become 0.

07-4 Basic instructions_html_f29af8020e49ee52.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.

07-4 Basic instructions_html_b2a9765d684738a.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) command (BCD→BIN conversion transfer command). In addition, when outputting to the 7-segment display of BCD (decimal number), please use the BCD(P) command (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

07-4 Basic instructions_html_5f1bfd7d87654823.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[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).

07-4 Basic instructions_html_b641c90fc891da0f.png

07-4 Basic instructions_html_ac7b8ff0fc346d22.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

image-20220609135337-1.png

(2) Sequence control program

07-4 Basic instructions_html_534a499aa3aff2bd.png

(D0) → (D21, D20)

BIN binary floating point operations

(X17 to X10) → (D22)

BCD BIN

(D22) → (D25, D24)

BIN binary floating point operations

K345÷K10 → (D27, D26)

Binary floating point operations

(D29,D28)×(D27,D26) → (D11,D10)

Binary floating-point number multiplication

(D21,D20)÷(D25,D24) → (D29,D28)

Binary floating-point number division operation →Binary floating-point number operation

(D11,D10) → (D13,D12)

Binary floating-point calculations →

Decimal floating-point calculations monitoring

(D11,D10) → (D13,D12)

Binary floating point operations 32-bit BIN integer

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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[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).

07-4 Basic instructions_html_ad1ab086d88e414d.png

07-4 Basic instructions_html_d28bfd0b2e180da8.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

07-4 Basic instructions_html_59e1ee5a835ee37b.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

Offset modification

Pulse extension

KnYKnMKnSTCDRSD[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.

07-4 Basic instructions_html_2f217e076dad911.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

07-4 Basic instructions_html_6a37a91af926ad4a.png

The result obtained above:

D0 corresponds to str length is 7.

D1 corresponds to a decimal point length of 3.

07-4 Basic instructions_html_c246a80634805a0f.png

D10 corresponds to -12356 ignoring the decimal point.

07-4 Basic instructions_html_1d720a7ec20fcbd0.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

Offset modification

Pulse extension

KnYKnMKnSTCDRSDLCHSC[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.

07-4 Basic instructions_html_deb43c301584a495.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

07-4 Basic instructions_html_bd7d0c8fcdf2ac04.png

The result obtained above

D0 corresponds to str length is 7.

D1 corresponds to a decimal point length of 3.

07-4 Basic instructions_html_c246a80634805a0f.png

D10 corresponds to -12356 ignoring the decimal point

07-4 Basic instructions_html_a33cef1638ad885e.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKHE[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.

image-20220609140410-2.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

ASCII code

"0"=30H "1"=32H "5"=35H

"A"=41H "2"=32H "6"=36H

"B"=42H "3"=33H "7"=37H

"C"=43H "4"=34H "8"=38H

07-4 Basic instructions_html_4dfde77feda27887.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.

image-20220609140635-3.png

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

Perform conversion processing as shown below.

image-20220609140723-4.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

ASCII

"0"=30H "1"=31H "5"=35H

"A"=41H "2"=32H "6"=36H

"B"=42H "3"=33H "7"=37H

"C"=43H "4"=34H "8"=38H

07-4 Basic instructions_html_923610a5469a8c3d.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

07-4 Basic instructions_html_3bfe1060c232ee52.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[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.

image-20220609141021-5.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

07-4 Basic instructions_html_304e7b8deb433792.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.

07-4 Basic instructions_html_e3b417a86a19aa3e.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

07-4 Basic instructions_html_98ddbde13d1ca597.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

07-4 Basic instructions_html_3261e16130b75547.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) command.

-[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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[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.

16-bit conversion mode

07-4 Basic instructions_html_e166d8d8585d88b8.png

If the number of 1 is odd, the horizontal parity is 1

If the number of 1 is even, the horizontal parity is 0

07-4 Basic instructions_html_943ba845ed8ba622.png

1091 at BCD

Horizontal parity

07-4 Basic instructions_html_a09695e96b475e1b.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.

07-4 Basic instructions_html_7131045570d715c5.png

If the number of 1 is odd, the horizontal parity is 1

If the number of 1 is even, the horizontal parity is 0

07-4 Basic instructions_html_8297d8c2a3152ba1.png

1091 at BCD

Horizontal parity

07-4 Basic instructions_html_ee059d50f21ceb6f.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

07-4 Basic instructions_html_ae409f8be1106eae.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 Devicess 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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[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).

07-4 Basic instructions_html_43a1f4febbb3924a.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

07-4 Basic instructions_html_922cc38651d7955c.png

07-4 Basic instructions_html_92013465d9efdae2.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[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).

07-4 Basic instructions_html_cb8880def5bf48e5.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

07-4 Basic instructions_html_3514e3bead2910b7.png

07-4 Basic instructions_html_cb8880def5bf48e5.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDKH[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).

07-4 Basic instructions_html_26b717f7fa6bab76.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

07-4 Basic instructions_html_6127738ab3840b44.png

As shown in the above Circuit program:

07-4 Basic instructions_html_f8d398516494cace.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

Offset modification

Pulse extension

KnXKnYKnMKnSTCDRSDLCHSCKH[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)

07-4 Basic instructions_html_269731957bf0d6a1.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

07-4 Basic instructions_html_f8f05dd202518dde.png

As shown in the above Circuit program:

07-4 Basic instructions_html_b41b41fe792eece7.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

Offset modification

Pulse extension

KnXKnYKnM[D]XXP
DPRUNParameter 1 
Parameter 2 

Features

• Octal digit device to decimal digit device

07-4 Basic instructions_html_3ab0bebbf73a2eab.png

• Decimal digit device → octal digit device

07-4 Basic instructions_html_3ab0bebbf73a2eab.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

07-4 Basic instructions_html_aaa4427d97f8cb5b.png

As shown in the above Circuit program:

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