The text of a manual · part 45 of 60
DL205 PLC User Manual, Volume 1 of 2, pages 441 to 450
Pages 441 to 450 of 598
The original document is the PDF (12 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 AutomationDirect D2-04TD1, AutomationDirect D2-08TD2, AutomationDirect D2-16ND3-2, AutomationDirect D2-32ND3, Konnect-It D2-04TD1, Koyo D2-04TD1, Konnect-It D2-08TD2, Koyo D2-08TD2, and 5 more models
Page 441
Chapter 5: Standard RLL Instructions
ASCII Find (AFIND)
230 a range of V-memory registers and places the string’s Found Index number (byte number where 1 240 desired string is found) in Hex, into a specified V-memory register. Other features include, 250-1 Search Starting Index number for skipping over unnecessary bytes before beginning the FIND 2 260 operation, Forward or Reverse direction search, and From Beginning and From End selections The ASCII Find instruction locates a specific ASCII string or portion of an ASCII string within to reference the Found Index Value.
DS Used HPP N/A
•B ase Address: specifies the beginning V-memory register where the entire ASCII string is stored in memory. • Number of Bytes: specifies the total number of bytes to search for the desired ASCII string. • Starting Index: specifies which byte to skip to (with respect to the Base Address) before beginning the search. • Forward begins the search from lower numbered V-memory registers to higher numbered V-memory registers. Reverse does the search from higher numbered V–memory registers to lowernumbered V-memory registers. • Index Value: specifies whether the Beginning or the End byte of the ASCII string found will be loaded into the Found Index register. • Index: specifies the V–memory register where the Found Index Value will be stored. A value 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. • for String: up to 128 characters.
Parameter
DL260 Range
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)
Discrete Bit Flags SP53 SP71
Description On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid.
DL205 User Manual, 4th Edition, Rev. D
3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-217
Page 442
Chapter 5: Standard RLL Instructions
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 Search 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. D
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 443
Chapter 5: Standard RLL Instructions
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. D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-219
Page 444
Chapter 5: Standard RLL Instructions
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
DS Used HPP N/A
5-220
The ASCII Extract instruction extracts a specified number of bytes of ASCII data from one series of V-memory registers and places them 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. • Base Address: specifies the beginning V-memory register where the entire ASCII string is stored in memory. • at Index: specifies which byte to skip to (with respect to the Source Base Address) before extracting the data. • of Bytes: specifies the number of bytes to be extracted. • ASCII Option: shifts all extracted data one byte left or one byte right to displace “unwanted” characters, if necessary. • Swap: swaps the high–byte and the low– byte within each V-memory register of the extracted data. See the SWAPB instruction for details. • BCD(Hex) ASCII to BCD (Hex): if enabled, this will convert ASCII numerical characters to Hexadecimal numerical values. • Base Address: specifies the V-memory register where the extracted data will be stored.
Parameter
DL260 Range
Source Base Address Extract at Index
All V-memory (See page 3-56) All V-memory (See page 3-56) or K0-127
Number of Bytes Destination Base Address
K1-128 All V-memory (See page 3-56)
See the previous page for an example using the AEX instruction. Discrete Bit Flags SP53 SP71
Description On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid.
DL205 User Manual, 4th Edition, Rev. D
Page 445
Chapter 5: Standard RLL Instructions
ASCII Compare (CMPV)
ASCII Compare instruction compares two groups of V–memory registers. The CMPV 230 The will compare any data type (ASCII to ASCII, BCD to BCD, etc) of one series (group) of 1 240 V–memory registers to another series of V–memory registers for a specified byte length. 250-1 “Compare from” Starting Address: 2 260 specifies the beginning V–memory
3 4 5 6 SP61 = 1 (ON), the result is equal 7 SP61 = 0 (OFF), the result is not equal Parameter DL260 Range 8 9 10 Discrete Bit Flags Description 11 12 CMPV Example 13 The CMPV instruction executes when the AIN instruction is complete. If the compared V–memory tables are equal, SP61 will turn ON. 14 A B C D
DS Used HPP N/A register of the first group of V–memory registers to be compared from. “Compare to” Starting Address: specifies the beginning V–memory register of the second group of V–memory registers to be compared to. Number of Bytes: specifies the length of each V–memory group to be compared.
Compare from Starting Address Compare to Starting Address Number of Bytes
SP53 SP61 SP71
All V-memory (See page 3-56) All V-memory (See page 3-56)
All V-memory (See page 3-56) or K0-127
On if the CPU cannot execute the instruction. On when result is equal. On when a value used by the instruction is invalid.
AIN Complete C1
CMPV
"Compare from" Starting Address: V3400 "Compare to" Starting Address: V3500 Number of Bytes: K12
SP61
Strings are equal C11 OUT
DL205 User Manual, 4th Edition, Rev. D
5-221
Page 446
Chapter 5: Standard RLL Instructions
ASCII Print to V-memory (VPRINT)
ASCII Print to V–memory instruction will write a specified ASCII string into a series of 1 The V–memory registers. Other features include Byte Swap, options to suppress or convert leading zeros or spaces, and _Date and _Time options for U.S., European, and Asian date formats and
2 12- or 24-hour time formats. • Swap: swaps the high–byte and low–byte within each V–memory register to which 3 the ASCII string is printed. See the SWAPB instruction for details. 4 • to Starting V–memory Address: specifies the beginning of a series of V– memory addresses where the ASCII string will 5 be placed by the VPRINT instruction. • V–memory Address: the first V– 6 memory register of the series of registers specified will contain the ASCII string’s length in bytes. 7 • V–memory Address +1: the 2nd and subsequent registers will contain the ASCII 8 string printed to V–memory. 9 VPRINT Time/Date Stamping 10 Parameter DL260 Range 11 Discrete Bit Flags Description 12 13 The codes in the table below can be used in the VPRINT ASCII string message to “print to V–memory” the current time and/or date. 14 # Character Code Date/Time Stamp Options A B C D 230 240
250-1 260
DS Used HPP N/A
Print to Starting V-memory Address
SP53 SP71
1 2 3 4 5
5-222
All V-memory (See page 3-56)
On if the CPU cannot execute the instruction. On when a value used by the instruction is invalid.
_Date:us _Date:e _Date:a _Time:12 _Time:24
American standard (month/day/2 digit year) European standard (day/month/2 digit year) Asian standard (2 digit year/month/day) standard 12 hour clock (0-12 hour:min am/pm) standard 24 hour clock (0-23 hour:min am/pm)
DL205 User Manual, 4th Edition, Rev. D
Page 447
Chapter 5: Standard RLL Instructions
VPRINT V-memory element
1 2 NOTE: There must be a space entered before and after the V-memory address to separate it from the text 3 string. Failure to do this will result in error code 499. # Character Code Description 4 5 6 7 Examples: V2000 Print binary data in V2000 for decimal number 8 V2000 : B Print BCD data in V2000 V2000 : D Print binary number in V2000 and V2001 for decimal number 9 V2000 : D B Print BCD data in V2000 and V2001 V2000 : R Print floating point number in V2000/V2001 as real number 10 V2000 : E Print floating point number in V2000/V2001 as real number with exponent The following modifiers can be added to any of the modifies above to suppress or convert 11 leading zeros or spaces. The character code must be capital letters. 12 # Character Code Description 13 14 Example with V2000 = 0018 (binary format) Number of Characters A V-memory Register with Modifier 1 2 3 4 B C D The following modifiers can be used in the VPRINT ASCII string message to “print to V–memory” register contents in integer format or real format. Use V-memory number or V-memory number with “:” and data type. The data types are shown in the table below. The Character code must be capital letters.
1 2 3 4 5 6 none :B :D :DB :R :E
16-bit binary (decimal number) 4-digit BCD 32-bit binary (decimal number) 8-digit BCD Floating point number (real number) Floating point number (real number with exponent)
1 2 3
S C0 0
Suppresses leading spaces Converts leading spaces to zeros Suppresses leading zeros
V2000 V2000:B V2000:B0
0 0 1
0 0 2
1 1
8 2
DL205 User Manual, 4th Edition, Rev. D
5-223
Page 448
Chapter 5: Standard RLL Instructions Example with V2000 = sp sp18 (binary format) where sp = space
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-224
V-memory Register with Modifier V2000 V2000:B V2000:BS V2000:BC0
1
Number of Characters 2 3 sp sp 1 0 sp sp 2 0
4
1 1
8 2
1
2
VPRINT V-memory text element The following is used for “printing to V-memory” text stored in registers. Use the % followed by the number of characters after V-memory number for representing the text. If you assign “0” as the number of characters, the function will read the character count from the first location. Then it will start at the next V-memory location and read that number of ASCII codes for the text from memory. Example: V2000 % 16 16 characters in V2000 to V2007 are printed. V2000 % 0 The characters in V2001 to Vxxxx (determined by the number in
V2000) will be printed.
VPRINT Bit element The following is used for “printing to V–memory” the state of the designated bit in V-memory or a control relay bit. The bit element can be assigned by the designating point (.) and bit number preceded by the V-memory number or relay number. The output type is described as shown in the table below. #
Data format
1 none
2
: BOOL
3
: ONOFF
Example: V2000.15 C100 C100 : BOOL C100 : ON/OFF V2000.15 : BOOL
Description Print 1 for an ON state, and 0 for an OFF state Print “TRUE” for an ON state, and “FALSE” for an OFF state Print “ON” for an ON state, and “OFF” for an OFF state
Prints the status of bit 15 in V2000, in 1/0 format Prints the status of C100 in 1/0 format Prints the status of C100 in TRUE/FALSE format Prints the status of C100 in ON/OFF format Prints the status of bit 15 in V2000 in TRUE/FALSE format
DL205 User Manual, 4th Edition, Rev. D
Page 449
Chapter 5: Standard RLL Instructions The maximum numbers of characters you can VPRINT is 128. The number of characters required for each element, regardless of whether the :S, :C0 or :0 modifiers are used, is listed in the table below.
1 Maximum Element Type 2 Characters 3 4 5 6 7 Text element The following is used for “printing to V-memory” character strings. The character strings 8 are defined as the character (more than 0) ranged by the double quotation marks. Two hex numbers preceded by the dollar sign means an 8-bit ASCII character code. Also, two characters 9 preceded by the dollar sign is interpreted according to the following table: 10 # Character code Description 11 12 13 14 A B C D Text, 1 character 16-bit binary 32-bit binary 4-digit BCD 8-digit BCD Floating point (real number) Floating point (real with exponent) V-memory/text Bit (1/0 format) Bit (TRUE/FALSE format) Bit (ON/OFF format)
1 2 3 4 5 6 7
$$ $” $L or $l $N or $n $P or $p $R or $r $T or $t
1 6 11 4 8 13 13 2 1 5 3
Dollar sign ($) Double quotation (“) Line feed (LF) Carriage return line feed (CRLF) Form feed Carriage return (CR) Tab
DL205 User Manual, 4th Edition, Rev. D
5-225
Page 450
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-226
The following examples show various syntax conventions and the length of the output to the printer. Example: ” ” Length 0 without character ”A” Length 1 with character A ” ” Length 1 with blank ” $” ” Length 1 with double quotation mark ”$R$L” Length 2 with one CR and one LF ” $ 0 D $ 0 A ” Length 2 with one CR and one LF ”$$” Length 1 with one $ mark In printing an ordinary line of text, you will need to include double quotation marks before and after the text string. Error code 499 will occur in the CPU when the print instruction contains invalid text or no quotations. It is important to test your VPRINT instruction data during application development.
VPRINT Example Combined with PRINTV Instruction The VPRINT instruction is used to create a string in V–memory. The PRINTV is used to print the string out of port 2. Create string permissive C12 14
VPRINT Byte Swap: “Print to” Address:
All V4000
“STX” V3000:B “$0D” Delay permissive for VPRINT C13 SET Delay Permissive for VPRINT C13 15
TMR Delay for VPRINT to complete T1 K10
Delay for VPRINT to complete T1 16
PRINTV CPU/DCM Slot: Port Number: Start Address: Number of Bytes: Append: Byte Swap: Busy: Complete:
CPU K2 V4000 K12 0D (hexadecimal) None C0 C1
Delay permissive for VPRINT C13 RST
DL205 User Manual, 4th Edition, Rev. D