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

Page 168

Advertising
background image

Sample API Modules

Appendix B

B-10

/*****************************************************************************
*
* PURPOSE: This function will write to a PLC-5/40V’s A16 configuration or
* 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 written.
*
* UWORD registerValue will contain the value to be written
* to the specified target register.
*
* OUTPUT: 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 = 0x1234;
* PLC540V_STATUS_TYPE status;
* read_plc540v_register(0x0FC00,
* kPLC540V_OF_REG,
* regValue,
* &status);
*
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/
void write_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 write the word to the PLC-5/40V’s register. */
status->epcStatus=EpcToVmeAm((BM_MBO|A16S), BM_W16,

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

if (status->epcStatus < 0)
{

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

}
}

Advertising