Read characters from the device – Rockwell Automation Logix5000 Controllers ASCII Strings Programming Manual User Manual

Page 14

Advertising
background image

Chapter 1 Communicating with an ASCII device

1. In the Controller Organizer, right-click Strings and choose New String

Type.

2. In the Name box, type the name for the data type.

3. In the Maximum Characters box, type the maximum number of characters

that the string data type stores.

4. Click OK.

As a general rule, before you read the buffer, use an ACB or ABL instruction to

verify that the buffer contains the required characters.

An ARD or ARL instruction continues to read the buffer until the

instruction reads the required characters.

While an ARD or ARL instruction reads the buffer, no other ASCII Serial

Port instructions, except the ACL, can execute.

Verifying that the buffer contains the required characters prevents the ARD

or ARL from holding up the execution of other ASCII Serial Port

instructions while the input device sends its data.

For additional information on ASCII Serial Port instructions, see

Logix5000

Controllers General Instruction Set Reference Manual

.

In the following example, the device sends a fixed number of characters, such as a

bar code reader:

Example:

A bar code reader sends bar codes to the serial port (channel 0) of the controller. Each bar code contains 24 characters. To determine
when the controller receives a bar code, the ACB instruction continuously counts the characters in the buffer.

When the buffer contains at least 24 characters, the controller received a bar code. The ARD instruction moves the bar code to the
bag_bar_code tag.

Read characters from the

device

14

Rockwell Automation Publication 1756-PM013D-EN-P - October 2014

Advertising