Explanation of ascii programming example – Rockwell Automation 5370 Color CVIM Communications Manual User Manual

Page 97

Advertising
background image

Chapter 5
Using the RS–232 Ports

5–29

The following sample program (called CCVIMASC.BAS) was written on an
Allen–Bradley 1784–T47 terminal using GW BASIC. This program obtains
and processes discrete results from the Color CVIM module. The program
will:

Read the trigger count.

Trigger an inspection.

Detect when new data is available.

Read discrete results part 1.

Display discrete results part 1.

Display a screen message if any of the first four windows fail.

A basic outline of the program is as follows:

Lines 10 to 99

Program identification and related information.
Initialize program variables, configure the RS–232 port
for 8 bit transmissions, select no parity, select 9600
Baud, and initialize the display monitor.

Lines 100 to 120

Prompt user to run program or exit.

Subroutine 2000

Reads results to find the current number of total triggers.

Subroutine 1000

Triggers the Color CVIM module inspection.

Line 200

Causes a continuous read of Color CVIM module block
1 results until new results are detected. New results are
detected by an incrementing of the “total trigger” data.

Subroutine 2500

Converts the Color CVIM module results from
hexadecimal to integer.

Lines 240 to 270

Analyze the discrete fail bits for windows 1 through 4
and display a message if a failure is detected.

Line 400

Sends the program to input line 100.

The program manipulates the returned data as follows:

Explanation of ASCII
Programming Example

Advertising