Wiki source code of 6.8 Data Conversion instruction
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | === **BCD/BIN → BCD** === | ||
| 2 | |||
| 3 | **BCD(P)** | ||
| 4 | |||
| 5 | Convert the BIN data of the device specified in (s) to BCD, and store it in the device specified in (d). | ||
| 6 | |||
| 7 | 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. | ||
| 8 | |||
| 9 | -[BCD (s) (d)] | ||
| 10 | |||
| 11 | **Content, range and data type** | ||
| 12 | |||
| 13 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 14 | |(s)|BIN data or start device storing BIN data|0 to 9999|Signed BIN16|ANY16 | ||
| 15 | |(d)|Start device for storing BCD data|-|BCD 4 digits|ANY16 | ||
| 16 | |||
| 17 | **Device used** | ||
| 18 | |||
| 19 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 20 | **Index** | ||
| 21 | |||
| 22 | **modification** | ||
| 23 | )))|((( | ||
| 24 | **Pulse** | ||
| 25 | |||
| 26 | **extension** | ||
| 27 | ))) | ||
| 28 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 29 | |(% rowspan="2" %)BCD|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 30 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 31 | |||
| 32 | **Features** | ||
| 33 | |||
| 34 | 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). | ||
| 35 | |||
| 36 | The data specified in (s) can be converted within the range of 0 to 9999 (BCD). | ||
| 37 | |||
| 38 | When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below. | ||
| 39 | |||
| 40 | (% style="text-align:center" %) | ||
| 41 | [[image:1760515828495-204.png]] | ||
| 42 | |||
| 43 | The data specified in (s) can be converted in the range of K0 to K9999 by BCD (decimal number). | ||
| 44 | |||
| 45 | When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below. | ||
| 46 | |||
| 47 | (% style="text-align:center" %) | ||
| 48 | [[image:1760515993069-622.png||height="194" width="491"]] | ||
| 49 | |||
| 50 | |**(d)**|**Digits**|**Data range** | ||
| 51 | |K1Y0|1-bit|0 to 9 | ||
| 52 | |K2Y0|2-bit|00 to 99 | ||
| 53 | |K3Y0|3-bit|000 to 999 | ||
| 54 | |K4Y0|4-bit|0000 to 9999 | ||
| 55 | |||
| 56 | **✎Note** | ||
| 57 | |||
| 58 | 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). | ||
| 59 | |||
| 60 | **Error code** | ||
| 61 | |||
| 62 | |**Error code**|**Content** | ||
| 63 | |4084H|The data input in the application instruction (s) exceeds the specified range | ||
| 64 | |4085H|The output result of the read application instruction (s) exceeds the device range | ||
| 65 | |4086H|The output result of the write application instruction (d) exceeds the device range | ||
| 66 | |||
| 67 | **Example** | ||
| 68 | |||
| 69 | (% style="text-align:center" %) | ||
| 70 | [[image:1760516200225-646.png]] | ||
| 71 | |||
| 72 | |||
| 73 | When M0 is set, the BIN value of D200 is converted into BCD and stored in K1Y0. | ||
| 74 | |||
| 75 | === **BIN/4-bit BCD → BIN** === | ||
| 76 | |||
| 77 | **BIN(P)** | ||
| 78 | |||
| 79 | Convert the BCD data of the device specified in (s) to BIN and store it in the device specified in (d). | ||
| 80 | |||
| 81 | 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. | ||
| 82 | |||
| 83 | -[BIN (s) (d)] | ||
| 84 | |||
| 85 | **Content, range and data type** | ||
| 86 | |||
| 87 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 88 | |(s)|BCD data or start device storing BIN data|0 to 9999|BCD 4 digits|ANY16 | ||
| 89 | |(d)|Start device for storing BIN data|-|Signed BIN16|ANY16 | ||
| 90 | |||
| 91 | **Device used** | ||
| 92 | |||
| 93 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 94 | **Index** | ||
| 95 | |||
| 96 | **modification** | ||
| 97 | )))|((( | ||
| 98 | **Pulse** | ||
| 99 | |||
| 100 | **extension** | ||
| 101 | ))) | ||
| 102 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 103 | |(% rowspan="2" %)BIN|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 104 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 105 | |||
| 106 | **Features** | ||
| 107 | |||
| 108 | 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). | ||
| 109 | |||
| 110 | |||
| 111 | (% style="text-align:center" %) | ||
| 112 | [[image:1760516268370-140.png]] | ||
| 113 | |||
| 114 | The data specified in (s) can be converted within the range of 0 to 9999 (BCD). | ||
| 115 | |||
| 116 | When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below. | ||
| 117 | |||
| 118 | (% style="text-align:center" %) | ||
| 119 | [[image:1760516329466-296.png]] | ||
| 120 | |||
| 121 | |**(d)**|**Digits**|**Data range** | ||
| 122 | |K1X0|1-bit|0 to 9 | ||
| 123 | |K2X0|2-bit|00 to 99 | ||
| 124 | |K3X0|3-bit|000 to 999 | ||
| 125 | |K4X0|4-bit|0000 to 9999 | ||
| 126 | |||
| 127 | **✎Note** | ||
| 128 | |||
| 129 | 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). | ||
| 130 | |||
| 131 | **Error code** | ||
| 132 | |||
| 133 | |**Error code**|**Content** | ||
| 134 | |4084H|The data input in the application instruction (s) exceeds the specified range | ||
| 135 | |4085H|The output result of the read application instruction (s) exceeds the device range | ||
| 136 | |4086H|The output result of the write application instruction (d) exceeds the device range | ||
| 137 | |||
| 138 | **Example** | ||
| 139 | |||
| 140 | (% style="text-align:center" %) | ||
| 141 | [[image:1760516369609-652.png||height="94" width="379"]] | ||
| 142 | |||
| 143 | When M0 is set, the BCD value of K1Y0 is converted into BIN and stored in D200. | ||
| 144 | |||
| 145 | === **DBIN/8-bit BCD → BIN** === | ||
| 146 | |||
| 147 | **DBIN(P)** | ||
| 148 | |||
| 149 | Convert the BCD data of the device specified in (s) to BIN and store it in the device specified in (d). | ||
| 150 | |||
| 151 | 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. | ||
| 152 | |||
| 153 | -[DBIN (s) (d)] | ||
| 154 | |||
| 155 | **Content, range and data type** | ||
| 156 | |||
| 157 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 158 | |(s)|BCD data or start device storing BIN data|0 to 99999999|BCD 8 digits|ANY32 | ||
| 159 | |(d)|Start device for storing BIN data|-|Signed BIN32|ANY32 | ||
| 160 | |||
| 161 | **Device used** | ||
| 162 | |||
| 163 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|((( | ||
| 164 | **Pulse** | ||
| 165 | |||
| 166 | **extension** | ||
| 167 | ))) | ||
| 168 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 169 | |(% rowspan="2" %)DBIN|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●|●|●|●|●| |●|● | ||
| 170 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 171 | |||
| 172 | **Features** | ||
| 173 | |||
| 174 | 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). | ||
| 175 | |||
| 176 | (% style="text-align:center" %) | ||
| 177 | [[image:1760516454645-987.png]] | ||
| 178 | |||
| 179 | The data specified in (s) can be converted within the range of 0 to 99999999 (BCD). | ||
| 180 | |||
| 181 | When the data specified in (s) or (d) is digit specification, the conditions are as shown in the table below. | ||
| 182 | |||
| 183 | (% style="text-align:center" %) | ||
| 184 | [[image:1760516560154-107.png]] | ||
| 185 | |||
| 186 | |**(d)**|**Bit**|**Data range** | ||
| 187 | |K1X0|1-bit|0 to 9 | ||
| 188 | |K2X0|2-bit|00 to 99 | ||
| 189 | |K3X0|3-bit|000 to 999 | ||
| 190 | |K4X0|4-bit|0000 to 9999 | ||
| 191 | |K5X0|5-bit|00000 to 99999 | ||
| 192 | |K6X0|6-bit|000000 to 999999 | ||
| 193 | |K7X0|7-bit|0000000 to 9999999 | ||
| 194 | |K8X0|8-bit|00000000 to 99999999 | ||
| 195 | |||
| 196 | **✎Note** | ||
| 197 | |||
| 198 | 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). | ||
| 199 | |||
| 200 | **Error code** | ||
| 201 | |||
| 202 | |**Error code**|**Content** | ||
| 203 | |4084H|The data input in the application instruction (s) exceeds the specified range | ||
| 204 | |4085H|The output result of the read application instruction (s) exceeds the device range | ||
| 205 | |4086H|The output result of the write application instruction (d) exceeds the device range | ||
| 206 | |||
| 207 | **Example** | ||
| 208 | |||
| 209 | (% style="text-align:center" %) | ||
| 210 | [[image:1760516760461-209.png||height="113" width="454"]] | ||
| 211 | |||
| 212 | When M0 is set, the BCD value of K8Y0 is converted into BIN and stored in D200. | ||
| 213 | |||
| 214 | === **FLT/BIN Integer → Binary Floating Point Number** === | ||
| 215 | |||
| 216 | **FLT(P)** | ||
| 217 | |||
| 218 | An instruction to convert a BIN 16-bit integer value into a binary floating point number (real number). | ||
| 219 | |||
| 220 | -[FLT (s) (d)] | ||
| 221 | |||
| 222 | **Content, range and data type** | ||
| 223 | |||
| 224 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 225 | |(s)|The data register number that saves the BIN integer value|-|Signed BIN 16 bit|ANY16 | ||
| 226 | |(d)|The data register number that saves the binary floating-point number (real number)|-|Single precision real number|ANYREAL_32 | ||
| 227 | |||
| 228 | **Device used** | ||
| 229 | |||
| 230 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 231 | **Index** | ||
| 232 | |||
| 233 | **modification** | ||
| 234 | )))|((( | ||
| 235 | **Pulse** | ||
| 236 | |||
| 237 | **extension** | ||
| 238 | ))) | ||
| 239 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 240 | |(% rowspan="2" %)FLT|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 241 | |Parameter 2| | | | | | | | | | | | | | |●|●|●|●|●|●|●| | | |●|● | ||
| 242 | |||
| 243 | **Features** | ||
| 244 | |||
| 245 | The signed 16-bit data specified in (s) is converted into a binary floating point data and stored in (d)+1, (d). | ||
| 246 | |||
| 247 | (% style="text-align:center" %) | ||
| 248 | [[image:1760516821297-118.png]] | ||
| 249 | |||
| 250 | |||
| 251 | **✎Note** | ||
| 252 | |||
| 253 | 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. | ||
| 254 | |||
| 255 | The inverse conversion instruction of this instruction is INT (convert a binary floating point value into a BIN integer). | ||
| 256 | |||
| 257 | **Error code** | ||
| 258 | |||
| 259 | |**Error code**|**Content** | ||
| 260 | |4085H|When the device specified in the read application instruction (s) exceeds the corresponding device range | ||
| 261 | |4086H|When the device specified in the write application instruction (d) exceeds the corresponding device range | ||
| 262 | |||
| 263 | **Example** | ||
| 264 | |||
| 265 | Four arithmetic using binary floating point operations | ||
| 266 | |||
| 267 | (1) Calculation example | ||
| 268 | |||
| 269 | (% style="text-align:center" %) | ||
| 270 | [[image:1760516859697-895.png]] | ||
| 271 | |||
| 272 | (2) Sequence control program | ||
| 273 | |||
| 274 | (% style="text-align:center" %) | ||
| 275 | [[image:1760517173347-405.png]] | ||
| 276 | |||
| 277 | === **DFLT/BIN Integer → Binary Floating Point Number** === | ||
| 278 | |||
| 279 | **DFLT(P)** | ||
| 280 | |||
| 281 | An instruction to convert a BIN 32-bit integer value into a binary floating point number (real number). | ||
| 282 | |||
| 283 | -[DFLT (s) (d)] | ||
| 284 | |||
| 285 | **Content, range and data type** | ||
| 286 | |||
| 287 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 288 | |(s)|The data register number that saves the BIN32 integer value|-|Signed BIN 32 bit|ANY32 | ||
| 289 | |(d)|The data register number that saves the binary floating-point number (real number)|-|Single precision real number|ANYREAL_32 | ||
| 290 | |||
| 291 | **Device used** | ||
| 292 | |||
| 293 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 294 | **Index** | ||
| 295 | |||
| 296 | **modification** | ||
| 297 | )))|((( | ||
| 298 | **Pulse** | ||
| 299 | |||
| 300 | **extension** | ||
| 301 | ))) | ||
| 302 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 303 | |(% rowspan="2" %)DFLT|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●|●|●|●|●| |●|● | ||
| 304 | |Parameter 2| | | | | | | | | | | | | | |●|●|●|●|●|●|●| | | |●|● | ||
| 305 | |||
| 306 | **Features** | ||
| 307 | |||
| 308 | Convert the signed BIN 32-bit data specified in (s) to binary floating point data and store them in (d)+1, (d). | ||
| 309 | |||
| 310 | (% style="text-align:center" %) | ||
| 311 | [[image:1760517259004-868.png]] | ||
| 312 | |||
| 313 | |||
| 314 | |||
| 315 | **✎Note** | ||
| 316 | |||
| 317 | 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. | ||
| 318 | |||
| 319 | The inverse conversion instruction of this instruction is INT (convert a binary floating point value into a BIN integer). | ||
| 320 | |||
| 321 | **Error code** | ||
| 322 | |||
| 323 | |**Error code**|**Content** | ||
| 324 | |4085H|When the device specified in the read application instruction (s) exceeds the corresponding device range | ||
| 325 | |4086H|When the device specified in the write application instruction (d) exceeds the corresponding device range | ||
| 326 | |||
| 327 | **Example** | ||
| 328 | |||
| 329 | (% style="text-align:center" %) | ||
| 330 | [[image:1760517298248-607.png]] | ||
| 331 | |||
| 332 | 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. | ||
| 333 | |||
| 334 | === **VAL/ String → BIN 16-bit Data Conversion** === | ||
| 335 | |||
| 336 | **VAL(P)** | ||
| 337 | |||
| 338 | 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). | ||
| 339 | |||
| 340 | [VAL (s) (d1) (d2)] | ||
| 341 | |||
| 342 | **Content, range and data type** | ||
| 343 | |||
| 344 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 345 | |(s)|The character string converted to BIN data or the start device that stores the character string|-|String|ANYSTRING_SINGLE | ||
| 346 | |(d1)|The start device that stores the number of digits of converted BIN data|-|Signed BIN 16 bit|ANY16_S_ARRAY | ||
| 347 | |(d2)|Start device for storing converted BIN data|-|Signed BIN 16 bit|ANY16_S | ||
| 348 | |||
| 349 | **Device used** | ||
| 350 | |||
| 351 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 352 | **Index** | ||
| 353 | |||
| 354 | **modification** | ||
| 355 | )))|((( | ||
| 356 | **Pulse** | ||
| 357 | |||
| 358 | **extension** | ||
| 359 | ))) | ||
| 360 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 361 | |(% rowspan="3" %)VAL|Parameter 1| | | | | | | | | | | | | | |●|●|●|●|●| | | | | |●|● | ||
| 362 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 363 | |Parameter 3| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 364 | |||
| 365 | **Features** | ||
| 366 | |||
| 367 | 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. | ||
| 368 | |||
| 369 | 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. | ||
| 370 | |||
| 371 | (% style="text-align:center" %) | ||
| 372 | [[image:1760517373906-417.png]] | ||
| 373 | |||
| 374 | **Error code** | ||
| 375 | |||
| 376 | |**Error code**|**Content** | ||
| 377 | |4082H|((( | ||
| 378 | The character string specified by (s) could not be converted into a numeric value | ||
| 379 | |||
| 380 | For example: | ||
| 381 | |||
| 382 | 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 | ||
| 383 | |||
| 384 | Except for the first character, there are non-character and decimal Signs | ||
| 385 | |||
| 386 | For example, 3.4000 is 34000 after removing the decimal point, which is out of range. | ||
| 387 | ))) | ||
| 388 | |4085H|(s) read address exceeds the device range | ||
| 389 | |408AH|When the character number of character string the specified in (s) is other than 2 to 8. | ||
| 390 | |408BH|The maximum range of the device is read when (s) taking character string, but 00H is not found as the end | ||
| 391 | |4086H|When using offset, the offset address of (d) exceeds the device range | ||
| 392 | |||
| 393 | **Example** | ||
| 394 | |||
| 395 | (% style="text-align:center" %) | ||
| 396 | [[image:1760517421103-521.png]] | ||
| 397 | |||
| 398 | |||
| 399 | The result obtained above: | ||
| 400 | |||
| 401 | D0 corresponds to str length is 7. | ||
| 402 | |||
| 403 | D1 corresponds to a decimal point length of 3. | ||
| 404 | |||
| 405 | (% style="text-align:center" %) | ||
| 406 | [[image:1760517499439-697.png]] | ||
| 407 | |||
| 408 | |||
| 409 | D10 corresponds to -12356 ignoring the decimal point. | ||
| 410 | |||
| 411 | |||
| 412 | (% style="text-align:center" %) | ||
| 413 | [[image:1760517525868-463.png]] | ||
| 414 | |||
| 415 | === **DVAL/String → BIN32-bit Data Conversion** === | ||
| 416 | |||
| 417 | **DVAL(P)** | ||
| 418 | |||
| 419 | 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). | ||
| 420 | |||
| 421 | -[DVAL (s) (d1) (d2)] | ||
| 422 | |||
| 423 | **Content, range and data type** | ||
| 424 | |||
| 425 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 426 | |(s)|The character string converted to BIN data or the start device that stores the character string|-|String|ANYSTRING_SINGLE | ||
| 427 | |(d1)|The start device that stores the number of digits of converted BIN data|-|Signed BIN 16 bit|ANY16_S_ARRAY | ||
| 428 | |(d2)|Start device for storing converted BIN data|-|Signed BIN 32 bit|ANY32_S | ||
| 429 | |||
| 430 | **Device used** | ||
| 431 | |||
| 432 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 433 | **Index** | ||
| 434 | |||
| 435 | **modification** | ||
| 436 | )))|((( | ||
| 437 | **Pulse** | ||
| 438 | |||
| 439 | **extension** | ||
| 440 | ))) | ||
| 441 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 442 | |(% rowspan="3" %)DVAL|Parameter 1| | | | | | | | | | | | | | |●|●|●|●|●| | | | | |●|● | ||
| 443 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 444 | |Parameter 3| | | | | | | | | | | |●|●|●|●|●|●|●|●|●|●| | | |●|● | ||
| 445 | |||
| 446 | **Features** | ||
| 447 | |||
| 448 | 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. | ||
| 449 | |||
| 450 | 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. | ||
| 451 | |||
| 452 | (% style="text-align:center" %) | ||
| 453 | [[image:1760517594117-892.png]] | ||
| 454 | |||
| 455 | |||
| 456 | **Error code** | ||
| 457 | |||
| 458 | |**Error code**|**Content** | ||
| 459 | |4082H|((( | ||
| 460 | The character string specified by (s) could not be converted into a numeric value. | ||
| 461 | |||
| 462 | 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 | ||
| 463 | |||
| 464 | Except for the first character, there are non-character and decimal Signs | ||
| 465 | |||
| 466 | For example, 3.000000000 is 3000000000 after removing the decimal point, which is out of range. | ||
| 467 | ))) | ||
| 468 | |4085H|(s) read address exceeds the device range | ||
| 469 | |408AH|When the character number of character string the specified in (s) is other than 2 to 13. | ||
| 470 | |408BH|The maximum range of the device is read when (d1) and (d2) taking character string, but 00H is not found as the end | ||
| 471 | |4086H|When using offset, the offset address of (d) exceeds the device range | ||
| 472 | |||
| 473 | **Example** | ||
| 474 | |||
| 475 | (% style="text-align:center" %) | ||
| 476 | [[image:1760517675391-831.png]] | ||
| 477 | |||
| 478 | |||
| 479 | The result obtained above | ||
| 480 | |||
| 481 | D0 corresponds to str length is 7. | ||
| 482 | |||
| 483 | D1 corresponds to a decimal point length of 3. | ||
| 484 | |||
| 485 | (% style="text-align:center" %) | ||
| 486 | [[image:1760517745942-979.png]] | ||
| 487 | |||
| 488 | D10 corresponds to -12356 ignoring the decimal point | ||
| 489 | |||
| 490 | |||
| 491 | (% style="text-align:center" %) | ||
| 492 | [[image:1760517809643-353.png]] | ||
| 493 | |||
| 494 | === **ASCI/HEX Code Data →ASCII Conversion** === | ||
| 495 | |||
| 496 | **ASCI(P)** | ||
| 497 | |||
| 498 | 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). | ||
| 499 | |||
| 500 | -[ASCI (s) (d) (n)] | ||
| 501 | |||
| 502 | **Content, range and data type** | ||
| 503 | |||
| 504 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 505 | |(s)|The start number of the device storing the HEX code to be converted|-|BIN16 bit|ANY16 | ||
| 506 | |(d)|The start number of the device storing the converted ASCII code|-|String|ANYSTRING_SINGLE | ||
| 507 | |(n)|The number of characters (digits) of the HEX code to be converted|1to256|BIN16 bit|ANY16_U | ||
| 508 | |||
| 509 | **Device used** | ||
| 510 | |||
| 511 | |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 512 | **Index** | ||
| 513 | |||
| 514 | **modification** | ||
| 515 | )))|((( | ||
| 516 | **Pulse** | ||
| 517 | |||
| 518 | **extension** | ||
| 519 | ))) | ||
| 520 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 521 | |(% rowspan="3" %)ASCI|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 522 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 523 | |Parameter 3| | | | | | | | | | | | | | | | |●|●|●| | |●|●| | |● | ||
| 524 | |||
| 525 | **Features** | ||
| 526 | |||
| 527 | 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. | ||
| 528 | |||
| 529 | 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. | ||
| 530 | |||
| 531 | **(1) 16-bit conversion mode (when SM8161=OFF)** | ||
| 532 | |||
| 533 | 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. | ||
| 534 | |||
| 535 | In the case of the following program, perform the conversion as shown below. | ||
| 536 | |||
| 537 | (% style="text-align:center" %) | ||
| 538 | [[image:1760517879658-305.png||height="201" width="654"]] | ||
| 539 | |||
| 540 | |||
| 541 | **Specify the number of bits (characters) and the conversion result** | ||
| 542 | |||
| 543 | |**(n)**|(% rowspan="2" %)**K1**|(% rowspan="2" %)**K2**|(% rowspan="2" %)**K3**|(% rowspan="2" %)**K4**|(% rowspan="2" %)**K5**|(% rowspan="2" %)**K6**|(% rowspan="2" %)**K7**|(% rowspan="2" %)**K8**|(% rowspan="2" %)**K9** | ||
| 544 | |**(d)** | ||
| 545 | |Under D200|C|B|C|0|4|3|2|1|8 | ||
| 546 | |D200 on| |C|B|C|0|4|3|2|1 | ||
| 547 | |Under D201| | |C|B|C|0|4|3|2 | ||
| 548 | |D201 on| | | |C|B|C|0|4|3 | ||
| 549 | |Under D202| | | | |C|B|C|0|4 | ||
| 550 | |D202 on| |(% colspan="2" %)Unchanged| | |C|B|C|0 | ||
| 551 | |Under D203| | | | | | |C|B|C | ||
| 552 | |D203 on| | | | | | | |C|B | ||
| 553 | |Under D204| | | | | | | | |C | ||
| 554 | |||
| 555 | **Bit structure in the case of (n)=K4** | ||
| 556 | |||
| 557 | (% style="text-align:center" %) | ||
| 558 | [[image:1760518002883-747.png]] | ||
| 559 | |||
| 560 | |||
| 561 | **(2) 8-bit conversion mode (when SM161=ON)** | ||
| 562 | |||
| 563 | 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. | ||
| 564 | |||
| 565 | In the case of the following program, perform the conversion as shown below. | ||
| 566 | |||
| 567 | (% style="text-align:center" %) | ||
| 568 | [[image:1760518024863-940.png||height="154" width="494"]] | ||
| 569 | |||
| 570 | |||
| 571 | If SM161 is set to ON, it will become 8-bit mode, | ||
| 572 | |||
| 573 | Perform conversion processing as shown below. | ||
| 574 | |||
| 575 | (% style="text-align:center" %) | ||
| 576 | [[image:1760518128297-536.png]] | ||
| 577 | |||
| 578 | |||
| 579 | |**(n)**|(% rowspan="2" %)**K1**|(% rowspan="2" %)**K2**|(% rowspan="2" %)**K3**|(% rowspan="2" %)**K4**|(% rowspan="2" %)**K5**|(% rowspan="2" %)**K6**|(% rowspan="2" %)**K7**|(% rowspan="2" %)**K8**|(% rowspan="2" %)**K9** | ||
| 580 | |**(d)** | ||
| 581 | |D200|C|B|C|0|4|3|2|1|8 | ||
| 582 | |D201| |C|B|C|0|4|3|2|1 | ||
| 583 | |D202| | |C|B|C|0|4|3|2 | ||
| 584 | |D203| | | |C|B|C|0|4|3 | ||
| 585 | |D204| | | | |C|B|C|0|4 | ||
| 586 | |D205| |(% colspan="2" %)Unchanged| | |C|B|C|0 | ||
| 587 | |D206| | | | | | |C|B|C | ||
| 588 | |D207| | | | | | | |C|B | ||
| 589 | |D208| | | | | | | | |C | ||
| 590 | |||
| 591 | Bit structure in the case of (n)=K2 | ||
| 592 | |||
| 593 | (% style="text-align:center" %) | ||
| 594 | [[image:1760518162828-183.png]] | ||
| 595 | |||
| 596 | **Error code** | ||
| 597 | |||
| 598 | |**Error code**|**Content** | ||
| 599 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 600 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 601 | |4084H|When the value specified in (n) exceeds the range of 1 to 256 | ||
| 602 | |||
| 603 | **Example** | ||
| 604 | |||
| 605 | (% style="text-align:center" %) | ||
| 606 | [[image:1760518190168-651.png]] | ||
| 607 | |||
| 608 | |||
| 609 | • 16-bit conversion mode (when SM161=OFF) | ||
| 610 | |||
| 611 | 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. | ||
| 612 | |||
| 613 | === **HEX/ASCII → HEX Code Data Conversion** === | ||
| 614 | |||
| 615 | **HEX(P)** | ||
| 616 | |||
| 617 | 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. | ||
| 618 | |||
| 619 | -[HEX (s) (d) (n)] | ||
| 620 | |||
| 621 | **Content, range and data type** | ||
| 622 | |||
| 623 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 624 | |(s)|The start device that stores the ASCII data converted to HEX code|-|String|ANYSTRING_SINGLE | ||
| 625 | |(d)|The start device that stores converted HEX code|-|BIN16 bit|ANY16 | ||
| 626 | |(n)|Number of characters (bytes) of converted ASCII data|1 to 256|BIN16 bit|ANY16_U | ||
| 627 | |||
| 628 | **Device used** | ||
| 629 | |||
| 630 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 631 | **Index** | ||
| 632 | |||
| 633 | **modification** | ||
| 634 | )))|((( | ||
| 635 | **Pulse** | ||
| 636 | |||
| 637 | **extension** | ||
| 638 | ))) | ||
| 639 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 640 | |(% rowspan="3" %)HEX|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 641 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 642 | |Parameter 3| | | | | | | | | | | | | | | | |●|●|●| | |●|●| | |● | ||
| 643 | |||
| 644 | **Features** | ||
| 645 | |||
| 646 | • 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. | ||
| 647 | |||
| 648 | **(1) 16-bit conversion mode (when SM161=OFF)** | ||
| 649 | |||
| 650 | 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). | ||
| 651 | |||
| 652 | SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16-bit conversion mode, please always set SM161 to OFF. | ||
| 653 | |||
| 654 | SM161 is cleared when RUN→STOP. | ||
| 655 | |||
| 656 | 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). | ||
| 657 | |||
| 658 | In the following program, the conversion will be performed in the following manner. | ||
| 659 | |||
| 660 | (% style="text-align:center" %) | ||
| 661 | [[image:1760518243532-544.png||height="136" width="579"]] | ||
| 662 | |||
| 663 | |||
| 664 | Transform the source data | ||
| 665 | |||
| 666 | |**(s)**|**ASCII data**|**HEX conversion** | ||
| 667 | |Under D200|30H|0 | ||
| 668 | |D200 on|41H|A | ||
| 669 | |Under D201|42H|B | ||
| 670 | |D201 on|43H|C | ||
| 671 | |Under D202|31H|1 | ||
| 672 | |D202 on|32H|2 | ||
| 673 | |Under D203|33H|3 | ||
| 674 | |D203 on|34H|4 | ||
| 675 | |Under D204|35H|5 | ||
| 676 | |||
| 677 | Bit structure in the case of (n)=K4 | ||
| 678 | |||
| 679 | (% style="text-align:center" %) | ||
| 680 | [[image:1760518318672-792.png]] | ||
| 681 | |||
| 682 | The number of characters specified and the conversion result becomes 0. | ||
| 683 | |||
| 684 | |(% colspan="2" %)**(n)**|1|2|3|4|5|6|7|8|9 | ||
| 685 | |(% rowspan="3" %)**(d)**|**D102**|(% colspan="4" rowspan="2" %)Unchanged| | | | |...OH | ||
| 686 | |**D101**|...OH|..OAH|.OABH|OABCH|ABC1H | ||
| 687 | |**D100**|...OH|..OAH|.OABH|OABCH|ABC1H|BC12H|C123H|1234H|2345H | ||
| 688 | |||
| 689 | **(2) 8-bit conversion mode (when SM161=ON)** | ||
| 690 | |||
| 691 | 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. | ||
| 692 | |||
| 693 | The number of characters to be converted is specified in (n). | ||
| 694 | |||
| 695 | SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 8-bit conversion mode, please always turn on SM161. | ||
| 696 | |||
| 697 | SM161 is cleared when RUN→STOP. | ||
| 698 | |||
| 699 | In the following program, the conversion will be performed in the following manner. | ||
| 700 | |||
| 701 | (% style="text-align:center" %) | ||
| 702 | [[image:1760518359500-132.png]] | ||
| 703 | |||
| 704 | Transform the source data | ||
| 705 | |||
| 706 | |**(s)**|**ASCII data**|**HEX conversion** | ||
| 707 | |D200|30H|0 | ||
| 708 | |D201|41H|A | ||
| 709 | |D202|42H|B | ||
| 710 | |D203|43H|C | ||
| 711 | |D204|31H|1 | ||
| 712 | |D205|32H|2 | ||
| 713 | |D206|33H|3 | ||
| 714 | |D207|34H|4 | ||
| 715 | |D208|35H|5 | ||
| 716 | |||
| 717 | Bit structure in the case of (n)=K2 | ||
| 718 | |||
| 719 | (% style="text-align:center" %) | ||
| 720 | [[image:1760518380601-932.png]] | ||
| 721 | |||
| 722 | The number of characters specified and the conversion result becomes 0. | ||
| 723 | |||
| 724 | |(% colspan="2" %)**(n)**|1|2|3|4|5|6|7|8|9 | ||
| 725 | |(% rowspan="3" %)**(d)**|**D102**|(% colspan="4" rowspan="2" %)Unchanged| | | | |...OH | ||
| 726 | |**D101**|...OH|..OAH|.OABH|OABCH|ABC1H | ||
| 727 | |**D100**|...OH|..OAH|.OABH|OABCH|ABC1H|BC12H|C123H|1234H|2345H | ||
| 728 | |||
| 729 | **Error code** | ||
| 730 | |||
| 731 | |**Error code**|**Content** | ||
| 732 | |(% rowspan="2" %)4084H|When the value specified in (n) exceeds the range. | ||
| 733 | |When ASCII codes other than 30H to 39H and 41H to 46H are set in (s). | ||
| 734 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 735 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 736 | |||
| 737 | **Example** | ||
| 738 | |||
| 739 | (% style="text-align:center" %) | ||
| 740 | [[image:1760518408811-430.png||height="113" width="463"]] | ||
| 741 | |||
| 742 | |||
| 743 | 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). | ||
| 744 | |||
| 745 | SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16-bit conversion mode, please always set SM161 to OFF. | ||
| 746 | |||
| 747 | === **CCD/Check Code** === | ||
| 748 | |||
| 749 | **CCD(P)** | ||
| 750 | |||
| 751 | 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 | ||
| 752 | |||
| 753 | Redundancy Check). To calculate the CRC value, use the CRC(P) instruction. | ||
| 754 | |||
| 755 | -[CCD (s) (d) (n)] | ||
| 756 | |||
| 757 | **Content, range and data type** | ||
| 758 | |||
| 759 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 760 | |(s)|The start number of object device|-|BIN16 bit|ANY16 | ||
| 761 | |(d)|The start number of the storage destination device of the calculated data|-|BIN16 bit|ANY16_ARRAY (number of elements: 2) | ||
| 762 | |(n)|Number of data|1 to 256|BIN16 bit|ANY16_U | ||
| 763 | |||
| 764 | **Device used** | ||
| 765 | |||
| 766 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 767 | **Index** | ||
| 768 | |||
| 769 | **modification** | ||
| 770 | )))|((( | ||
| 771 | **Pulse** | ||
| 772 | |||
| 773 | **extension** | ||
| 774 | ))) | ||
| 775 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 776 | |(% rowspan="3" %)CCD|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 777 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 778 | |Parameter 3| | | | | | | | | | | | | | | | |●|●|●| | |●|●| | |● | ||
| 779 | |||
| 780 | **Features** | ||
| 781 | |||
| 782 | 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 | ||
| 783 | |||
| 784 | 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. | ||
| 785 | |||
| 786 | **(1) 16-bit conversion mode (when SM161=OFF)** | ||
| 787 | |||
| 788 | 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. | ||
| 789 | |||
| 790 | SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16 bits, always set to OFF for use. | ||
| 791 | |||
| 792 | SM161 is cleared when RUN→STOP. | ||
| 793 | |||
| 794 | In the case of the following program, perform the conversion as shown below. | ||
| 795 | |||
| 796 | (% style="text-align:center" %) | ||
| 797 | [[image:1760518549836-396.png]] | ||
| 798 | |||
| 799 | |||
| 800 | (% style="text-align:center" %) | ||
| 801 | [[image:1760518595510-661.png]] | ||
| 802 | |||
| 803 | **(2) 8-bit conversion mode (when SM161=ON)** | ||
| 804 | |||
| 805 | 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. | ||
| 806 | |||
| 807 | 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. | ||
| 808 | |||
| 809 | SM161 is cleared when RUN→STOP. | ||
| 810 | |||
| 811 | In the case of the following program, perform the conversion as shown below. | ||
| 812 | |||
| 813 | (% style="text-align:center" %) | ||
| 814 | [[image:1760518650396-504.png]] | ||
| 815 | |||
| 816 | (% style="text-align:center" %) | ||
| 817 | [[image:1760518681791-265.png]] | ||
| 818 | |||
| 819 | **Error code** | ||
| 820 | |||
| 821 | |**Error code**|**Content** | ||
| 822 | |4084H|When the value specified in (n) exceed the range of 1 to 256. | ||
| 823 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 824 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 825 | |||
| 826 | **Example** | ||
| 827 | |||
| 828 | (% style="text-align:center" %) | ||
| 829 | [[image:1760518721394-977.png]] | ||
| 830 | |||
| 831 | |||
| 832 | 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. | ||
| 833 | |||
| 834 | SM161 is shared with ASC, ASCI, BCC, CCD and CRC instructions. When using in 16 bits, always set to OFF for use. | ||
| 835 | |||
| 836 | === **GBIN/Gray code → BIN 16-bit Data Conversion** === | ||
| 837 | |||
| 838 | **GBIN(P)** | ||
| 839 | |||
| 840 | 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). | ||
| 841 | |||
| 842 | -[GBIN (s) (d)] | ||
| 843 | |||
| 844 | **Content, range and data type** | ||
| 845 | |||
| 846 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 847 | |(s)|Gray code data or the start device that stores Gray code|0 to 32767|BIN16 bit|ANY16_S | ||
| 848 | |(d)|The start device that stores the converted BIN data|-|BIN16 bit|ANY16_S | ||
| 849 | |||
| 850 | **Device used** | ||
| 851 | |||
| 852 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 853 | **Index** | ||
| 854 | |||
| 855 | **modification** | ||
| 856 | )))|((( | ||
| 857 | **Pulse** | ||
| 858 | |||
| 859 | **extension** | ||
| 860 | ))) | ||
| 861 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 862 | |(% rowspan="2" %)GBIN|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 863 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 864 | |||
| 865 | **Features** | ||
| 866 | |||
| 867 | 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). | ||
| 868 | |||
| 869 | (% style="text-align:center" %) | ||
| 870 | [[image:1760518798409-907.png]] | ||
| 871 | |||
| 872 | 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). | ||
| 873 | |||
| 874 | **Error code** | ||
| 875 | |||
| 876 | |**Error code**|**Content** | ||
| 877 | |4084H|When the value specified in (s) exceeds the range | ||
| 878 | |4085H|When the specified device range is read to exceed the range of the corresponding device | ||
| 879 | |4086H|When the specified device range is written to exceed the range of the corresponding device | ||
| 880 | |||
| 881 | **Example** | ||
| 882 | |||
| 883 | (% style="text-align:center" %) | ||
| 884 | [[image:1760518822792-557.png]] | ||
| 885 | |||
| 886 | |||
| 887 | It could be used when the encoder of Gray code method is used to detect the absolute position. | ||
| 888 | |||
| 889 | For S, the numerical are valid in the range of 0 to 32767. | ||
| 890 | |||
| 891 | === **DGBIN/Gray Code → BIN32-bit Data Conversion** === | ||
| 892 | |||
| 893 | **DGBIN(P)** | ||
| 894 | |||
| 895 | 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). | ||
| 896 | |||
| 897 | **Content, range and data type** | ||
| 898 | |||
| 899 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 900 | |(s)|Gray code data or the start device that stores Gray code|0 to 2147483647|BIN32 bit|ANY32_S | ||
| 901 | |(d)|The start device that stores converted BIN data|-|BIN32 bit|ANY32_S | ||
| 902 | |||
| 903 | **Device used** | ||
| 904 | |||
| 905 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 906 | **Index** | ||
| 907 | |||
| 908 | **modification** | ||
| 909 | )))|((( | ||
| 910 | **Pulse** | ||
| 911 | |||
| 912 | **extension** | ||
| 913 | ))) | ||
| 914 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 915 | |(% rowspan="2" %)DGBIN|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●|●|●|●|●| |●|● | ||
| 916 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●|●|●| | | |●|● | ||
| 917 | |||
| 918 | **Features** | ||
| 919 | |||
| 920 | 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). | ||
| 921 | |||
| 922 | (% style="text-align:center" %) | ||
| 923 | [[image:1760518892993-298.png]] | ||
| 924 | |||
| 925 | (s)+1: high 16 bits | ||
| 926 | |||
| 927 | (s): low 16 bits | ||
| 928 | |||
| 929 | 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). | ||
| 930 | |||
| 931 | **Error code** | ||
| 932 | |||
| 933 | |**Error code**|**Content** | ||
| 934 | |4084H|When the value specified in (s) exceeds the range | ||
| 935 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 936 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 937 | |||
| 938 | **Example** | ||
| 939 | |||
| 940 | (% style="text-align:center" %) | ||
| 941 | [[image:1760518916894-252.png]] | ||
| 942 | |||
| 943 | === **GRY/BIN 16-bit Data → Gray Code Conversion** === | ||
| 944 | |||
| 945 | **GRY(P)** | ||
| 946 | |||
| 947 | 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). | ||
| 948 | |||
| 949 | -[GRY (s) (d)] | ||
| 950 | |||
| 951 | **Content, range and data type** | ||
| 952 | |||
| 953 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 954 | |(s)|BIN data or the start device that stores BIN data|0 to 32767|BIN16 bit|ANY16_S | ||
| 955 | |(d)|The start device that stores the converted Gray code|-|BIN16 bit|ANY16_S | ||
| 956 | |||
| 957 | **Device used** | ||
| 958 | |||
| 959 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 960 | **Index** | ||
| 961 | |||
| 962 | **modification** | ||
| 963 | )))|((( | ||
| 964 | **Pulse** | ||
| 965 | |||
| 966 | **extension** | ||
| 967 | ))) | ||
| 968 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 969 | |(% rowspan="2" %)GRY|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 970 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|● | ||
| 971 | |||
| 972 | **Features** | ||
| 973 | |||
| 974 | Convert the BIN 16-bit data specified in (s) into BIN 16-bit Gray code, and store it in the device specified in (d). | ||
| 975 | |||
| 976 | [[image:1760518963231-603.png]] | ||
| 977 | |||
| 978 | 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) . | ||
| 979 | |||
| 980 | **Error code** | ||
| 981 | |||
| 982 | |**Error code**|**Content** | ||
| 983 | |4084H|When the value specified in (s) exceeds the range | ||
| 984 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 985 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 986 | |||
| 987 | **Example** | ||
| 988 | |||
| 989 | (% style="text-align:center" %) | ||
| 990 | [[image:1760519299493-121.png||height="63" width="442"]] | ||
| 991 | |||
| 992 | |||
| 993 | As shown in the above ladder diagram: | ||
| 994 | |||
| 995 | (% style="text-align:center" %) | ||
| 996 | [[image:1760519319104-654.png]] | ||
| 997 | |||
| 998 | |||
| 999 | For S, the range of 0 to 32767 is valid. | ||
| 1000 | |||
| 1001 | === **DGRY/BIN 32-bit Data → Gray Code Conversion** === | ||
| 1002 | |||
| 1003 | **DGRY(P)** | ||
| 1004 | |||
| 1005 | 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). | ||
| 1006 | |||
| 1007 | -[GRY (s) (d)] | ||
| 1008 | |||
| 1009 | **Content, range and data type** | ||
| 1010 | |||
| 1011 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 1012 | |(s)|BIN data or the start device that stores BIN data|0 to 2147483647|BIN32 bit|ANY32_S | ||
| 1013 | |(d)|The start device that stores the converted Gray code|-|BIN32 bit|ANY32_S | ||
| 1014 | |||
| 1015 | **Device used** | ||
| 1016 | |||
| 1017 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 1018 | **Index** | ||
| 1019 | |||
| 1020 | **modification** | ||
| 1021 | )))|((( | ||
| 1022 | **Pulse** | ||
| 1023 | |||
| 1024 | **extension** | ||
| 1025 | ))) | ||
| 1026 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1027 | |(% rowspan="2" %)DGRY|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●|●|●|●|●| |●|● | ||
| 1028 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●|●|●| | | |●|● | ||
| 1029 | |||
| 1030 | **Features** | ||
| 1031 | |||
| 1032 | Convert the BIN32-bit data specified in (s) into BIN32-bit Gray code and store it in the device specified in (d) | ||
| 1033 | |||
| 1034 | (% style="text-align:center" %) | ||
| 1035 | [[image:1760519357374-958.png]] | ||
| 1036 | |||
| 1037 | (s)+1: high 16 bits | ||
| 1038 | |||
| 1039 | (s): low 16 bits | ||
| 1040 | |||
| 1041 | 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) . | ||
| 1042 | |||
| 1043 | **Error code** | ||
| 1044 | |||
| 1045 | |**Error code**|**Content** | ||
| 1046 | |4084H|When the value specified in (s) exceeds the range | ||
| 1047 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 1048 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 1049 | |||
| 1050 | **Example** | ||
| 1051 | |||
| 1052 | (% style="text-align:center" %) | ||
| 1053 | [[image:1760519378928-755.png]] | ||
| 1054 | |||
| 1055 | As shown in the above ladder diagram: | ||
| 1056 | |||
| 1057 | (% style="text-align:center" %) | ||
| 1058 | [[image:1760519409066-947.png]] | ||
| 1059 | |||
| 1060 | === **PRUN/Octal digit transmission (16-bit data)** === | ||
| 1061 | |||
| 1062 | PRUN(P) | ||
| 1063 | |||
| 1064 | After processing the device numbers of (s) and (d) with specified digits as octal numbers, transfer the data. | ||
| 1065 | |||
| 1066 | -[PRUN (s) (d)] | ||
| 1067 | |||
| 1068 | **Content, range and data type** | ||
| 1069 | |||
| 1070 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**|**Custom variable type** | ||
| 1071 | |(s)|Digit specification*1|-|BIN16 bit|ANY16|~-~- | ||
| 1072 | |(d)|Transfer target device number*1|-|BIN16 bit|ANY16|~-~- | ||
| 1073 | |||
| 1074 | **Device used** | ||
| 1075 | |||
| 1076 | |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|**Pulse expansion** | ||
| 1077 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1078 | |(% rowspan="2" %)PRUN|Parameter 1| | | | | | | | | | |●| |●| | | | | | | | | | | |●|● | ||
| 1079 | |Parameter 2| | | | | | | | | | | |●|●| | | | | | | | | | | |●|● | ||
| 1080 | |||
| 1081 | **Function** | ||
| 1082 | |||
| 1083 | • Octal digit device→ decimal digit device | ||
| 1084 | |||
| 1085 | (% style="text-align:center" %) | ||
| 1086 | [[image:1760519463939-108.png]] | ||
| 1087 | |||
| 1088 | • Decimal digit device → octal digit device | ||
| 1089 | |||
| 1090 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps206.jpg]] | ||
| 1091 | |||
| 1092 | **Error code** | ||
| 1093 | |||
| 1094 | |**Error code**|**Content** | ||
| 1095 | |4085H|When the specified device range for reading exceeds the range of the corresponding device | ||
| 1096 | |4086H|When the specified device range for writing exceeds the range of the corresponding device | ||
| 1097 | |||
| 1098 | **Example** | ||
| 1099 | |||
| 1100 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps207.jpg]] | ||
| 1101 | |||
| 1102 | As shown in the above ladder diagram: X0~~X17 takes the value of octal digits and pass it to the devices corresponding to M. | ||
| 1103 | |||
| 1104 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps208.jpg]] | ||
| 1105 | |||
| 1106 | === | ||
| 1107 | **6.8.**[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps209.png]]**16 DPRUN/Otal Digit Transmission (32-bit data)** === | ||
| 1108 | |||
| 1109 | **DPRUN(P)** | ||
| 1110 | |||
| 1111 | After processing the device numbers of (s) and (d) with specified digits as octal numbers, transfer the data. | ||
| 1112 | |||
| 1113 | -[PRUN (s) (d)] | ||
| 1114 | |||
| 1115 | **Content, range and data type** | ||
| 1116 | |||
| 1117 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)** | ||
| 1118 | |(s)|Digit specification*1|-|BIN32 bit|ANY32 | ||
| 1119 | |(d)|Transfer destination device number*1|-|BIN32 bit|ANY32 | ||
| 1120 | |||
| 1121 | **Device used** | ||
| 1122 | |||
| 1123 | |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|((( | ||
| 1124 | **Index** | ||
| 1125 | |||
| 1126 | **modification** | ||
| 1127 | )))|((( | ||
| 1128 | **Pulse** | ||
| 1129 | |||
| 1130 | **extension** | ||
| 1131 | ))) | ||
| 1132 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1133 | |(% rowspan="2" %)DPRUN|Parameter 1| | | | | | | | | | |●| |●| | | | | | | | | | | |●|● | ||
| 1134 | |Parameter 2| | | | | | | | | | | |●|●| | | | | | | | | | | |●|● | ||
| 1135 | |||
| 1136 | **Features** | ||
| 1137 | |||
| 1138 | • Octal digit device to decimal digit device | ||
| 1139 | |||
| 1140 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps210.jpg]] | ||
| 1141 | |||
| 1142 | • Decimal digit device → octal digit device | ||
| 1143 | |||
| 1144 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps211.jpg]] | ||
| 1145 | |||
| 1146 | **Error code** | ||
| 1147 | |||
| 1148 | |**Error code**|**Content** | ||
| 1149 | |4085H|When the specified device range is read to exceed the corresponding device range | ||
| 1150 | |4086H|When the specified device range is written to exceed the corresponding device range | ||
| 1151 | |||
| 1152 | **Example** | ||
| 1153 | |||
| 1154 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml13456\wps212.jpg]] | ||
| 1155 | |||
| 1156 | As shown in the above ladder diagram: | ||
| 1157 | |||
| 1158 | X0 to X27 take the value of octal digits and pass them to the Devices corresponding to M. |