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

Page 169

Advertising
background image

Sample API Modules

Appendix B

B-11

/*****************************************************************************
*
* PURPOSE: This function will determine if a PLC-5/40V has successfully
* completed its startup diagnostics validation routine. The
* PLC-5/40V’s STATUS/CONTROL register contains two flag bits:
* RDY and PASSED. If both of these are asserted (high),
* then the PLC-5/40V has passed its internal self-test. If
* either or both of these bits are clear, then the PLC-5/40V
* has detected internal faults and may not work properly.
*
* INPUT: UWORD baseAddress will contain the base address of the
* PLC-5/40V.
*
* 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:
* PLC540V_STATUS_TYPE status;
* plc540v_self_tested_ok(0x0FC00, &status);
*
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/
void plc540v_self_tested_ok(UWORD baseAddress,

PLC540V_STATUS_TYPE *status)

{
/* The status/control register contents. */
UWORD statCtrl = 0;

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

/* Lets obtain the status bits from the specified PLC-5/40V. */
read_plc540v_register(baseAddress, kPLC540V_SC_REG, &statCtrl, status);

if (status->plc540vStatus == kPLC540V_SUCCESS)
{

/* Let’s determine if the READY and PASSED bits are set. */
if ((statCtrl & kPLC540V_READY) == kPLC540V_READY)
{
if ((statCtrl & kPLC540V_PASSED) != kPLC540V_PASSED)
{

/* The PLC-5/40V didn’t pass its self-test. */
status->plc540vStatus = kPLC540V_NOT_PASSED;
status->statusCategory = kPLC540V_STATUS;

}
}
else
{
/* The PLC-5/40V is not ready to accept commands. */
status->plc540vStatus = kPLC540V_NOT_READY;
status->statusCategory = kPLC540V_STATUS;
}

}
}

Advertising