Appendix b – Rockwell Automation 1785-Vx0B, D17856.5.9 PLC-5 VME VMEbus Programmable Controllers User Manual User Manual

Page 167

Advertising
background image

Sample API Modules

Appendix B

B-9

/*****************************************************************************
*
* PURPOSE: This function will read a PLC-5/40V’s A16 configuration and
* control register.
*
* INPUT: UWORD baseAddress will contain the base address of the
* PLC-5/40V.
*
* PLC540V_REGISTER_TYPE targetRegister will contain the
* particular PLC-5/40V register that will be read.
*
* OUTPUT: UWORD *registerValue will contain the value read from the
* specified target register.
*
* PLC540V_STATUS_TYPE *status will contain the final status
* of requesting this function. This status could be and EPC
* or PLC-5/40V value.
*
* RETURNS: Nothing.
*
* EXAMPLE:
* UWORD *regValue;
* PLC540V_STATUS_TYPE status;
* read_plc540v_register(0x0FC00,
* kPLC540V_ID_REG,
* &regValue,
* &status);
*
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/

void read_plc540v_register(UWORD baseAddress,

PLC540V_REGISTER_TYPE targetRegister,
UWORD *registerValue,
PLC540V_STATUS_TYPE *status)

{
/* Let’s initialize the status variable to success. */
memset((char *) status, 0x0, sizeof(PLC540V_STATUS_TYPE));

/* Let’s read the word from the PLC-5/40V’s register. */
status->epcStatus=EpcFromVmeAm((BM_MBO|A16S), BM_W16,

baseAddress+targetRegister,
(char far *) registerValue,
sizeof(UWORD));

if (status->epcStatus < 0)
{

status->statusCategory = kEPC_STATUS;
status->plc540vStatus = kPLC540V_READ_REGISTER_FAILED;

}
}

Advertising