Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual

Page 197

Advertising
background image

API Library of Routines

Appendix B

DTL_READ_W

B-66

Description

Use the DTL_READ_W function to read data from a PLC-5
programmable controller that is directly connected to the
control coprocessor.

This function is synchronous. When this function is initiated, your
C application programs stops until the function completes or fails.

C Example

unsigned status;

unsigned machine1;

unsigned short parts1 [10];

unsigned iostat;

DTL_C_DEFINE (&machine1, “N20:36, 10, WORD, READ”);

status = DTL_READ_W (machine1, &parts1, &iostat)

if (status == DTL_SUCCESS)

{

printf (“parts = %d\n”, parts1 [0]);

}

else

{

(printf (“error %d, %d on read of parts data\n”,

status,

iostat);

}

BASIC Example

The BASIC function code is 5.

procedure COPRO

DIM status : INTEGER

DIM fred : INTEGER

DIM rcvbuff(10) : INTEGER

DIM iostat : INTEGER

.

.

.

rem * DTL_READ_W - Read from N10:2 10 words into rcvbuff

RUN AB_BAS (5, status, fred, ADDR(rcvbuff), ADDR(iostat))

.

.

.

References

DTL_C_DEFINE(); DTL_WRITE_W();

Advertising