Logix5000 Controllers ASCII Strings: Programming Manual
Logix5000 Controllers ASCII Strings: Programming Manual
Logix5000 Controllers ASCII Strings: Programming Manual
Activities including installation, adjustments, putting into service, use, assembly, disassembly, and maintenance are required to be
carried out by suitably trained personnel in accordance with applicable code of practice. If this equipment is used in a manner not
specified by the manufacturer, the protection provided by the equipment may be impaired.
In no event will Rockwell Automation, Inc. be responsible or liable for indirect or consequential damages resulting from the use or
application of this equipment.
The examples and diagrams in this manual are included solely for illustrative purposes. Because of the many variables and
requirements associated with any particular installation, Rockwell Automation, Inc. cannot assume responsibility or liability for
actual use based on the examples and diagrams.
No patent liability is assumed by Rockwell Automation, Inc. with respect to use of information, circuits, equipment, or software
described in this manual.
Reproduction of the contents of this manual, in whole or in part, without written permission of Rockwell Automation, Inc., is
prohibited.
Throughout this manual, when necessary, we use notes to make you aware of safety considerations.
WARNING: Identifies information about practices or circumstances that can cause an explosion in a hazardous environment, which may lead to
personal injury or death, property damage, or economic loss.
ATTENTION: Identifies information about practices or circumstances that can lead to personal injury or death, property damage, or economic
loss. Attentions help you identify a hazard, avoid a hazard, and recognize the consequence
Important: Identifies information that is critical for successful application and understanding of the product.
SHOCK HAZARD: Labels may be on or inside the equipment, for example, a drive or motor, to alert people that dangerous voltage may be
present.
BURN HAZARD: Labels may be on or inside the equipment, for example, a drive or motor, to alert people that surfaces may reach dangerous
temperatures.
ARC FLASH HAZARD: Labels may be on or inside the equipment, for example, a motor control center, to alert people to potential Arc Flash. Arc
Flash will cause severe injury or death. Wear proper Personal Protective Equipment (PPE). Follow ALL Regulatory requirements for safe work
practices and for Personal Protective Equipment (PPE).
Allen-Bradley, Rockwell Software, Rockwell Automation, and TechConnect are trademarks of Rockwell Automation, Inc.
Trademarks not belonging to Rockwell Automation are property of their respective companies.
Summary of changes
This manual contains new and updated information. Changes to this manual are
documented in the following table.
Change Topic
Updated the list of supported controllers. Cover
Chapter 1
Chapter 2
Appendix A
The term Logix5000 controller refers to any controller that is based on the
Logix5000 operating system.
Studio 5000 environment The Studio 5000 Automation Engineering & Design Environment™ combines
engineering and design elements into a common environment. The first element is
the Studio 5000 Logix Designer™ application. The Logix Designer application is
the rebranding of RSLogix™ 5000 software and will continue to be the product to
program Logix5000™ controllers for discrete, process, batch, motion, safety, and
drive-based solutions.
Resource Description
Industrial Automation Wiring and Grounding Guidelines , Provides general guidelines for installing a Rockwell
publication 1770-4.1 Automation industrial system.
Resource Description
Product Certifications webpage, available at Provides declarations of conformity, certificates, and other
http://ab.rockwellautomation.com certification details.
You can exchange ASCII data with a device through the serial port of the
Introduction
controller. For example, you can use the serial port to:
• Read ASCII characters from a weigh scale module or bar code reader.
• Send and receive messages from an ASCII triggered device, such as a
MessageView terminal.
Firmware revision 3.1 and later of the 1756-EWEB EtherNet/IP Web Server
module supports the controller serial port and a socket interface that lets
Logix5000 controllers exchange ASCII data using TCP or UDP socket services.
Connect the ASCII device To connect to the ASCII device, use these steps.
1. On the serial port of the ASCII device, determine which pins send signals
and which pins receive signals.
Do not handshake
Configure the Serial Port To configure the serial port, use these steps.
2. On the Controller Properties dialog box, click the Serial Port tab.
3. On the Mode menu, choose User and type the configuration settings for
the serial port.
• Choose the baud rate, data bits, parity, and stop bits.
• In the Control Line menu, choose the Control Line option:
If And And this is the Choose Then
You are not using a modem ---------------------------------------------------------------> No Handshaking
You are using a modem Modems in a point-to-point link -----------------------------> Full Duplex
are full-duplex
Master modem is full-duplex master controller. Full Duplex
while slave modem is half-duplex
slave controller Half Duplex Select the Continuous Carrier check box.
All modems in the system are -----------------------------> Half Duplex Clear the Continuous Carrier check box
half-duplex (default).
• In the RTS Send Delay box, type the delay (in 20 ms units) between
the time the RTS signal turns on (high) and the time that data is sent.
For example, a value of 4 produces an 80 ms delay.
• In the RTS Off Delay box, type the delay (in 20 ms units) between the
time the last character is sent and the time that the RTS signal turns off
(low).
4. Click Apply.
Configure the User Protocol To configure the user protocol, use these steps.
1. In the Controller Properties dialog box, click the User Protocol tab.
Two termination characters In the Termination Character 1 and 2 boxes, type the
hexadecimal ASCII code for each character.
• For AWA instruction, enter append characters. For ASCII codes, see
ASCII Character Codes on page 29.
2. Click OK.
You can use the default STRING data or You can create a string data type to store the
type. It stores up to 82 characters. number of characters that you define.
Important: Use caution when you create a string data type. If you decide later to change the size of the
string data type, you may lose data in any tags that currently use that data type.
If you Then
Make a string data type smaller • The data truncates.
• The LEN does not change.
Make a string data type larger The data and LEN resets to zero.
2. In the Name box, type the name for the data type.
4. Click OK.
Read characters from the As a general rule, before you read the buffer, use an ACB or ABL instruction to
verify that the buffer contains the required characters.
device
• 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.
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.
In the following example, the device sends a variable number of characters, such as
a message or display terminal.
When the ABL instruction finds the carriage return (MV_line.FD is set), the controller removes the characters from the buffer, up to and
including the carriage return, and places them in the MV_msg tag.
Send characters to the When you send characters to the device, you must determine either to send the
same number of characters each time or to append terminations characters to the
device data.
In the following example, you always send the same number of characters and
want to automatically append one or two characters to the end of the data.
Example: When the temperature exceeds the high limit (temp_high is on), the AWA instruction sends five
characters from the string[1] tag to a MessageView terminal.
• The $14 counts as one character. The hex code for the Ctrl-T character.
• The instruction also sends (appends) the characters defined in the user protocol. In this example,
the AWA instruction sends a carriage return ($0D), which marks the end of the message.
Example: When the temperature reaches the low limit (temp_low is on), the AWT instruction sends nine
characters from the string[2] tag to a MessageView terminal. (The $14 counts as one character. The
hex code for the Ctrl-T character.)
In the following example, you send a different number of characters each time and
want to automatically append one or two characters to the end of the data:
Example: When alarm is on, the AWA instruction sends the characters in alarm_msg and appends a
termination character.
• Because the number of characters in alarm_msg varies, the rung first moves the length of
alarm_msg (alarm_msg.LEN) to the length of the AWA instruction (alarm_write.LEN).
• In alarm_msg, the $14 counts as one character. The hex code for the Ctrl-T character.
Example: When MV_update is on, the AWT instruction sends the characters in MV_msg.
• Because the number of characters in MV_msg varies, the rung first moves the length of MV_msg
(MV_msg.LEN) to the length of the AWT instruction (MV_write.LEN).
• In MV_msg, the $16 counts as one character. The hex code for the Ctrl-V character.
Enter ASCII characters To enter the ASCII characters, use these steps.
Important: This String Browser window shows the characters up to the value of the LEN member of the string
tag. The string tag may contain additional data, which the String Browser window does not show.
Line feed ($0A) The number of characters that you see in the
window. The same as the LEN member of the
string tag.
New line ($0D$0A) The maximum number of characters that the
string tag can hold.
Form feed ($0C)
3. Click OK.
Extract a part of a Bar Code For example, a bar code may contain information about a bag on a conveyor at an
airport. To check the flight number and destination of the bag, you extract
characters 10 - 18.
Bar code N W A H O P 5 0 5 8 A M S 0 2 2 2 0 1
Character number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
5 0 5 8 A M S
9 characters
Example: In the baggage handling conveyor of an airport, each bag gets a bar code. Characters 10 - 18 of the
bar code are the flight number and destination airport of the bag. After the bar code is read
(bag_read.EM is on) the MID instruction copies the flight number and destination airport to the
bag_flt_and_dest tag.
Look up a Bar Code For example, in a sorting operation, an array of a user-defined data type creates a
table that shows the lane number for each type of product. To determine which
lane to route a product, the controller searches the table for the product ID
(characters of the bar code that identify the product).
The FSC instruction searches each Product_ID member in the sort_table array
until the instruction finds a match to the product_id tag.
When the FSC instruction finds the product ID within the sort_table array, the
instruction sets the FD bit. The POS member indicates the element number
within the sort_table array of the match. The corresponding LANE member
indicates the lane number of the match.
Based on the POS value, the MOV instruction moves the corresponding lane
number into the lane tag. The controller uses the value of this tag to route the
item.
After the MOV instruction sets the value of the lane tag, the RES instruction
resets the FSC instruction so it can search for the next product ID.
If the FSC instruction does not find the product ID within the sort_table array,
the instruction sets the DN bit. The MOV instruction moves 999 into the lane tag
to notify the controller to reject or reroute the item.
After the MOV instruction sets the value of the lane tag, the RES instruction
resets the FSC instruction so it can search for the next product ID.
Use a compare instruction (EQU, GEQ, GRT, LEQ, LES, NEQ) to check for
Check the Bar Code
characters.
characters
• The hexadecimal values of the characters determine if one string is less than
or greater than another string.
• When the two strings are sorted, as in a telephone directory, the order of the
strings determines which one is greater.
Example: When bag_flt_and_dest is equal to gate[1], xfer[1] turns on. This routes the bag to the required gate.
You can convert the ASCII representation of a value to an DINT or REAL value
Convert a value that you can use in your application.
• The STOD and STOR instructions skip any initial control or non-numeric
characters (except the minus sign in front of a number).
Example: After reading the weight from the scale (weight_read.EM is on), the STOR instruction converts the
numeric characters in weight_ascii to a REAL value and stores the result in weight.
Example: When MV_read.EM is on, the STOD instruction converts the first set of numeric characters in MV_msg to
an integer value. The instruction skips the initial control character ($06) and stops at the delimiter ( \ ).
Decode an ASCII message You can extract and convert a value from an ASCII message that contains
multiple values. A message may look like the following example:
The MID instruction identifies a group of characters within a string and places
them in their own string tag.
• The source is the same string tag as for the FIND instruction.
• The quantity values tells the MID instruction how many characters to pull
from the source.
• The start value is the same as the Result value from the FIND instruction.
This tells the MID instruction where to start pulling characters from the
Source.
• The Destination contains the characters you located.
Build a string The following example builds a string that contains two variables. For example, an
operator terminal may require a string that looks like the following:
A
S
ASCII
configure serial port 12 send
configure user protocol 13 ASCII characters 17
enter characters 19 serial
manipulate characters 21 configure port for ASCII 12
organize data 15 string
read characters 16 data type 15
write characters 17 enter characters 19
manipulate 21
organize data 15
C read characters 16
configure write characters 17
serial port for ASCII 12 string data type
user protocol for ASCII 13 create 15
create
string data type 15
T
tag
D string 15
data
ASCII 15
U
enter ASCII characters 19
user protocol
configure for ASCII 13
E
enter
W
ASCII characters 19
write
ASCII characters 17
M
manipulate string 21
O
organize
strings 15
R
read
ASCII characters 16
In addition, we offer multiple support programs for installation, configuration, and troubleshooting. For more information, contact
your local distributor or Rockwell Automation representative, or visit http://www.rockwellautomation.com/services/online-phone.
Installation assistance
If you experience a problem within the first 24 hours of installation, review the information that is contained in this manual. You can
contact Customer Support for initial help in getting your product up and running.
United States Contact your distributor. You must provide a Customer Support case number (call the phone number above to obtain one) to
your distributor to complete the return process.
Outside United States Please contact your local Rockwell Automation representative for the return procedure.
Documentation feedback
Your comments will help us serve your documentation needs better. If you have any suggestions on how to improve this document,
complete the feedback form, publication RA-DU002.
Supersedes Publication 1756-PM013D-EN-P - October 2014 Copyright © 2016 Rockwell Automation, Inc. All rights reserved. Printed in the U.S.A.