Custom serial port message example – Rockwell Automation 5370-CUPK Color CVIM USER-PAK Option User Manual

Page 122

Advertising
background image

Chapter 8

Defining Strings for Serial Ports and Viewports

8 – 33

This section provides an example of a serial port message string, for the
purpose of demonstrating the use of string elements, and the definition of the

Event.

For this example, we want to transmit the results of the two gage
measurements, and also to transmit the results only if the inspection fails.

First, determine the format. Suppose we want the message transmitted in the
following format for use by a printer:

Results [space] [ gage 1 result ] [space] [ gage 2 result ] [CR ] [ LF]

where

[space]

is the space character,

[CR]

is the carriage return, and

[LF]

is

the line feed character. A string text entry which would transmit the above
content and format would be:

“Results ” g1(3) “ ” g2(3) n

The above string text would look like this on the keyboard display:

String entry display

Transmitted String:

Results 109 112 [CR] [LF]

Assuming these gage results for an inspection – Gage 1 = 109, Gage 2 = 112
– the resulting string, if transmitted, would be as shown above.

Now let’s look at the string elements to see how the message was created:

Literal Text – consists of any characters enclosed within a pair of quotes.
Two literal text entries in the string are

“Results ”

(which includes a

space after the word “Results”) and

“ ”

(which is a space enclosed in

quotes).

Results 109 112 [CR] [LF]

Note that, as a result of the spaces in the literal entries, spaces exist between
the transmitted “fields.”

Custom Serial Port
Message Example

Advertising