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

Page 130

Advertising
background image

Appendix A

Sample Applications

A-8

/***************************************************************************/
/***************************** GET_KEY_MODE ********************************/
/***************************************************************************/
char *get_key_mode(int keyMode)
{

// Return a string which textually described the state of the key
// switch on the PLC.

static char mode[80+1];
switch (keyMode)
{

case kPLC540V_PROGRAM_LOAD:

strcpy(mode, ”Program Load”);
break;

case kPLC540V_RUN:

strcpy(mode, ”Run”);
break;

case kPLC540V_REMOTE_PROGRAM_LOAD:

strcpy(mode, ”Remote Program Load”);
break;

case kPLC540V_REMOTE_TEST:

strcpy(mode, ”Remote Test”);
break;

case kPLC540V_REMOTE_RUN:

strcpy(mode, ”Remote Run”);
break;

}

return(mode);

}

/***************************************************************************/
/********************** TEST_ENABLE_SLAVE_MEMORY ***************************/
/***************************************************************************/
void test_enable_slave_memory(void)
{
// Enable the onboard VME memory on the PLC–5/VME processor.

// Status information
PLC540V_STATUS_TYPE status;

// A list of all the PLC’s in this VME chassis. We will use a list of 1.
LOCATED_PLC540V_ARRAY_TYPE plcList;

// Prepare the records which will contain info concerning the enabled
// VME memory for the PLC.
memset((char *) &plcList, 0x0, sizeof(LOCATED_PLC540V_ARRAY_TYPE));
memset((char *) &mem, 0x0, sizeof(MEM_TYPE));
mem.isInitialized = 1;

// Ask the user for the target PLC’s base address and where they want
// to locate the PLC’s memory in VME space.
clrscr();
gotoxy(0, 10);
cprintf(
”Enter the desired VME slave address for the PLC (for the A24 addr space): ”);
scanf(”%lx”, &mem.vmeSlaveAddr);
gotoxy(0, 11);
cprintf(”Enter the base address for the PLC–5/40V in hex: ”);
scanf(”%x”, &mem.baseAddr);

Advertising