KEMBAR78
PLC5 String Instructions | PDF | String (Computer Science) | Ascii
0% found this document useful (0 votes)
347 views30 pages

PLC5 String Instructions

This document discusses ASCII instructions for enhanced PLC-5 processors. It lists the available ASCII instructions for tasks like reading characters from a buffer, writing strings, comparing strings, etc. It explains that ASCII instructions are dependent on each other and a second instruction cannot begin until the first is complete. However, the processor does not wait for ASCII instructions to finish before continuing other non-ASCII instructions. It also discusses using status bits to examine events from executing ASCII instructions.

Uploaded by

Bin Mulyadin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
347 views30 pages

PLC5 String Instructions

This document discusses ASCII instructions for enhanced PLC-5 processors. It lists the available ASCII instructions for tasks like reading characters from a buffer, writing strings, comparing strings, etc. It explains that ASCII instructions are dependent on each other and a second instruction cannot begin until the first is complete. However, the processor does not wait for ASCII instructions to finish before continuing other non-ASCII instructions. It also discusses using status bits to examine events from executing ASCII instructions.

Uploaded by

Bin Mulyadin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,

AHL, ARD, ARL, ASC, ASR, AWA, AWT

17 ASCII Instructions ABL, ACB, ACI,


ACN, AEX, AIC, AHL, ARD, ARL,
ASC, ASR, AWA, AWT

Enhanced PLC-5 Processors only

Using ASCII Instructions


The ASCII instructions read, write, compare and convert ASCII strings. These
instructions are only supported by Enhanced PLC-5 processors. Table 17.A lists the
available ASCII instructions.

Table 17.A
Available ASCII Instructions

If You Want to: Use this Instruction: On Page:

See how many characters are in the buffer, up to and ABL 175
including the end of line character

See how many total characters are in the buffer ACB 177

Convert a string to an integer value ACI 179

Concatenate two strings into one ACN 1710

Extract a portion of a string to create a new string AEX 1711

Configure your modem handshake lines AHL 1712

Convert an integer value to a string AIC 1714

Read characters from the buffer and put into a string ARD 1715
(Continued)

17-1
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

17 ASCII Instructions ABL, ACB, ACI,


ACN, AEX, AIC, AHL, ARD, ARL,
ASC, ASR, AWA, AWT

Enhanced PLC-5 Processors only

Using ASCII Instructions


The ASCII instructions read, write, compare and convert ASCII strings. These
instructions are only supported by Enhanced PLC-5 processors. Table 17.A lists the
available ASCII instructions.

Table 17.A
Available ASCII Instructions

If You Want to: Use this Instruction: On Page:

See how many characters are in the buffer, up to and ABL 175
including the end of line character

See how many total characters are in the buffer ACB 177

Convert a string to an integer value ACI 179

Concatenate two strings into one ACN 1710

Extract a portion of a string to create a new string AEX 1711

Configure your modem handshake lines AHL 1712

Convert an integer value to a string AIC 1714

Read characters from the buffer and put into a string ARD 1715
(Continued)

17-1
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

If You Want to: Use this Instruction: On Page:

Read one line of characters from the buffer and put into ARL 1718
a string

Search a string for another string ASC 1721

Compare two strings ASR 1722

Write a string with userconfigured characters appended AWA 1723

Write a string AWT 1726

For more information on the operands (and valid data types/values of each operand)
used by the instructions discussed in this chapter, see Appendix C.

There are two types of ASCII instructions:

Type of ASCII Instruction: Description:

ASCII port control read, write, set/reset handshake lines,


examine the length of the buffer (ARD,
ARL, AWT, AWA, AHL, ACB, ABL)
ASCII string manipulate string data, such as
compare, search, extract, concatenate,
convert to/from integer (ASR, ASC,
AEX, ACN, ACI, AIC)

ASCII instructions are dependent upon one another. For example, if you have an
ARD (ASCII read instruction) and then an AWT (ASCII write), the done bit on the
ARD must be set before the AWT can begin executing (even if the AWT was
enabled while the processor was executing the ARD). A second ASCII instruction
cannot begin until the first has completed. However, the processor does not wait for
an ASCII instruction to complete before continuing to execute your ladder program
(non-ASCII instructions).

17-2
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

If You Want to: Use this Instruction: On Page:

Read one line of characters from the buffer and put into ARL 1718
a string

Search a string for another string ASC 1721

Compare two strings ASR 1722

Write a string with userconfigured characters appended AWA 1723

Write a string AWT 1726

For more information on the operands (and valid data types/values of each operand)
used by the instructions discussed in this chapter, see Appendix C.

There are two types of ASCII instructions:

Type of ASCII Instruction: Description:

ASCII port control read, write, set/reset handshake lines,


examine the length of the buffer (ARD,
ARL, AWT, AWA, AHL, ACB, ABL)
ASCII string manipulate string data, such as
compare, search, extract, concatenate,
convert to/from integer (ASR, ASC,
AEX, ACN, ACI, AIC)

ASCII instructions are dependent upon one another. For example, if you have an
ARD (ASCII read instruction) and then an AWT (ASCII write), the done bit on the
ARD must be set before the AWT can begin executing (even if the AWT was
enabled while the processor was executing the ARD). A second ASCII instruction
cannot begin until the first has completed. However, the processor does not wait for
an ASCII instruction to complete before continuing to execute your ladder program
(non-ASCII instructions).

17-2
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Using Status Bits

You can examine status bits in the ladder program to examine some event. The
processor changes the states of status bits as the processor executes the instruction.
You address the status bits by mnemonic (or bit number) in the control
element address.

The ASCII instructions use the length (.LEN) and position (.POS) fields in some
instructions as well as the following status bits:

Description: Explanation of Status Bit:

Found.FD (08) Reserved


Unload.UL (10) This bit may be used by the user to cancel an ASCII read or
write in progress. The time out may occur immediately or up to 6
seconds later.
Error.ER (11) The instruction did not complete successfully.
Note: If this bit is set , the .EN bit is cleared and the .DN bit is set
during prescan.
Synchronous Done.EM (12) The bit is set on the first scan of the instruction after it is completed.
Asynchronous Done.DN (13) The bit is set immediately upon successful completion of the
instruction, asynchronous to program scan.
Note: If this bit is set , the .EN bit is cleared and the .DN bit is set
during prescan.
Queue.EU (14) The bit is set when the instruction is successfully queued.
Enable.EN (15) The bit is set when the rung goes true and is reset after completion
of the instruction and the rung goes false.
Note: If this bit is set and the .DN and .ER bits are cleared, the
control word is cleared during prescan.

Using the Control Block


In addition to the status bits, the control block contains other parameters the
processor uses to control ASCII transfer instructions. Table 17.B lists these values.
Table 17.B
Values in the Control Word

Word - Integer ASCII Control Block Description


Control Block

0 .EN, .DN, etc Status Bits

1 .LEN Word Length

2 .POS Character Position

17-3
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Length (.LEN)

This is the number of characters the operation is to be performed on.

Position (.POS)

This is the current character number which the operation has executed.

Using Strings

You can address string lengths by adding a .LEN to any string address (for example,
ST17:1.LEN).

String lengths must be between 0 and 82 bytes. In general, lengths that are outside
of this range cause the processor to set a minor fault (S:17/8) and the instruction is
not executed.
Note You configure append or end-of-line characters on the Channel Configuration
screen. The default append characters are carriage return and line feed; the default
end-of-line (termination) character is carriage return. For more information, see
your software user manual.

17-4
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Test Buffer for Line (ABL)

Description:
ABL EN Use the ABL instruction to see how many characters are in the buffer, up to and
ASCII TEST FOR LINE
Channel DN including the end-of-line characters (termination). On a false-to-true transition, the
Control system reports the number of characters in the Position field, and sets the done bit.
Characters ER
The serial port must be in User mode.

Entering Parameters:

To use the ABL instruction, you must supply the following information:

Parameter: Definition:

Channel the number of the RS232 port. (The only valid value is 0).
Control the address of a control file element used for the control
status bits.
Characters the number of characters in the buffer (including the
endofline/termination characters) that the processor finds
(0256). This field is display only.

Example:

I:012 ABL
EN
[
[
ASCII TEST FOR LINE
10 Channel 0 DN
If input word 12, bit 10 is set, the processor Control R6:32
performs an ABL operation for channel 0.
Characters ER

When the rung goes from false to true, the control element enable bit (.EN) is set.
The instruction is put in the ASCII instruction queue, the .EU bit is set and program
scan continues. The instruction is then executed parallel to program scan.

17-5
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

The processor determines the number of characters (up to and including the
end-of-line/termination characters) and puts this value in the position field. The
done bit is then set. If a zero appears in the position field, no end-of-line/termination
characters were found. The .FD bit is set if the position field was set to a
non-zero value.

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit. The .EM bit acts as a secondary done bit corresponding to the
program scan.

The error bit (.ER) is set during the execution of the instruction if:
• the instruction is aborted - serial port not in User mode
• the instruction is aborted due to processor mode change

17-6
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Number of Characters in Buffer (ACB)

Description:
ACB Use the ACB instruction to see how many total characters are in the buffer. On a
EN
ASCII CHARS IN BUFFER
Channel DN
false-to-true transition, the system determines the total number of characters and
Control reports it in the Characters field. The serial port must be in User mode.
Characters ER

Entering Parameters:

To use the ACB instruction, you must provide the processor the
following information:

Parameter: Definition:

Channel the number of the RS232 port (The only valid value in this field is 0).
Control the address of a control file element used for control status bits.
Characters the number of the characters in the buffer that the processor finds
(0256). This field is display only.

Example:
I:012 ACB
[
[ EN
ASCII CHARS IN BUFFER
10 Channel 0 DN
If input word 12, bit 10 is set, the processor Control R6:32
performs an ACB operation for channel 0. Characters
ER

When the rung goes from false to true, the control element enable bit (.EN) is set.
When the instruction is put in the ASCII instruction queue, the .EU bit is set and
program scan continues. The instruction is then executed parallel to program scan.

The processor determines the number of characters in the buffer and puts this value
in the position field. The done bit is then set. If a zero appears in the position field,
no characters were found. The .FD bit is set if the position field was set to a
non-zero value.

17-7
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit. The .EM bit acts as a secondary done bit corresponding to the
program scan.

The error bit (.ER) is set during the execution of the instruction if:
• the instruction is aborted – serial port not in User mode
• the instruction is aborted due to processor mode change

17-8
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII String to Integer (ACI)

Description:
ACI Use the ACI instruction to convert an ASCII string to an integer value between
STRING TO INTEGER CONVERSION
Source –32,768 and 32,767.
Destination

The processor searches the source (file type ST) for the first character that is
between 0 and 9. All numeric characters are extracted until a non-numeric character
or the end of the string is reached. Commas and signs (–, +) are allowed in
the string.

The extracted numeric string is then converted to an integer between –32,768


and 32,767.

If no numeric characters are found, no action is taken. Also, if the string has an
invalid length (less than zero or greater than 82), the fault bit is set (S:17/8) and the
instruction is not executed.

This instruction also sets the arithmetic flags (found in word 0, bits 0-3 in the
processor status file S):

Bit: Description: Indicating:

S:0/0 Carry (C) the carry was generated while converting the string
to an integer
S:0/1 Overflow (V) the integer value was outside of the valid range
S:0/2 Zero (Z) the integer value is zero
S:0/3 Sign (S) the integer value is negative

Example:
I:012 ACI
[
[
STRING TO INTEGER
10 Source ST38:90
Destination N7:123
If input word 12, bit 10 is set, convert the string in
ST38:90 to an integer and store the result in N7:123. 75

17-9
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII String Concatenate (ACN)

Description:
ACN The ACN instruction appends Source B to the end of Source A and stores the result
STRING CONCATENATE in the Destination.
Source A
Source B
Destination If the result is longer than 82 characters, only the first 82 are written to the
destination file and the error bit (S:17/8) is set. Also, if the length of either string is
invalid (less than zero or greater than 82), the fault bit is set and the string at the
destination address is not changed.

Example:
I:012 ACN
[
[
STRING CONCATENATE
10 Source A ST37:42
If input word 12, bit 10 is set, concatenate the string
Source B ST38:91
in ST37:42 with the string in ST38:91 and store the
Destination ST52:76
result in ST52:76

17-10
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII String Extract (AEX)

Description:
AEX
STRING EXTRACT
Use the AEX instruction to create a new string by taking a portion of an
Source existing string.
Index
Number
Destination

Entering Parameters:

To use the AEX instruction, you must provide the processor the
following information

Parameter: Definition:

Source the existing string.


Index the starting position (from 1 to 82) of the portion of the string you want to extract.
(An index of 1 indicates the leftmost character of the string.)
Number the number of characters (from 0 to 82) you want to extract, starting at the indexed
position. If the Index plus the Number is greater than the total characters in the
source string, the destination string will be the characters from the index to the end
of the source string. If you enter 0 for the number, the destination string length is set
to zero.
Destination the string element (ST) where you want the extracted string stored.

Example:
I:012 AEX
[
[
STRING EXTRACT
10 Source ST38:40
If input word 12, bit 10 is set, extract 10 characters Index 42
starting at the 42nd character of ST38:40 and store Number 10
the result in ST52:75. Destination ST52:75

The following conditions cause the processor to set the fault bit (S:17/8):
• invalid string length or string length of zero
• index or number values outside of range
• index value greater than the length of the source string

The destination string will not change in any of the above instances.

17-11
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Set or Reset Handshake Lines (AHL)

Description:
AHL Use the AHL instruction to set or reset the RS-232 DTR and RTS handshake control
EN
ASCII HANDSHAKE LINE
Channel
lines for your modem. On a false-to-true transition, the system uses the two masks
DN
AND Mask to determine whether to set or reset the DTR and RTS lines, or leave
OR Mask
Control ER them unchanged.
Channel Status

Note Before you use this instruction make sure that you do not conflict with the automatic
control lines on your modem.

Entering Parameters:

To use the AHL instruction, you must provide the following information:

Parameter: Definition:

Channel the number of the RS232 port that you want to use. Currently, only
channel 0 can be set or reset.
AND Mask the mask to reset the DTR and RTS control lines. Bit 0 corresponds to
the DTR line and bit 1 corresponds to the RTS line. A 1 at the mask
bit causes the line to be reset; a 0 leaves the line unchanged.
OR Mask the mask to set the DTR and RTS control lines. Bit 0 corresponds to
the DTR line and bit 1 corresponds to the RTS line. A 1 at the mask
bit causes the line to be set; a 0 leaves the line unchanged.
Control the address of the result control structure in the control area of
memory for the result.
Channel Status displays the current status (0000 to FFFF) of the handshake lines for
the channel specified above. This field is display only; convert the
hexadecimal status to binary and refer to the table below:

Bit 1 0

Line RTS DTR

17-12
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Example: (Reset DTR and RTS Lines)


I:012 AHL
[
[ EN
ASCII HANDSHAKE LINES
10 Channel 0
DN
AND Mask 0003
OR Mask 0000
Control R6:23 ER
If input word 12, bit 10 is set, bit 0 and bit 1 of the AND
mask is set to RESET (OFF) the DTR and RTS lines. Channel Status
Channel status will display a 000D.

Example: (Set DTR and RTS Lines)


I:012 AHL
[
[ EN
ASCII HANDSHAKE LINES
11 Channel 0
DN
AND Mask 0000
OR Mask 0003
Control R6:22 ER
If input word 12, bit 11 is set, bit 0 and bit 1 of the OR
mask is set to SET (ON) the DTR and RTS lines. Channel Status
Channel status will display a 001F.

The error bit (.ER) is set during the execution of the instruction if the instruction is
aborted due to processor mode change.

17-13
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Integer to String (AIC)

Description:

Use the AIC instruction to convert an integer value (between –32,768 and 32,767) to
an ASCII string. The source can be a constant or an integer address.

Example:
I:012 AIC
[
[
INTEGER TO STRING
10 Source 867
If input word 12, bit 10 is set, convert the value Destination ST38:42
876 to a string and store the result in ST38:42.

17-14
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Read Characters (ARD)

Description:
ARD Use the ARD instruction to read characters from the buffer and store them in a
EN
ASCII READ
Channel string. To repeat the operation, the rung must go from false to true. The serial port
Destination DN
Control must be in User mode.
String Length ER
Characters Read

Entering Parameters:

To use the ARD instruction, provide the following information:

Parameter: Definition:

Channel the number of the RS232 port. (The only valid value is 0).
Control the control file element used for the control status bits.
Destination the string element where you want the characters stored.
String Length the number of characters you want to read from the buffer. The
maximum is 82 characters. If you specify a length larger than 82,
only 82 characters will be read. (If you specify 0, the string length
defaults to 82.)
Characters Read the number of characters that the processor moved from the buffer to
the string (0 to 82). This field is display only.

Example:

I:012 ARD
ASCII READ EN
[
[

10 Channel 0
Destination ST52:76 DN
If input word 12, bit 10 is set, read 50 characters Control R6:23
from the buffer and move them to ST52:76. String Length 50 ER
Characters Read

When the rung goes from false to true, the control element enable bit (.EN) is set.
The instruction is put in the ASCII instruction queue, the .EU bit is set and program
scan continues. The instruction is then executed parallel to program scan.

17-15
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Once the requested number of characters are in the buffer, the characters are moved
to the destination string. The number of characters moved is put in the position word
of the control element and the done bit is set.

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit. The .EM bit acts as a secondary done bit corresponding to the
program scan.

You can use the .UL bit to terminate an ARD instruction before it completes (for
example, you may want to terminate the instruction if you know that the ASCII
device connected to the port is not sending data, or if the connection breaks after the
instruction starts executing). Set the .UL bit in the control structure (the .ER bit is
then set).
Note When you set the .UL bit, the instruction does not terminate immediately; it may
take several seconds.

If an ARD instruction starts executing with the .UL bit already set and there are no
characters in the buffer, the instruction terminates. If an ARD instruction starts
executing with the .UL bit already set and there are characters in the buffer, the
instruction proceeds to normal completion.

The error bit (.ER) is set during the execution of the instruction if:
• the instruction is aborted – serial port not in User mode
• the instruction is aborted due to processor mode change
• when using a modem, the modem is disconnected

17-16
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Figure 17.1
Example ARD Timing Diagram
Rung Condition ON
OFF

ON
Enable Bit (.EN) OFF

Queue Bit (.EU) ON


OFF

Done Bit
Error Bit ON
(.DN or. ER) OFF

ON
Synchronous Done Bit (.EM) OFF

1 2 3 4 5 1 5 2 3 4
1  rung goes true
2  instruction successfully queued
3  instruction execution complete
4  instruction scanned for the first time after execution is complete
5  rung goes false

17-17
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Read Line (ARL)

Description:
ARL Use the ARL instruction to read characters from the buffer up to and including the
ASCII READ LINE EN
Channel end-of-line (termination) characters and store them in a string. The end-of-line
Destination DN
Control characters are specified on the Channel Configuration screen (the default is a
String Length
ER
Characters Read carriage return). For more information on channel configuration, see your software
user manual. The serial port must be in User mode.

Entering Parameters:

To use the ARL instruction, you must provide the following information:

Parameter: Definition:

Channel the number of the RS232 port. (The only valid value is 0).
Control the address of the control file element used for the control status bits.
Destination the string element where you want the string stored.
String Length the number of characters (maximum 82) you want to read from the buffer. If
the processor finds the endofline characters before reading the number of
characters you specified, only those characters read and the endofline are
moved to the destination.
Characters Read the number of characters that the processor moved from the buffer to the
string (0 to 82). This field is display only.

Example:

I:012 ARL
[ ASCII READ LINE EN
[
10 Channel 0
Destination ST52:72 DN
If input word 12, bit 10 is set, read 18 characters Control R6:23
(or until endofline) from the buffer and move String Length 18
them to ST52:72. ER
Characters Read

When the rung goes from false to true, the control element enable bit (.EN) is set.
The instruction is put in the ASCII instruction queue, the .EU bit is set and program
scan continues. The instruction is then executed parallel to program scan.

17-18
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Once the requested number of characters (or the end-of-line characters) are in the
buffer, all characters (including the end-of-line characters) are moved to the
destination string. The number of characters moved is stored in the position word of
the control element and the done bit is set.

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit. The .EM bit acts as a secondary done bit corresponding to the
program scan.

You can use the .UL bit to terminate an ARL instruction before it completes (for
example, you may want to terminate the instruction if you know that the ASCII
device connected to the port is not sending data, or if the connection breaks after the
instruction starts executing). Set the .UL bit in the control structure (the .ER bit is
then set).
Note When you set the .UL bit, the instruction does not terminate immediately; it may
take several seconds.

If an ARL instruction starts executing with the .UL bit already set and there are no
characters in the buffer, the instruction terminates. If an ARL instruction starts
executing with the .UL bit already set and there are characters in the buffer, the
instruction proceeds to normal completion.

The error bit (.ER) is set during the execution of the instruction if the channel is in
system mode (or switches to system mode), the processor switches to program/test
mode or if the modem is lost (when using modem control).

17-19
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Figure 17.2
Example ARL Timing Diagram

Rung Condition ON
OFF

Enable Bit (.EN) ON


OFF

Queue Bit (.EU) ON


OFF

Done Bit
Error Bit
ON
(.DN or. ER)
OFF

ON
Empty Bit (.EM) OFF

1 2 3 4 5 1 5 2 3 4
1  rung goes true
2  instruction successfully queued
3  instruction execution complete
4  instruction scanned for the first time after execution is complete
5  rung goes false

17-20
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII String Search (ASC)

Description:
ASC
STRING SEARCH
Use the ASC instruction to search an existing string (search string) for an
Source occurrence of the source string.
Index
Search
Result

Entering Parameters:

To use the ASC instruction, you must provide the processor the
following information:

Parameter: Definition:

Search the string you want to examine.


Source the string you want to find when examining the search string.
Index the starting position (from 1 to 82) of the portion of the search string you want to
search. An index of 1 indicates the leftmost character.
Result an integer address where the processor stores the position of the search string
where the source string begins. If no match is found, 0 is stored in the result.

Example:
I:012 ASC
[ STRING SEARCH
[
10 Source ST38:40
Index 35
Search ST52:80
If input word 12, bit 10 is set, search the string in ST52:80 Result N10:0
starring at the 35th character, for the string found in
ST38:40. In this example, the result is stored in N10:0.

The following conditions cause the processor to set the fault bit (S:17/8):
• invalid string length or string length of zero
• index values outside of range
• index value greater than the length of the source string

The result is set to zero in any of the above instances.

17-21
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII String Compare (ASR)

Description:

Use the ASR instruction to compare two ASCII strings. The system looks for a
match in length and upper/lower case. If the two strings are identical, the rung is
true; if there are any differences, the rung is false.

Example:
ASR O:013
ASCII STRING COMPARE
Source A ST37:42 01
Source B ST38:90
If the string in ST37:42 is identical to the
string in ST38:90, set output bit O:013/01.

An invalid string length causes the processor to set the fault bit (S:17/8), and the
rung is false.

17-22
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Write with Append (AWA)

Description:
AWA Use the AWA instruction to write characters from the source to a display device.
ASCII WRITE APPEND EN
Channel This append instruction adds 1 or 2 characters (which you configure in the Channel
Source DN
Control Configuration). The default is a carriage return and line feed appended to the end of
String Length
Characters Sent ER the string. You can use this instruction with the serial port in User or System mode.

Entering Parameters:

To use the AWA instruction, you must provide the following information:

Parameter: Definition:

Channel the number of the RS232 port. (The only valid value is 0).
Source the string you want to write.
Control the address of the control file element used for the control status bits.
String Length the maximum number of characters you want to write from the source string
(0 to 82). If you enter 0, the entire string will be written.
Characters Sent the number of characters that the processor sent to the display area
(0 to 82). Only after the entire string is sent is this field updated (no running
total for each character sent is stored). This field is display only.

Example:
I:012 AWA
EN
[
[ ASCII WRITE APPEND
10 Channel 0
Source ST37:42 DN
Control R6:23
String Length 25 ER
If input word 12, bit 10 is set, read 25 characters from
ST37:42 and write it to the display device. Then write Characters Sent
a carriage return and line feed (default).

When the rung goes from false to true, the control element enable bit (.EN) is set.
The instruction is put in the ASCII instruction queue, the .EU bit is set and program
scan continues. The instruction is then executed parallel to program scan.

17-23
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Twenty-five characters from the start of string ST37:42 are sent to the display
device and then user-configured append characters are sent. The done bit is set and a
value of 27 is sent to the position word.

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit to act as a secondary done bit corresponding to the program scan.

You can use the .UL bit to terminate an AWA instruction before it completes (for
example, you may want to terminate the instruction if you know that the ASCII
device connected to the port cannot accept data, or if the connection breaks after the
instruction starts executing). Set the .UL bit in the control structure (the .ER bit is
then set).
Note When you set the .UL bit, the instruction does not terminate immediately; it may
take several seconds.

If an AWA instruction starts executing with the .UL bit already set, the instruction
aborts immediately.

The error bit (.ER) is set during the execution of the instruction if the instruction is
aborted due to processor mode change or if the modem becomes lost (when using
modem control). If the modem was already lost, the instruction still executes.

17-24
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

Figure 17.3
Example AWA Timing Diagram
Rung Condition ON
OFF

ON
Enable Bit (.EN)
OFF

ON
Queue Bit (.EU)
OFF

Done Bit
ON
Error Bit
OFF
(.DN or. ER)

ON
Empty Bit (.EM)
OFF

1 2 3 4 5 1 5 2 3 4

1  rung goes true


2  instruction successfully queued
3  instruction execution complete
4  instruction scanned for the first time after execution is complete
5  rung goes false

17-25
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

ASCII Write (AWT)

Description:
AWT
ASCII WRITE
Use the AWT instruction to write characters from the source to a display device. To
EN
Channel repeat the instruction, the rung must go from false to true. You can use this
Source
DN
Control instruction with the port in System or User mode.
String Length
Characters Sent ER

Entering Parameters:

To use the AWT instruction, you must provide the following information:

Parameters: Definition:

Channel the number of the RS232 port. (The only valid value is 0).
Source the string you want to write.
Control the address of the control file element used for the control status file.
String Length the maximum number of characters you want to write from the source string
(0 to 82). If you enter 0, the entire string will be written.
Characters Sent the number of characters that the processor sent to the display area
(0 to 82). Only after the entire string is sent is this field updated (no running
total for each character sent is stored). This field is display only.

Example:
I:012 AWT
[
[ ASCII WRITE EN
10 Channel 0
Source ST37:20 DN
Control R6:23
If input word 12, bit 10 is set, write 40 characters String Length 40
ER
from ST37:20 and write it to the display device. Characters Sent

When the rung goes from false to true, the control element enable bit (.EN) is set.
The instruction is put in the ASCII instruction queue, the .EU bit is set and program
scan continues. The instruction is then executed parallel to program scan.

Forty characters from string ST37:20 are sent through channel 0. The done bit is set
and a value of 40 is sent to the position word.

17-26
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
AHL, ARD, ARL, ASC, ASR, AWA, AWT

When the program scans the instruction and finds the .DN bit set, the processor then
sets the .EM bit. The .EM bit acts as a secondary done bit corresponding to the
program scan.

You can use the .UL bit to terminate an AWT instruction before it completes (for
example, you may want to terminate the instruction if you know that the ASCII
device connected to the port cannot accept data, or if the connection breaks after the
instruction starts executing). Set the .UL bit in the control structure (the .ER bit is
then set).
Note When you set the .UL bit, the instruction does not terminate immediately; it may
take several seconds.

If an AWT instruction starts executing with the .UL bit already set, the instruction
aborts immediately.

The error bit (.ER) is set during the execution of the instruction if the processor
switches to program or test mode or if the modem becomes lost (when using modem
control). If the modem was already lost, the instruction still executes.
Figure 17.4
Example AWT Timing Diagram
ON
Rung Condition
OFF

ON
Enable Bit (.EN) OFF

ON
Queue Bit (.EU) OFF

Done Bit
ON
Error Bit
OFF
(.DN or. ER)

ON
Empty Bit (.EM)
OFF

1 2 3 4 5 1 5 2 3 4
1  rung goes true
2  instruction successfully queued
3  instruction execution complete
4  instruction scanned for the first time after execution is complete
5  rung goes false

17-27
ASCII Instructions ABL, ACB, ACI, ACN, AEX, AIC,
Preface
AHL, ARD, ARL, ASC, ASR, AWA, AWT

17-28

You might also like