Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 46 of 61

DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 433 to 442

Pages 433 to 442 of 592, from DL205 PLC User Manual, Volume 1 of 2

The original document is the PDF (13 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the PLC Direct D2-08ND3 and Koyo D2-08ND3

Page 433

Chapter 5: Standard RLL Instructions - ASCII

ASCII Instructions (DL260)

1

2

3 4 Reading ASCII Input Strings 5 There are several methods which the DL260 can use to read ASCII input strings: 1) ASCII IN (AIN) – This instruction configures port 2 for raw ASCII input strings with parameters such as fixed and variable length ASCII strings, termination characters, byte swapping options, and 6 instruction control bits. Use barcode scanners, weight scales, etc. to write raw ASCII input strings into port 2 based on the (AIN) instruction’s parameters. 7 2) Write embedded ASCII strings directly to V–memory from an external HMI or similar master device via a supported communications protocol using the CPU ports, H2–ECOM or D2–DCM. The AIN instruction is not used in this case. 8 3) If a DL260 PLC is a master on a network, the Network Read instruction (RX) can be used to read embedded ASCII data from a slave device via a supported communications protocol using port 2, 9 H2–ECOM or D2–DCM. The RX instruction places the data directly into V–memory. Writing ASCII Output Strings 10 The following instructions can be used to write ASCII output strings: 1) Print from V–memory (PRINTV) – Use this instruction to write raw ASCII strings out of port 2 11 to a display panel or a serial printer, etc. The instruction features the starting V–memory address, string length, byte swapping options, etc. When the instruction’s permissive bit is enabled, the string is written to port 2. 12 2) Print to V–memory (VPRINT) – Use this instruction to create pre–coded ASCII strings in the PLC (i.e. alarm messages). When the instruction’s permissive bit is enabled, the message is loaded 13 into a pre–defined V–memory address location. Then use the PRINTV instruction to write the pre–coded ASCII string out of port 2. American, European and Asian Time/Date stamps are supported. 14 Additionally, if a DL260 PLC is a master on a network, the Network Write instruction (WX) A can be used to write embedded ASCII data to an HMI or slave device directly from V–memory via a supported communications protocol using port 2, H2–ECOM or B D2–DCM. C D 230 240

250-1 260

DS Used HPP N/A

The DL260 CPU supports several instructions and methods that allow ASCII strings to be read into and written from the PLC communications ports. Specifically, port 2 on the DL260 can be used for either reading or writing raw ASCII strings, but cannot be used for both on the same CPU. The DL260 can also decipher ASCII embedded within a supported protocol (K–Sequence, DirectNET, Modbus, Ethernet) via the CPU ports, H2–ECOM or D2–DCM module. ASCII character tables and descriptions can be found at www.asciitable.com.

DL205 User Manual, 4th Edition, Rev. A

5–211

Page 434

Chapter 5: Standard RLL Instructions - ASCII

Managing the ASCII Strings

The following instructions can be helpful in managing the ASCII strings within the CPUs 1 V-memory: ASCII Find (AFIND) – Finds where a specific portion of the ASCII string is located in 2 continuous V-memory addresses. Forward and reverse searches are supported. ASCII Extract (AEX) – Extracts a specific portion (usually some data value) from the ASCII 3 find location or other known ASCII data location. Compare V-memory (CMPV) – This instruction is used to compare two blocks of 4 V-memory addresses and is usually used to detect a change in an ASCII string. Compared data types must be of the same format (i.e. BCD, ASCII, etc.). 5 Swap Bytes (SWAPB) – usually used to swap V-memory bytes on ASCII data that was written directly to V-memory from an external HMI or similar master device via a communications protocol. The AIN and AEX instructions have a built–in byte swap feature. 6 7 ASCII Input (AIN) The ASCII Input instruction allows the CPU to receive ASCII strings through the specified communications port and places the string into a series of specified V-memory registers. The

8 ASCII data can be received as a fixed number of bytes or as a variable length string with a specified termination character(s). Other features include, Byte Swap preferences, Character 9 Timeout, and user defined flag bits for Busy, Complete and Timeout Error.

10 11 12 13 14 A B C D 230 240

250-1 260

DS Used HPP N/A

5–212

DL205 User Manual, 4th Edition, Rev. A

Page 435

Chapter 5: Standard RLL Instructions - ASCII AIN Fixed Length Configuration

1 • Port Number: must be DL260 port 2 (K2) 2 • Data Destination: specifies where the ASCII string will be placed in V–memory • Fixed Length: specifies the length, in bytes, of the fixed length ASCII string the port will receive 3 • Inter–character Timeout: if the amount of time between incoming ASCII characters exceeds the set time, the specified Timeout Error bit will be set. No data will be stored at the Data Destination V–memory location. The bit will reset when the AIN instruction permissive bits are disabled. None 4 selection disables this feature. • First Character Timeout: if the amount of time from when the AIN is enabled to the time the first 5 character is received exceeds the set time, the specified First Character Timeout bit will be set. The bit will reset when the AIN instruction permissive bits are disabled. None selection disables this feature. 6 • Byte Swap: swaps the high–byte and low–byte within each V–memory register of the Fixed Length ASCII string. See the SWAPB instruction for details. 7 • Busy Bit: is ON while the AIN instruction is receiving ASCII data • Complete Bit: is set once the ASCII data has been received for the specified fixed length and reset 8 when the AIN instruction permissive bits are disabled. • Inter–character Timeout Error Bit: is set when the Character Timeout is exceed. See Character 9 Timeout explanation above. • First Character Timeout Error Bit: is set when the First Character Timeout is exceed. See First Character Timeout explanation above. 10 11 Parameter DL260 Range 12 13 Discrete Bit Flags Description 14 A B C D • Length Type: select fixed length based on the length of the ASCII string that will be sent to the CPU port

Data Destination Fixed Length Bits: Busy, Complete, Timeout Error, Overflow

SP53 SP71 SP116 SP117

All V-memory (See page 3 - 56) K1-128 C0-3777

On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid. On when CPU port 2 is communicating with another device. On when CPU port 2 has experienced a communication error.

DL205 User Manual, 4th Edition, Rev. A

5–213

Page 436

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–214

AIN Fixed Length Examples Fixed Length example when the PLC is reading the port continuously and timing is not critical

Fixed Length example when character to character timing is critical

DL205 User Manual, 4th Edition, Rev. A

Page 437

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 AIN Variable Length Configuration: 7 • Length Type: select Variable Length if the ASCII string length followed by termination characters will vary in length 8 • Port Number: must be DL260 port 2 (K2) • Data Destination: specifies where the ASCII string will be placed in V–memory 9 • Maximum Variable Length: specifies, in bytes, the maximum length of a Variable Length ASCII string the port will receive • Inter–character Timeout: if the amount of time between incoming ASCII characters exceeds the set 10 time, the Timeout Error bit will be set. No data will be stored at the Data Destination V–memory location. The Timeout Error bit will reset when the AIN instruction permissive bits are disabled. 11 None selection disables this feature. • First Character Timeout: if the amount of time from when the AIN is enabled to the time the first 12 character is received exceeds the set time, the specified First Character Timeout bit will be set. The bit will reset when the AIN instruction permissive bits are disabled. None selection disables this feature. 13 • Byte Swap: swaps the high–byte and low–byte within each V–memory register of the Varaible Length ASCII string. See the SWAPB instruction for details. 14 • Termination Code Length: consists of either 1 or 2 characters. Refer to the ASCII table in Appendix G. A • Overflow Error Bit: is set when the ASCII data received exceeds the Maximum Variable Length specified. • Busy Bit: is ON while the AIN instruction is receiving ASCII data B • Complete Bit: is set once the ASCII data has been received up to the termination code characters. It will be reset when the AIN instruction permissive bits are disabled. C • Inter–character Timeout Error Bit: is set when the Character Timeout is exceed. See Character Timeout explanation above. D • First Character Timeout Error Bit: is set when the First Character Timeout is exceed. See First Character Timeout explanation above.

DL205 User Manual, 4th Edition, Rev. A

5–215

Page 438

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–216

Parameter Data Destination Max. Variable Length Bits: Busy, Complete, Timeout Error, Overflow

DL260 Range All V-memory (See page 3 - 56) K1-128 C0-3777

AIN Variable Length Example AIN Variable Length example used to read barcodes on boxes (PE = photoelectric sensor).

DL205 User Manual, 4th Edition, Rev. A

Page 439

Chapter 5: Standard RLL Instructions - ASCII

ASCII Find (AFIND)

1 2 3 • Base Address: specifies the begining V-memory register where the entire ASCII string is stored in memory 4 • Total Number of Bytes: specifies the total number of bytes to search for the desired ASCII string • Search Starting Index: specifies which byte to skip to (with respect to the Base Address) before 5 begining the search • Direction: Forward begins the search from lower numbered V-memory registers to higher 6 numbered V-memory registers. Reverse does the search from higher numbered V–memory registers to lower numbered V-memory registers. • Found Index Value: specifies whether the Begining or the End byte of the ASCII string found will 7 be loaded into the Found Index register • Found Index: specifies the V–memory register where the Found Index Value will be stored. A value 8 of FFFF will result if the desired string is not located in the memory registers specified. A value of EEEE will result if there is a conflict in the AFIND search parameters specified. 9 • Search for String: up to 128 characters. 10 Parameter DL260 Range 11 12 13 14 A B C Discrete Bit Flags Description D

The ASCII Find instruction locates a specific ASCII string or portion of an ASCII string

230 within a range of V-memory registers and places the string’s Found Index number (byte 240 number where desired string is found), in Hex, into a specified V-memory register. Other 250-1 features include, Search Starting Index number for skipping over unnecessary bytes before the FIND operation, Forward or Reverse direction search, and From Begining and 260 beginning From End selections to reference the Found Index Value. DS Used HPP N/A

Base Address

All V-memory (See page 3 - 56)

Total Number of Bytes

All V-memory (See page 3 - 56) or K1-128

Search Starting Index

All V-memory (See page 3 - 56) or K0-127

Found Index

All V-memory (See page 3 - 56)

SP53 SP71

On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid.

DL205 User Manual, 4th Edition, Rev. A

5–217

Page 440

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

AFIND Search Example In the following example, the AFIND instruction is used to search for the “day” portion of “Friday” in the ASCII string “Today is Friday.”, which had previously been loaded into V–memory. Note that a Search Starting Index of constant (K) 5 combined with a Forward Direction Seach is used to prevent finding the “day” portion of the word “Today”. The Found Index will be placed into V4000.

ASCII Characters HEX Equivalent Base Address 0 1 Reverse Direction Search 2 3 4 Search start Index Number 5 6 7 8 Forward Direction Search 9 10 11 Beginning Index Number 12 13 End Index Number 14 15

Found Index Number =

5–218

DL205 User Manual, 4th Edition, Rev. A

T o d a y i s F r i d a y .

54h 6Fh 64h 61h 79h 20h 69h 73h 20h 46h 72h 69h 64h 61h 79h 2Eh

Low High Low High Low High Low High Low High Low High Low High Low High

0012

V3000 V3001 V3002 V3003 V3004 V3005 V3006 V3007

V4000

Page 441

Chapter 5: Standard RLL Instructions - ASCII

AFIND Example Combined with AEX Instruction When an AIN instruction has executed, its’ Complete bit can be used to trigger an AFIND instruction to search for a desired portion of the ASCII string. Once the string is found, the AEX instruction can be used to extract the located string.

DL205 User Manual, 4th Edition, Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–219

Page 442

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

ASCII Extract (AEX)

230 240 250-1 260

The ASCII Extract instruction extracts a specified number of bytes of ASCII data from one series of V-memory registers and places it into another series of V-memory registers. Other features include, Extract at Index for skipping over unnecessary bytes before begining the Extract operation, Shift ASCII Option, for One Byte Left or One Byte Right, Byte Swap and Convert data to a BCD format number.

DS Used HPP N/A

• Source Base Address: specifies the begining V-memory register where the entire ASCII string is stored in memory • Extract at Index: specifies which byte to skip to (with respect to the Source Base Address) before extracting the data • Number of Bytes: specifies the number of bytes to be extracted • Shift ASCII Option: shifts all extracted data one byte left or one byte right to displace “unwanted” characters if necessary • Byte Swap: swaps the high–byte and the low–byte within each V-memory register of the extracted data. See the SWAPB instruction for details. • Convert BCD(Hex) ASCII to BCD (Hex): if enabled, this will convert ASCII numerical characters to Hexidecimal numerical values • Destination Base Address: specifies the V-memory register where the extracted data will be stored

Parameter Source Base Address Extract at Index Number of Bytes Destination Base Address

Discrete Bit Flags SP53 SP71

5–220

DL260 Range All V-memory (See page 3 - 56) All V-memory (See page 3 - 56) or K0-127 K1-128 All V-memory (See page 3 - 56)

Description On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid.

See the previous page for an example using the AEX instruction.

DL205 User Manual, 4th Edition, Rev. A