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

Page 172

Advertising
background image

Sample API Modules

Appendix B

B-14

/* The PLC-5/40V’s command/control register WRITE-READY bit
indicates when it is ready to accept a new command. We
will poll this bit until it is set or we timeout.
*/
poll_plc540v_cmdctrl_bits(baseAddress, kCMDCTRL_WRDY, status);
if (status->plc540vStatus == kPLC540V_SUCCESS)
{

/* The PLC-5/40V command word is 32 bits wide. However, the VME
interface to the command word is only 16 bits wide so we must
write the command word as two 16 bit chunks. These words must
be written MSW and then LSW.
*/
write_plc540v_register(baseAddress, kPLC540V_CH_REG,

HIWORD(command), status);

write_plc540v_register(baseAddress, kPLC540V_CL_REG,

LOWORD(command), status);

poll_plc540v_cmdctrl_bits(baseAddress, kCMDCTRL_WRDY, status);
if (status->plc540vStatus == kPLC540V_SUCCESS)
{
/* The PLC-5/40V has now started processing the command word.
We will chech the command control register’s ERROR bit to
see if this command word caused any PLC-5/40V errors. If
so, we will extract the 8 bit error code from the command
control register.
*/
read_plc540v_register(baseAddress, kPLC540V_CC_REG,

&cmdctlReg, status);

if (status->plc540vStatus == kPLC540V_SUCCESS)
{

/* Determine if the bit is set. */
if (cmdctlReg & kCMDCTRL_ERR)
{
/* Extract the error code. */
status->plc540vStatus = cmdctlReg & 0x00FF;
status->statusCategory = kPLC540V_STATUS;
}

}
}

}
}

Advertising