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

Page 128

Advertising
background image

Appendix A

Sample Applications

A-6

/***************************************************************************/
/******************************* SHOW_ERROR *******************************/
/***************************************************************************/
void show_error(char *str)
{
// This function will inform the user of an error.

gotoxy(20, 16);
highvideo();
cprintf(str);
gotoxy(20, 17);
cprintf(”Press the backspace key to continue...”);
while(!kbhit());
gotoxy(20, 16);
clreol();
gotoxy(20, 17);
clreol();
normvideo();
}

/***************************************************************************/
/******************* TEST_EPC_TO_PLC_GLOBAL_MEMORY *************************/
/***************************************************************************/
void test_epc_to_plc_global_memory(void)
{
// This routine will instruct the EPC to write the values from
// 0 to 255 to VME shared global memory and then the PLC–5/40V
// will read the value and send it to a SIM module for display.

///// WARNING! THIS ROUTINE EXPECTS VME ADDRESS E00000 EXISTS! //////

// A loop counter
short i;

// Tell the user how to exit this demo
clrscr();
gotoxy(20, 10);
cprintf(”Press the backspace key when you wish to exit this demo...”);

// While the user doesn’t touch the keyboard, show the value and send it
// to VME using the Radisys driver.
while (!kbhit())
{

if ((i >= 0) && (i <= 255))
{
// Write the value to VME memory. */
gotoxy(20, 12);
cprintf(”Sending this value to global VME memory: ”);
gotoxy(61, 12);
cprintf(”%03d”, i);

EpcToVmeAm(BM_MBO | A24SD, BM_W16, (char far *) &i, 0xE00000, 2);

// Up our counter...
i++;
}
else
{
// Reset the value to zero so it is within the range of
// numbers that can be displayed on the SIM card.
i = 0;
}

}
}

Advertising