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

Page 165

Advertising
background image

Sample API Modules

Appendix B

B-7

/* Loop until we timeout or the bits are set. */
for (i=0;

((i<kTIMEOUT_COUNT) && (status->plc540vStatus == kPLC540V_SUCCESS));
i++)

{

read_plc540v_register(baseAddress, kPLC540V_CC_REG,

&cmdctlReg, status);

if (status->plc540vStatus == kPLC540V_SUCCESS)
{
/* Determine if the bit is set. */
if (cmdctlReg & andMask)

break;

}

}

if (i > kTIMEOUT_COUNT)
{

/* Signal that we timed out. */
status->plc540vStatus = kPLC540V_CMDCTRL_WRDY_TIMEOUT;
status->statusCategory = kPLC540V_STATUS;

}
}

/*****************************************************************************
*
* PURPOSE: This function will examine the entire VME memory space to
* locate all the PLC-5/40V’s which are installed.
*
* INPUT: None
*
* OUTPUT: LOCATED_PLC540V_ARRAY_TYPE *plcList will contain the base
* addresses of each located PLC-5/40V. Any entries in this
* array which don’t have a PLC-5/40V will be zero.
*
* 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:
* LOCATED_PLC540V_ARRAY_TYPE plcList;
* PLC540V_STATUS_TYPE *status;
* find_all_plc540v_in_VME(plcList, &status);
*
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/
void find_all_plc540v_in_VME(LOCATED_PLC540V_ARRAY_TYPE plcList,

PLC540V_STATUS_TYPE *status)

{
/* The current base address which we are examining in VME space. */
UWORD baseAddress;

/* The current array entry to write an address into. */
UBYTE arrayIndex;

/* The manufacturer id for a located PLC-5/40V */
UWORD manId = 0;

/* The PLC-5/40V device type for a located PLC-5/40V */
UWORD devType = 0;

/* Let’s initialize the array to have no located PLC-5/40V’s. */
memset((char *) plcList, 0x0, sizeof(LOCATED_PLC540V_ARRAY_TYPE));

Advertising