Rockwell Automation 5370-CUPK Color CVIM USER-PAK Option User Manual

Page 101

Advertising
background image

Chapter 8

Defining Strings for Serial Ports and Viewports

8 – 12

Field Formatting Codes

You can, at your option, specify the format of the contents of any numerical
field, that is, fields in the displayed or transmitted strings which correspond
either to tool results (or other data), or to the index (#) number. You specify
field format by placing a field formatting code in parentheses immediately
following the data code (or index character) in the string you are defining.

In defining the format, you can simply specify the “field width,” which limits
the number of places a field will occupy in the serial message (the default
format is 9 places). Or, you can further define the format by also specifying
other characteristics, such as limiting the number of decimal places used (for
floating point results only), or specifying left justification of data within the
field.

For instance, within a serial port string, the data code

G1

will transmit the

result of the gage 1; the transmitted field will, by default, be 9 places in
width. However, entering the code

G1(3)

, where

(3)

is the format code,

transmits the result of the gage 1, and limits the field for that result to three
places in the serial message.

Likewise, within a viewport string, the data code

G1

will display the result of

the gage 1; the displayed field will, by default, be 9 places in width.
However, entering the code

G1(3)

, where

(3)

is the format code, displays

the result of the gage 1, and limits the field for that result to three places in
the viewport display.

For example: Assume the gage 1 result = 34

This code

transmits (or displays) this field :

G1

_ _ _ _ _ _ _ 34 (where “_ ” represents one space character)

G1(3)

_ 34

The field formatting code options are described in following pages, along
with examples for each option.

Field Formatting Codes:

(x)

where

x

is a number 0-40, specifies the “field width.” That is, the

field will contain

x

number of places. Note that, in specifying the field

width:

Results exceeding the specified field width are truncated from the right.

The maximum field width of any given field is 40; specifying a higher
number for the field width will result in a field width of 40 places.

Any unused places are left as spaces preceding the value in the field (that
is, the field contents are right justified within the field), if no other
specifications are defined for the format.

Advertising