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

The text of a manual · part 22 of 70

SLC 500 Instruction Set Reference Manual, pages 211 to 220

Pages 211 to 220 of 694

The original document is the PDF (7.2 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 Allen-Bradley 1747-L514

Page 211

ASCII Instructions

10-7

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 channel mode change. • the Unload bit (UL) is set and the instruction is not executed.

Number of ASCII Characters In Buffer (ACB)

Use the ACB instruction to determine the total characters in the buffer. On a false-to-true transition, the processor determines the total number of characters and records it in the position field of the ASCII control block. The serial port must be in User mode.

Entering Parameters ACB Ascii Chars In Buffer Channel 0 Control R16:1 Characters 0 Error 0

EN

Enter the following parameters when programming this instruction.

DN ER

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 • Output Instruction

•

•

• Channel is the number of the RS-232 port (Channel 0). • Control is the area that stores the control register required to operate the instruction. • Characters are the number of characters in the buffer that the processor finds (0-1024). This parameter is display only. • Error displays the hexadecimal error code that indicates why the ER bit was set in the control data file (R6). See page 10-24 for error descriptions.

Example

When the rung goes from false-to-true, the Enable bit (EN) is set. When the instruction is placed in the ASCII queue, the Queue bit (EU) is set. The Running bit (IN) is set when the instruction is executing. The Done bit (DN) is set upon completion of the instruction. The processor determines the number of characters in the buffer and puts this value in the position field of the control block. The Done bit (DN) is then set. If a zero appears in the characters field, no characters were found. When the program scans the instruction and finds the Done bit (DN) set, the processor then sets the Synchronous bit (EM). The EM bit acts as a secondary done bit corresponding to the program scan.

Publication 1747-RM001G-EN-P - November 2008

Page 212

10-8

ASCII Instructions

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 channel mode change. • the Unload bit (UL) is set and the instruction is not executed.

Use the ACI instruction to convert a numeric ASCII string to an integer value between -32,768 and 32,767.

String to Integer (ACI)

Example ACI String to Integer Source ST10:0 Dest N7:75 0<

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

Output Instruction

The processor searches the source (file type ST) for the first character between 0 and 9. All numeric characters are extracted until a non-numeric character or the end of the string is reached. Action is taken only if numeric characters are found. If the string contains an invalid length (<0 or >82) the ASCII Error bit S:5/15 is set. Commas and signs (+, -) are allowed in the string. However, only the minus sign is displayed in the data table. The extracted numeric string is then converted to an integer. The ASCII Error bit S:5/15 is set if the string contains an invalid string length. The value of 32,767 is returned as the result. This instruction also sets the arithmetic flags (found in word 0, bits 0-3 in the processor status file S:0).

Table 10.6 Processor Function With this Bit The Processor

Publication 1747-RM001G-EN-P - November 2008

S:0/0

Carry (C)

is reserved.

S:0/1

Overflow (V)

sets if the integer value is outside of the valid range.

S:0/2

Zero (Z)

sets if the integer value is zero.

S:0/3

Sign (S)

sets if the result is negative.

Page 213

ASCII Instructions

ASCII Clear Receive and/or Transmit Buffer (ACL) ACL Ascii Clear Buffers Channel Receive Buffer Transmit Buffer

0 Yes No

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 • Output Instruction

•

•

10-9

Use this instruction to clear an ASCII buffer. ASCII instructions are removed from the queue and then the Error bit (ER) is set. This instruction clears the ASCII buffers immediately upon the rung transitioning to a true state. The instruction works when the channel is in User Mode or System Mode configured for DF1 Full-duplex or Half-duplex drivers. In System Mode, only the ASCII transmit buffer can be cleared. For OS Series C, FRN 7 and higher, the ACL instruction can also be used to clear the DF1 communication buffers when the channel is configured for any of the DF1 communication drivers. Select 0 for the channel number and Yes for both the receive and transmit buffers. When the ACL instruction is executed, any pending outgoing DF1 replies, incoming DF1 commands, and outgoing DF1 commands are flushed. Any MSG instructions in progress on that channel will error out with an error code of 0x0C. The DF1 communication buffers are cleared at end-of-scan or during REF instruction execution.

IMPORTANT

For OS Series C, FRN 7 and higher, when the ACL instruction is executed with both the Receive Buffer and Transmit buffer set to Yes while channel 0 is in System Mode and configured for DF1, two actions occur. • The ASCII transmit buffer is cleared and any AWA and AWT instructions in the ASCII queue are removed. • Any pending outgoing DF1 replies, incoming DF1 commands, and outgoing DF1 commands are flushed.

In addition, for SLC 5/03 processors with OS302 Series C, FRN 7 or higher, the ACL instruction can be used to clear the Local Passthru Queue when channel 0 is configured for DF1 and the DF1 Remote/Local Passthru bit (S:34/6) is set to Local. Select No for the receive buffer and Yes for the transmit buffer.

Publication 1747-RM001G-EN-P - November 2008

Page 214

10-10

ASCII Instructions

IMPORTANT

For SLC 5/03 with OS302, Series C, FRN 7 and higher, when the ACL instruction is executed with: • the receive buffer set to No and the Transmit buffer set to Yes while channel 0 is in System Mode and configured for DF1. • the DF1 Remote/Local Passthru bit is set for Local (S34/6=1). Two actions occur. • The ASCII transmit buffer is cleared and any AWA and AWT instructions in the ASCII queue are removed • The Local Passthru queue is flushed

Entering Parameters Enter the following parameters when programming this instruction. • Channel is the number of the RS-232 port (Channel 0). • Receive Buffer, when set to Yes, clears the receive buffer and removes the ARD and ARL instructions from the queue. The Error bit (ER) is set in each of these instructions. • Transmit Buffer, when set to Yes, clears the transmit buffer and removes the AWA and AWT instructions from the queue. The Error bit (ER) is set in each of these instructions.

Example

When the rung goes true, the selected buffer(s) will be cleared and the ASCII instruction(s) are removed from the ASCII instruction queue.

Publication 1747-RM001G-EN-P - November 2008

Page 215

ASCII Instructions

String Concatenate (ACN)

10-11

The ACN instruction combines two strings using ASCII strings as operands. The second string is appended to the first and the result stored in the destination.

Entering Parameters Enter the following parameters when programming this instruction.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

• Source A is the first string in the concatenation procedure. • Source B is the second string in the concatenation procedure. • Destination is where the result of Source A and B is stored.

•

Output Instruction

Example

Only the first 82 characters (0 to 81) are written to the destination. If the result is > 82 the ASCII Error bit S:5/15 is set.

Publication 1747-RM001G-EN-P - November 2008

Page 216

10-12

ASCII Instructions

Use the AEX instruction to create a new string by taking a portion of an existing string and linking it to a new string.

String Extract (AEX)

Entering Parameters AEX String Extract Source ST28:0 Index 32 Number 10 Dest ST14:3

Enter the following parameters when programming this instruction.

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

Output Instruction

• Source is the existing string. The source value is not affected by this instruction. • Index is the starting position (from 1 to 82) of the string you want to extract. (An index of 1 indicates the left-most character of the string.) • Number is the number of characters (from 1 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. • Destination is the string element (ST) where you want the extracted string stored.

Example

The following conditions cause the processor to set the ASCII Error bit (S:5/15). • Invalid source 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 is not changed in any of the above error conditions. However, the destination will be changed if the index value plus the number value are greater than the string length. Note that the ASCII Error bit (S:5/15) is not set.

Publication 1747-RM001G-EN-P - November 2008

Page 217

ASCII Instructions

10-13

ASCII Handshake Lines (AHL) AHL Ascii Handshake Lines Channel 0 AND Mask 0FF03h OR Mask 0FDEBh Control R6:4 Channel Status 0000h Error 0

Use the AHL instruction to set or reset the RS-232 Data Terminal Ready (DTR) and Request to Send (RTS) handshake control lines for your modem. On a false-to-true transition, the processor uses the two masks to determine whether to set or reset the DTR and RTS lines, or leave them unchanged. This instruction will operate when the port is in either mode or is disabled.

EN DN ER

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 • Output Instruction

•

•

TIP

Make sure the automatic modem control used by the port, in system mode, does not conflict with this instruction.

Entering Parameters Enter the following parameters when programming this instruction. • Channel is the number of the RS-232 port (Channel 0). • AND Mask is the type of mask used to reset the DTR and RTS control lines. Bit 0 corresponds to the DTR line and bit 1 corresponds to the RTS control line. A 1 at the mask bit causes the line to be reset; a 0 leaves the line unchanged. Note that mask values do not have a one-to-one correspondence to the modem control lines. • OR Mask is the type of mask used to set the DTR and RTS control lines. Bit 0 corresponds to the DTR line and bit 1 corresponds to the RTS control line. A 1 at the mask bit causes the line to be set; a 0 leaves the line unchanged. Note that mask values do not have a one-to-one correspondence to the modem control lines. • Control is the area that stores the control register required to operate the instruction. • Channel Status displays the current status (0000 to 001F) of the handshake lines for the channel, specified above. This field is display only and resides in word 2 of the control element. • Error displays the hexadecimal error code that indicates why the ER bit was set in the control data file (R6). See page 10-24 for error code descriptions.

Publication 1747-RM001G-EN-P - November 2008

Page 218

10-14

ASCII Instructions

Example The following shows the channel status as 001F.

Table 10.7 Control Block Structure Channel Status Bit

15

14

Bit

Reserved

Line

0

Channel Status

0

13

0

12

0

0

11

0

10

0

0

9

0

8

0

7

0 1

6

0

5

0

4

3

2

1

0

DTR

DCD

DSR

RTS

CTS

1

1

1

1

1

F

Example

The Error bit (ER) is set during the execution of the instruction if: • the instruction is aborted due to channel mode change. • the Unload bit (UL) is set and the instruction is not executed.

The AIC instruction converts an integer value (-32,768 and 32,767) to an ASCII string. The source can be a constant or an integer address.

Integer to String (AIC)

Example AIC Integer to String Source N7:98 0< Dest ST10:6

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •

•

•

Output Instruction

Publication 1747-RM001G-EN-P - November 2008

Page 219

ASCII Instructions

10-15

Use the ARD instruction to read characters from the buffer and store them in a string. To repeat the operation, the rung must go from false-to-true.

ASCII Read Characters (ARD)

Entering Parameters ARD ASCII Read Channel Dest Control String Length Characters Read Error

EN 0 ST10:7 R6:5 20< 0 0

Enter the following parameters when programming this instruction.

DN ER

Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 • Output Instruction

•

•

• Channel is the number of the RS-232 port (Channel 0). • Destination is the string element where you want the characters stored. • Control is the address of the control block used to store data for the ARD instruction. • String Length (.LEN) is 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 the first 82 characters will be read. (A 0 defaults to 82.) This is word 1 in the control block. • Characters Read (.POS) are the number of characters that the processor moved from the buffer to the string (0 to 82). This field is updated during the execution of the instruction and is display only. This is word 2 in the control block. • Error displays the hexadecimal error code that indicates why the ER bit was set in the control data file (R6). See page 10-24 for error code descriptions.

Example

When the rung goes from false-to-true, the Enable bit (EN) is set. When the instruction is placed in the ASCII queue, the Queue bit (EU) is set. The Running bit (IN) is set when the instruction is executing. The DN bit is set upon completion of the instruction. 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 POS field of the control block. The number in the Characters Read field is continuously updated and the Done bit (DN) is not set until all of the characters are read. When the program scans the instruction and finds the Done bit (DN) set, the processor then sets the Synchronous Done bit (EM). The EM bit acts as a secondary done bit corresponding to the program scan. Publication 1747-RM001G-EN-P - November 2008

Page 220

10-16

ASCII Instructions

The Error bit (ER) is set during the execution of the instruction if: • the instruction is aborted - serial port is not in User mode. • the modem is disconnected (control line selection is other than NO HANDSHAKING). • the instruction is aborted due to channel mode change. • the Unload bit (UL) is set. The instruction stops executing, but received characters are sent to the destination. • an ACL to clear the receive buffer is executed, removing the ARD instruction from the ASCII queue.

Timing Diagram for a Successful ARD, ARL, AWA, and AWT Instructions

Publication 1747-RM001G-EN-P - November 2008