Convert a value – Rockwell Automation Logix5000 Controllers ASCII Strings Programming Manual User Manual

Page 24

Advertising
background image

Chapter 2

Processing ASCII characters

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

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.

The following rung converts ASCII characters to an integer value:

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 ( \ ).

Convert a value

24

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

Advertising