Logix 5000 Controllers ASCII Strings: Programming Manual
Logix 5000 Controllers ASCII Strings: Programming Manual
Strings
1756 ControlLogix, 1756 GuardLogix, 1769 CompactLogix,
1769 Compact GuardLogix, 1789 SoftLogix, 5069
CompactLogix, 5069 Compact GuardLogix, Studio 5000
Logix Emulate
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.
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).
Global changes
This table identifies changes that apply to all information about a subject in
the manual and the reason for the change. For example, the addition of new
supported hardware, a software design change, or additional reference
material would result in changes to all of the topics that deal with that subject.
This table identifies changes that apply to all information about a subject in
the manual and the reason for the change. For example, the addition of new
supported hardware, a software design change, or additional reference
material would result in changes to all of the topics that deal with that subject.
Change Topic
Updated Legal notices. Legal Notices on page 8
Chapter 1
Communicating with an Introduction ................................................................................................ 9
ASCII device Connect the ASCII device........................................................................... 9
Configure the Serial Port ..........................................................................10
Configure the User Protocol ...................................................................... 12
Create string data types ............................................................................. 13
Read characters from the device ............................................................... 14
Send characters to the device .................................................................... 15
Enter ASCII characters .............................................................................. 16
Chapter 2
Processing ASCII characters Introduction ............................................................................................... 19
Extract a part of a Bar Code ...................................................................... 19
Look up a Bar Code..................................................................................... 19
Create the PRODUCT_INFO Data Type ............................................ 20
Search for the characters ..................................................................... 21
Identify the Lane Number ................................................................... 21
Reject bad characters .......................................................................... 22
Enter the Product IDs and Lane Numbers........................................ 22
Check the Bar Code characters................................................................. 22
Convert a value ...........................................................................................23
Decode an ASCII message ........................................................................ 24
Build a string ............................................................................................. 25
Appendix A
ASCII character codes ASCII character codes .............................................................................. 27
Index
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 Logix 5000™ controllers for discrete, process,
batch, motion, safety, and drive-based solutions.
Legal Notices Rockwell Automation publishes legal notices, such as privacy policies, license
agreements, trademark disclosures, and other terms and conditions on
the Legal Notices page of the Rockwell Automation website.
Introduction You can exchange ASCII data with a device through the serial port of the
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
Logix 5000 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.
2. Connect sending pins to corresponding receiving pins and attach
jumpers.
Do not handshake
2. On the Controller Properties dialog box, click the Serial Port tab.
• 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 ---------------------------------------------------------------> No Handshaking
modem
You are using a modem Modems in a point-to-point -----------------------------> Full Duplex
link are full-duplex
Master modem is full-duplex master controller. Full Duplex
while slave modem is half-
slave controller Half Duplex Select the Continuous Carrier check
duplex
box.
All modems in the system are -----------------------------> Half Duplex Clear the Continuous Carrier check
half-duplex box (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.
2. Click OK.
Create string data types Store ASCII characters in tags that use a string data type.
You can use the default STRING data type. It or You can create a string data type to store the number
stores up to 82 characters. 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.
3. In the Maximum Characters box, enter the maximum number of
characters that the string data type stores.
4. Select OK.
Read characters As a general rule, before you read the buffer, use an ACB or ABL instruction to
verify that the buffer contains the required characters.
from the 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.
For additional information on ASCII Serial Port instructions, see Logix 5000
Controllers General Instruction Set Reference
Manual http://literature.rockwellautomation.com/idc/groups/literature/documents/rm
/1756-rm003_-en-p.pdf.
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.
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 When you send characters to the device, you must determine either to send
the same number of characters each time or to append terminations
to the device characters to the 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.
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.
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.
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.
Airline Origin Flight # Destination Date
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
Create the PRODUCT_INFO To create a Product_Info user-defined date type in the Controller Organizer,
right-click User-Defined and click New Data Type. Configure the user-
Data Type defined data type as follows.
Data Type: PRODUCT_INFO
Name PRODUCT_INFO
Description Identifies the destination for an item based on an ASCII string of characters that
identify the item
Members
Name Data Type Style Description
Product_ID STRING ASCII characters that identify the item
Lane DINT Decimal Destination for the item, based on its ID
Search for the characters You can search for characters by creating the following ladder logic routine.
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.
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.
Enter the Product IDs In the sort_table array, enter the ASCII characters to identify each item and
the corresponding lane number for the item.
and Lane Numbers
Check the Bar Use a compare instruction (EQU, GEQ, GRT, LEQ, LES, NEQ) to check for
characters.
Code 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.
EXAMPL When bag_flt_and_dest is equal to gate[1], xfer[1] turns on. This routes the bag to the required gate.
E
Convert a value You can convert the ASCII representation of a value to an DINT or REAL 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).
• If the string contains multiple groups of numbers that are separated by
delimiters (for example, / ), the STOD and STOR instructions convert
only the first group of numbers.
The following rung converts ASCII characters to a floating-point value:
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.
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:
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:
IMPORTANT To send the message, an AWA instruction sends the msg tag and appends the
carriage return [CR].
Index send
ASCII characters 15
serial
configure port for ASCII 10
string
A data type 13
enter characters 16
ASCII manipulate 19
configure serial port 10 organize data 13
configure user protocol 12 read characters 14
enter characters 16 write characters 15
manipulate characters 19 string data type
organize data 13
create 13
read characters 14
write characters 15 T
C tag
string 13
configure
serial port for ASCII 10 U
user protocol for ASCII 12
create user protocol
string data type 13 configure for ASCII 12
D W
data write
ASCII 13 ASCII characters 15
enter ASCII characters 16
E
enter
ASCII characters 16
M
manipulate string 19
O
organize
strings 13
R
read
ASCII characters 14
Literature Library Find installation instructions, manuals, brochures, and technical data publications. rok.auto/literature
Product Compatibility and Download Center Get help determining how products interact, check features and capabilities, and rok.auto/pcdc
(PCDC) find associated firmware.
Documentation feedback
Your comments help us serve your documentation needs better. If you have any suggestions on how to improve our content, complete the form
at rok.auto/docfeedback.
Rockwell Automation maintains current product environmental information on its website at rok.auto/pec.
Allen-Bradley, expanding human possibility, Logix, Rockwell Automation, and Rockwell Software are trademarks of Rockwell Automation, Inc.
Trademarks not belonging to Rockwell Automation are property of their respective companies.
Rockwell Otomayson Ticaret A.Ş. Kar Plaza İş Merkezi E Blok Kat:6 34752, İçerenkÖy, İstanbul, Tel: +90 (216) 5698400 EEE YÖnetmeliğine Uygundur