Programming example for dos, Programming example for dos -5 – Rockwell Automation 1747-PCIS API Software - Open Controller User Manual

Page 37

Advertising
background image

Publication 1747-UM002A-US-P - June 2000

Developing Applications 3-5

The application can change the behavior of the input and output
scans by allowing the application to have more control over I/O
scanning. The application can prevent the scanner from doing any
output scans and allow the application to read inputs and initialize
outputs before the scanner begins to write outputs. This mode allows
the application to pre-scan the inputs before the outputs are written.

The application can set the scanner to a conditional scan mode where
the scanner writes outputs at the next scan time after the application
writes data to the output image. In this mode, the scanner only writes
outputs each time the application writes data to the output image.

The application can also prevent output scans by the scanner and
have the scanner send a message after every input scan. The
application can detect an end-of-scan message and then read the
input image, perform logic, and write outputs using
OC_DemandOutputScan to force the scanner to write outputs
immediately. This lets the application synchronize its control loop
with the input and output scans.

The application can also disable both input and output scans. In this
mode, the scanner is a slave and input or output scans only take place
when requested by the host application.

Programming Example
for DOS

The following DOS example (

sample.c

on your API disk) shows

how to program the above steps. Callouts on the right margin identify
the code for each step.

/************************************************************************
*
*

FILE:

sample.c

*
*

PURPOSE:Sample application code for 1746 I/O PCI Interface API

*
*

SUMMARY:This program,

*

- Resets and initializes the scanner.

*

- Displays the scanner firmware and hardware versions.

*

- Autconfigures the I/O in chassis.

*

- Reads the front panel switch position and lights LED 1.

*

- Reads first discrete input module data word.

*

- Writes incremental data to first output module data word.

*

- Closes connection to scanner and exits.

*
*

ENVIRONMENT:

1747-PCIS 1746 I/O PCI Interface

*

MS-DOS

*

Borland/Microsoft C/C++ Compiler (16-bit)

*
************************************************************************/

Advertising
This manual is related to the following products: