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

The text of a manual · part 23 of 70

SLC 500 Instruction Set Reference Manual, pages 221 to 230

Pages 221 to 230 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 221

ASCII Instructions

10-17

Use the ARL instruction to read characters from the buffer, up to and including the end-of-line (termination) characters, and store them in a string. The end-of-line characters are specified via the ASCII Configuration screen.

ASCII Read Line (ARL)

Entering Parameters ARL ASCII Read Line Channel Dest Control String Length Characters Read Error

EN 0 ST10:8 R6:6 16< 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 ARL 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 are read and moved to the destination. (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 display only and resides in word 2 of 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 control element Enable (EN) bit 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 either the end of line character(s) are received or, the requested number of 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 POS word of the control block. The number in the Characters Read field is continuously updated and the Done bit (DN) is not set until either the end of line character(s) are received or, all of the characters have been read.

Publication 1747-RM001G-EN-P - November 2008

Page 222

10-18

ASCII Instructions

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. 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 (when 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 ARL instruction from the ASCII queue.

TIP

For information on the timing of this instruction, refer to the timing diagram on page 10-16.

Use the ASC instruction to search an existing string for an occurrence of the source string.

String Search (ASC)

Entering Parameters ASC String Search Source Index String Search Result

ST10:9 22 ST10:10 N7:99 0<

Enter the following parameters when programming this instructio.:

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

• Source is the string you want to find when examining the search string. • Index is the starting position (from 1 to 82) of the portion of the string you want to find. (An index of 1 indicates the left-most character of the string.) • String Search is the string you want to examine. • Result is an integer where the processor stores the position of the search string where the source string begins. If no match is found, result is set equal to zero.

Page 223

ASCII Instructions

10-19

Example

The following conditions cause the processor to set the ASCII Error bit (S:5/15). • Invalid string length or string length of zero • Index value outside of range • Index value greater than the length of the source string The destination is not changed in any of the above conditions.

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

Entering Parameters ASR ASCII String Compare Source A ST10:8 Source B ST10:9

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 string one for comparison. • Source B is string two for comparison.

•

Input Instruction

Example

An invalid string length causes the processor to set ASCII Error bit S:5/15, and the rung goes false.

Publication 1747-RM001G-EN-P - November 2008

Page 224

10-20

ASCII Instructions

ASCII Write with Append (AWA)

Use the AWA instruction to write characters from a source string to an external device. This instruction adds the one or two appended characters that you configure on the ASCII Configuration screen. The default is a carriage return and line feed appended to the end of the string. When using this instruction you can also perform in-line indirection. See page 10-21 for more information.

Entering Parameters AWA ASCII Write Append Channel 0 Source ST10:11 Control R6:7 String Length 3< Characters Sent 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). • Source is the string element you want to write. • Control is the area that stores the control register required to operate the instruction. • String Length (.LEN) is the number of characters you want to write from the source string (0 to 82). If you enter a 0, the entire string will be written. This is word 1 in the control block. • Characters Sent (.POS) are the number of characters that the processor sent to the display area (0 to 82). This field is continuously updated during the execution of the instruction. This value can be greater than the string length if appended characters or inserted values from in-line indirection are used. If the string length is greater than 82, the string written to the destination is truncated to 82 characters. 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 control element Enable (EN) bit 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 on completion of the instruction. The system sends 25 characters from the start of string ST37:42 to the display device and then sends user-configured append characters. The Done bit (DN) is set and a value of 27 is present in .POS word of the ASCII control block.

Publication 1747-RM001G-EN-P - November 2008

Page 225

ASCII Instructions

10-21

When the program scans the instruction and finds the Done bit (DN) set, the processor then sets the Synchronous Done bit (EM) to act as a secondary done bit corresponding to the program scan. The Error bit (ER) is set during execution of the instruction if: • the modem is disconnected (control line selection is other than NO HANDSHAKING). • port is in System Mode and is configured for DH-485 or DF1 Radio Modem. • the Unload bit (UL) is set. The instruction stops executing, but received characters are sent to the destination. • an ACL to clear the send buffer is executed, removing the AWA instruction from the ASCII queue.

TIP

For information on the timing of this instruction, refer to the timing diagram on page 10-16.

Using Inline Indirection This allows you to insert integer and floating point values into ASCII strings. The Running bit (IN) must be set before the string value can be used. The following conditions apply to performing in-line indirection. • All valid integer (N) and floating point (F) files can be used. Valid ranges include 7, 8, and 9-255 • file types are not case sensitive and can include either a colon (:) or semicolon (;) • positive values and leading zeros are not printed. Negative values are printed with a leading minus sign

Publication 1747-RM001G-EN-P - November 2008

Page 226

10-22

ASCII Instructions

Examples For the following examples: N7:0 = 250 N7:1 = -37 F8:0 = 2.015000 F8:1 = 0.873000

Valid in-line direction: Input:

Flow rate is currently [N7:0] GPH and contains [F8:0] PPM contaminants.

Output:

Flow rate is currently 250 GPH and contains 2.015000 PPM contaminants.

Input:

Current position is [N7:1] at a speed of [F8:1] RPM.

Output:

Current position is -37 at a speed of 0.873000 RPM.

Invalid in-line indirection: Input:

Current position is [N5:1] at a speed of [F8:1] RPM.

Output:

Current position is [N5:1] at a speed of 0.873000 RPM.

TIP

Truncation occurs in the output string if the indirection causes the output to exceed 80 characters. The appended characters are always applied to the output.

Use the AWT instruction to write characters from a source string to an external device. To repeat the instruction, the rung must go from false-to-true. When using this instruction you can also perform in-line indirection. See page 10-21 for more information.

ASCII Write (AWT)

Entering Parameters AWT ASCII Write Channel Source Control String Length Characters Sent Error

EN 0 ST10:12 R6:8 12< 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

Publication 1747-RM001G-EN-P - November 2008

• Channel is the number of the RS-232 port (Channel 0). • Source is the string element you want to write. • Control is the area that stores the control register required to operate the instruction. • String Length (LEN) is the number of characters you want to write from the source string (0 to 82). If you enter a 0, the entire string will be written.

Page 227

ASCII Instructions

10-23

• Characters Sent (POS) is 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 is stored). This field is display only. This value can be greater than the string length if inserted values from in-line indirection are used. If the string length is greater than 82, the string written to the destination is truncated to 82 characters. • 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 control element Enable (EN) bit 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 on completion of the instruction. Forty characters from string ST37:40 are sent through channel 0. The Done bit (DN) is set and a value of 40 is present in the POS word of the ASCII control block. When the program scans the instruction and finds the Done bit (DN) set, the processor then sets the Synchronous Done bit (EM) to act as a secondary done bit corresponding to the program scan. The Error bit (ER) is set during execution of the instruction if: • the modem is disconnected (control line selection is other than “NO HANDSHAKING”). • port is in System Mode and is configured for DH-485 or DF1 Radio Modem. • the Unload bit (UL) is set. The instruction stops executing, but received characters are sent to the destination. • an ACL to clear the transmit buffer is executed, removing the AWT instruction from the ASCII queue. TIP

For information on the timing of this instruction, refer to the timing diagram on page 10-16.

Publication 1747-RM001G-EN-P - November 2008

Page 228

10-24

ASCII Instructions

ASCII Instruction Error Codes

The following error codes indicate why the Error bit (ER) is set in the control data file (R6).

Table 10.8 ASCII Error Codes Error Code (HEX)

Conditions Resulting in the Setting of the ER Bit

Recommended Action

00

No error. The instruction completed successfully.

None required.

02

Operation cannot be completed because the modem went offline.

Check modem cabling to communication channel. If the channel is configured for modem handshaking, both the DCD (Data-Carrier-Detect) and DSR (Data-Set-Ready) lines to the channel must be active for the modem to be online.

03

Transmission cannot be completed because the Clear-to-Send signal was lost.

Check modem and modem cabling connections.

04

Cannot perform ASCII receives because the communication channel is configured for System Mode.

Reconfigure the communication channel for User Mode.

05

While attempting to perform ASCII transmission, System Mode (DF1) communication was detected.

Verify that the modem is online and communicating with required devices.

07

Cannot perform ASCII send or receive because channel configuration has been shut down via the channel configuration menu.

Reconfigure the channel configuration menu and retry operation.

08

Cannot perform ASCII write due to an ASCII transmission already in progress.

Resend the transmission.

09

ASCII communication requested is not supported by current channel configuration. (Channel 0 is configured for DH-485 or DF1 Radio Modem while trying to initiate an ASCII transmission or modem handshake control.)

Configure channel 0 for DF1 Full-duplex, DF1 Half-duplex Master, or DF1 Half-duplex Slave.

0A

The Unload bit (UL) was set, stopping instruction execution.

None required.

0B

The requested length for the string is either a negative number or greater than 82. Applies to ARD and ARL instructions.

Enter a valid string length and retry operation.

0C

The length of the source string is either a negative number or greater than 82. Applies to AWA and AWT instructions.

Enter a valid string length and retry operation.

0D

The requested length (.LEN) in the control block is a negative number or a value greater than 82. Applies to AWA and AWT instructions.

Enter a valid length and retry operation.

0E

The ACL instruction was aborted.

None required.

0F

The channel configuration mode was changed.

None required.

Publication 1747-RM001G-EN-P - November 2008

Page 229

ASCII Instructions

ASCII Conversion Table

10-25

The table below lists the decimal, hexadecimal, and ASCII conversions.

Table 10.9 ASCII Conversion Table ASCII

Hex

Decimal

Enter as

Displayed as

NUL

00

0

\00

\00

SOH

01

1

^A or ^a or \01

^A

STX

02

2

^B or ^b or \02

^B

ETX

03

3

^C or ^c or \03

^C

EOT

04

4

^D or ^d or \04

^D

ENQ

05

5

^E or ^e or \05

^E

ACK

06

6

^F or ^f or \06

^F

BEL

07

7

^G or ^g or \07

^G

BS

08

8

^H or ^h or \08

^H

HT

09

9

^I or ^i or \09

^I

LF

0A

10

^J or ^j or \0A or \0a

^J

VT

0B

11

^K or ^k or \0B or \0b

^K

FF

0C

12

^L or ^l or \0C or \0c

^L

CR

0D

13

^M or ^m or \0D or \0d

^M

SOH

0E

14

^N or ^n or \0E or \0e

^N

SI

0F

15

^O or ^o or \0F or \0f

^O

DLE

10

16

^P or ^p or \10

^P

DC1

11

17

^Q or ^q or \11

^Q

DC2

12

18

^R or ^r or \12

^R

DC3

13

19

^S or ^s or \13

^S

DC4

14

20

^T or ^t or \14

^T

HAK

15

21

^U or ^u or \15

^U

SYN

16

22

^V or ^v or \16

^V

ETB

17

23

^W or ^w or \17

^W

CAN

18

24

^X or ^x or \18

^X

EM

19

25

^Y or ^y or \19

^Y

SUB

1A

26

^Z or ^z or \1A or \1a

^Z

ESC

1B

27

\1B or \1b

\1B

FS

1C

28

\1C or \1c

\1C

GS

1D

29

\1D or \1d

\1D

RS

1E

30

\1E or \1e

\1E

US

1F

31

\1F or \1f

\1F

SP

20

32

\20

Publication 1747-RM001G-EN-P - November 2008

Page 230

10-26

ASCII Instructions

Table 10.9 ASCII Conversion Table (Continued) ASCII

Hex

Decimal

Enter as

Displayed as

!

21

33

! or \21

!

““““

22

34

“““ or \22”

““““

#

23

35

# or \23

#

$

24

36

$ or \24

$

%

25

37

% or \25

%

&

26

38

& or \26

&

‘

27

39

‘ or \27

‘

(

28

40

( or \28

(

)

29

41

) or \29

)

*

2A

42

* or \2A or \2a

*

+

2B

43

+ or \2B or \2b

+

,

2C

44

, or \2C or \2c

,

-

2D

45

- or \2D or \2d

-

.

2E

46

. or \2E or \2e

.

/

2F

47

/ or \2F or \2f

/

0

30

48

0 or \30

0

1

31

49

1 or \31

1

2

32

50

2 or \32

2

3

33

51

3 or \33

3

4

34

52

4 or \34

4

5

35

53

5 or \35

5

6

36

54

6 or \36

6

7

37

55

7 or \37

7

8

38

56

8 or \38

8

9

39

57

9 or \39

9

:

3A

58

: or \3A or \3a

:

;

3B

59

; or \3B or \3b

;

<

3C

60

< or \3C or \3c

<

=

3D

61

= or \3D or \3d

=

>

3E

62

> or \3E or \3e

>

?

3F

63

? or \3F or \3f

?

@

40

64

@ or \40

@

A

41

65

A or \41

A

B

42

66

B or \42

B

C

43

67

C or \43

C

D

44

68

D or \44

D

Publication 1747-RM001G-EN-P - November 2008