Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 623
ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19
String To DINT (STOD)
The STOD instruction converts the ASCII representation of an integer to an
integer or REAL value.
Operands:
Relay Ladder
Structured Text
The operands are the same as those for the relay ladder STOD instruction.
Description: The STOD converts the Source to an integer and places the result in the
Destination.
· The instruction converts positive and negative numbers.
· If the Source string contains non-numeric characters, the STOD converts
the first set of contiguous numbers:
– The instruction skips 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 instruction converts only the first group
of numbers.
Arithmetic Status Flags: Arithmetic status flags are affected.
Fault Conditions
String To DINT
Source ?
??
Dest ?
??
STOD
Operand Type Format Enter Notes
Source String Tag Tag that contains the value in
ASCII
String data types are:
·default STRING data type.
·any new string data type that you create.
Destination SINT
INT
DINT
REAL
Tag Tag to store the integer value If the Source value is a floating-point number, the
instruction converts only the non-fractional part of
the number (regardless of the destination data type).
Type Code Cause Recovery Method
4 51 The LEN value of the string tag is greater than the DATA size
of the string tag.
1. Check that no instruction is writing to the LEN member of
the string tag.
2. In the LEN value, enter the number of characters that the
string contains.
4 53 The output number is beyond the limits of the destination data
type.
Either:
·Reduce the size of the ASCII value.
·Use a larger data type for the destination.