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

Page 129

Advertising
background image

Appendix A

Sample Applications

A-7

/***************************************************************************/
/****************************** TEST_PCCC_ID *******************************/
/***************************************************************************/
void test_pccc_id(void)
{
// This function will test the PCCC Id Host & Status command.

// Address where to store command block
ULONG vmeCmdBlkAddr = 0;

// Address where the PLC–5/VME’s registers exists
UWORD baseAddr = 0;

// Status information
PLC540V_STATUS_TYPE status;

// Id Host & Status reply info
PLC540V_PCCC_IHAS_RPY_TYPE reply;

// Clear the screen and get the desired command block and processor info
clrscr();
gotoxy(0, 10);
cprintf(
”Enter the VME command block address in hex (for the A24 addr space): ”);
scanf(”%lx”, &vmeCmdBlkAddr);
gotoxy(0, 11);
cprintf(”Enter the base address for the PLC–5/40V in hex: ”);
scanf(”%x”, &baseAddr);

// Ask the PLC for its identity and status info
plc540v_pccc_id_host_and_status(

vmeCmdBlkAddr,
baseAddr,
kVME_D16_DATA_WIDTH,
kVME_A24_ADDR_SPACE,
&reply,
&status);

// Show the important data
gotoxy(20, 13);
cprintf(”Processor Series: %c”, reply.plcStatus.series + ’A’);
gotoxy(20, 14);
cprintf(”Processor Revision: %c”, reply.plcStatus.revision + ’A’);
gotoxy(20, 15);
cprintf(”Station Number: %05d”, reply.plcStatus.stationNumber);
gotoxy(20, 16);
cprintf(”Key Switch Mode: %s”, get_key_mode(reply.plcStatus.keyswitchMode));
gotoxy(20, 17);
cprintf(”Major Faults: %s”,
reply.plcStatus.majorFault == kPLC540V_NO_MAJOR_FAULT ? ”False”:”True”);
gotoxy(20, 18);
cprintf(”Memory Size (words): %05ld”, reply.plcStatus.memorySize/2);
gotoxy(20, 19);
cprintf(”Data Table File Count: %05d”, reply.plcStatus.dataTableFileCount);
gotoxy(20, 20);
cprintf(”Program File Count: %05d”, reply.plcStatus.programFileCount);

gotoxy(20, 24);
cprintf(”Press the backspace key to continue...”);
while(!kbhit());
gotoxy(20, 24);
clreol();
normvideo();

display_status(&status);
}

Advertising