The text of a manual · part 38 of 53
DL06 Micro PLC User Manual, Volume 1 of 2, pages 370 to 379
Pages 370 to 379 of 524
The original document is the PDF (6.4 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 Direct Logic DL06 and Koyo DL06 D0-06DD1
Page 370
Chapter 5: Standard RLL Instructions - ASCII
ASCII Find (AFIND)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
DS5
Used
HPP
N/A
5–216
The ASCII Find instruction locates a specific ASCII string or portion of an ASCII string within a range of V–memory registers and places the string’s Found Index number (byte number where desired string is found), in Hex, into a specified V–memory register. Other features include, Search Starting Index number for skipping over unnecessary bytes before beginning the FIND operation, Forward or Reverse direction search, and From Beginning and From End selections to reference the Found Index Value. • Base Address: specifies the beginning V–memory register where the entire ASCII string is stored in memory • 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 beginning the search • Direction: 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 lower numbered V–memory registers. • Found Index Value: specifies whether the Beginning or the End byte of the ASCII string found will be loaded into the Found Index register • Found 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. • Search for String: up to 128 characters. Parameter
Base Address Total Number of Bytes Search Starting Index Found Index
DL06 Range All V–memory All V–memory or K1–128 All V–memory or K0–127 All V–memory
NOTE: Quotation marks are not required around the Search String item. Quotes are valid characters that the AFIND can search for.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 371
Chapter 5: Standard RLL Instructions - ASCII
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.
Notice that quotation marks are not placed around the Search String. Only use quotation marks if they’re actually part of the Search String.
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 =
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
V4000
DL06 Micro PLC User Manual, 3rd Edition Rev. A
5–217
Page 372
Chapter 5: Standard RLL Instructions - ASCII
AFIND Example Combined with AEX Instruction
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
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.
5–218
DL06 Micro PLC User Manual, 3rd Edition Rev. A
15
AIN Complete C1
Give delay time for AFIND instruction to complete C7 16
AFIND Base Address: V2001 Total Number of Bytes: K32 Search Starting Index: K0 Direction: Forward Found Index Value: From Beginning Found Index: V2200 Code 39 Give delay time for AFIND instruction to complete C7 SET
Search string not found in table V2200
Data not found with AFIND C10 SET
Kffff
Give delay time for AFIND instruction to complete C7 RST Give delay time for AFIND instruction to complete C7
TMR
Data not found with AFIND C10
Delay for AFIND to complete T0
17
K2
18
Delay time for AFIND to complete T0
AEX Source Base Address: V2001 Extract at Index: K0 Number of Bytes: K4 Shift ASCII Option: None Byte Swap: All Convert ASCII: To BCD (HEX) Destination Base Address: V3000 Give delay time for AFIND instruction to complete C7
RST
Page 373
Chapter 5: Standard RLL Instructions - ASCII
ASCII Extract (AEX) DS5
Used
HPP
N/A
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 beginning the Extract operation, Shift ASCII Option, for One Byte Left or One Byte Right, Byte Swap and Convert data to a BCD format number. • Source Base Address: specifies the beginning 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 Hexadecimal numerical values • Destination Base Address: specifies the V–memory register where the extracted data will be stored See the previous page for an example using the AEX instruction.
Parameter Source Base Address Extract at Index Number of Bytes
DL06 Range All V–memory All V–memory or K0–127
Constant range: V-memory location containing BCD value: “Convert BCD (HEX) ASCII” K1–128 1–128 not checked
Number of Bytes location Constant range: V-memory containing BCD value: “Convert BCD (HEX) ASCII” K1–4 1–4 checked
Destination Base Address
All V–memory
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–219
Page 374
Chapter 5: Standard RLL Instructions - ASCII
ASCII Compare (CMPV)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
DS5
Used
HPP
N/A
5–220
The ASCII Compare instruction compares two groups of V–memory registers. The CMPV will compare any data type (ASCII to ASCII, BCD to BCD, etc.) of one series (group) of V–memory registers to another series of V–memory registers for a specified byte length. • “Compare from” Starting Address: specifies the beginning V–memory 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 Parameter
SP61 = 1, the result is equal SP61 = 0, the result is not equal
DL06 Range
Compare from Starting Address All V–memory Compare to Starting Address All V–memory Number of Bytes K0–127
CMPV Example The CMPV instruction executes when the AIN instruction is complete. If the compared V–memory tables are equal, SP61 will turn ON.
AIN Complete C1
CMPV "Compare from" Starting Address: V2001 "Compare to" Starting Address: V10001 Number of Bytes: K32
SP61
Strings are equal C11 OUT
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 375
Chapter 5: Standard RLL Instructions - ASCII
ASCII Print to V–memory (VPRINT) DS5
Used
HPP
N/A
The ASCII Print to V–memory instruction will write a specified ASCII string into a series of 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 12 or 24 hour time formats. • Byte Swap: swaps the high–byte and low–byte within each V–memory register the ASCII string is printed to. See the SWAPB instruction for details. • Print to Starting V–memory Address: specifies the beginning of a series of V–memory addresses where the ASCII string will be placed by the VPRINT instruction. NOTE: Starting V–memory Address is the first V–memory register of the series of registers specified will contain the ASCII string’s length in bytes. Starting V–memory Address +1 is the 2nd and subsequent registers will contain the ASCII string printed to V–memory
Parameter
DL06 Range
Print to Starting V–memory Address All V–memory
VPRINT Time/Date Stamping– 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. # 1 2 3 4 5
Character code _date:us _date:e _date:a _time:12 _time:24
Date / Time Stamp Options 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)
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–221
Page 376
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–222
VPRINT V-memory element – 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. NOTE: There must be a space entered before and after the V-memory address to separate it from the text string. Failure to do this will result in an error code 499.
#
Character code
1 2 3 4 5 6 none :B :D :DB :R :E
Description 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)
Examples: V2000 Print binary data in V2000 for decimal number V2000 : B Print BCD data in V2000 V2000 : D Print binary number in V2000 and V2001 for decimal number V2000 : D B Print BCD data in V2000 and V2001 V2000 : R Print floating point number in V2000/V2001 as real number 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 leading zeros or spaces. The character code must be capital letters. #
Character code
1 2 3
S C0 0
Description Suppresses leading spaces Converts leading spaces to zeros Suppresses leading zeros
Example with V2000 = 0018 (binary format) Number of Characters
V–memory Register with Modifier
1
2
3
4
V2000 V2000:B V2000:B0
0 0 1
0 0 2
1 1
8 2
Example with V2000 = sp sp18 (binary format) where sp = space Number of Characters V–memory Register with Modifier 1 2 3
4
V2000 V2000:B V2000:BS V2000:BC0 sp sp 1 0 sp sp 2 0
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 1
8 2
1
2
Page 377
Chapter 5: Standard RLL Instructions - ASCII 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 2 3 none : BOOL : ONOFF
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
Example: V2000 . 15 Prints the status of bit 15 in V2000, in 1/0 format C100 Prints the status of C100 in 1/0 format C100 : BOOL Prints the status of C100 in TRUE/FALSE format C100 : ON/OFF Prints the status of C100 in ON/OFF format V2000.15 : BOOL Prints the status of bit 15 in V2000 in TRUE/FALSE format 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. Element type 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)
Maximum Characters 1 6 11 4 8 3 13 2 1 5 3
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–223
Page 378
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–224
Text element – the following is used for “printing to V–memory” character strings. The character strings 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 preceded by the dollar sign is interpreted according to the following table: #
Character code
1 2 3 4 5 6 7
$$ $” $Lor $l $N or $n $P or $p $R or $r $T or $t
Description Dollar sign ($) Double quotation (”) Line feed (LF) Carriage return line feed (CRLF) Form feed Carriage return (CR) Tab
The following examples show various syntax conventions and the length of the output to the printer. ”” ”A” ” ” ” $” ” ”$R$L” ”$0D$0A” ”$$”
Length 0 without character Length 1 with character A Length 1 with blank Length 1 with double quotation mark Length 2 with one CR and one LF 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 the application development.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 379
Chapter 5: Standard RLL Instructions - ASCII
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.
28
Create String Permissive C12
VPRINT Byte Swap: "Print to" Address
All V4000
"STX" V3000:B"$0D" Delay permissive for VPRINT C13 SET
Delay permissive for VPRINT C13
TMR
29 Delay for VPRINT to complete T1
Delay for Vprint to complete T1 30
K10 PRINTV CPU/DCM Slot: Port Number: Start Address: Number of Bytes: Append: Byte Swap: Busy: Complete:
C13
CPU K2 V4001 V4000 None None C15 C16
Delay Permissive for VPRINT RST
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–225