Rockwell Automation 5370 Color CVIM Communications Manual User Manual

Page 66

Advertising
background image

Chapter 4
Using the Remote I/O Link

4–29

if (status != C_AUTOCONF && status != C_SETUP)

printf (”Scanner fatal error %d\n”, fatal_6008());

abort();

}

/* Place scanner in RUN mode */

mr_pkt.qmr_data[0] = CM_RUN;

status = mr_wait (C_SETMODE, &mr_pkt);

if (status != OK)

{

printf (”Setup failed: command=%s, status=%s\n”,

xlat_cmd(status), xlat_conf(mr_pkt.qmr_stat));

if (status != C_AUTOCONF && status != C_SETUP)

printf (”Scanner fatal error %d\n”, fatal_6008());

abort();

}

/* Disable host watchdog. For sample program ONLY ––

not recommended for any application programs. */

host_active(–1);

/* Get CVIM rack address from the user */

printf (”Enter CVIM remote–I/O rack number (0–7): ”);

scanf (”%d”, &CVIM_rack);

g_oit[8*CVIM_rack + 2] |= 0x0001; /* post tool results */

/* Start of main loop */

do {

printf (”\n\nOperations: \n\n”);

printf (”1. Trigger Tool Set\n”);

printf (”2. Read Results, Part 1\n”);

printf (”3. Read Configuration\n”);

printf (”4. Write Configuration\n”);

printf (”\nEnter operation number (1–4) or –1 to quit: ”);

scanf(”%d”, &op_num ); /* Convert user string input to a number */

err = 0;

switch (op_num)

{

case 1: /* trigger tool set by toggling trigger bit */

{

g_oit[8*CVIM_rack] |= TRIGGER_1_BIT;

for (t=0; t<25000; t++);

g_oit[8*CVIM_rack] &= ~TRIGGER_1_BIT;

err = g_op_stat & SO_FAULT;

} break;

case 2: /* read discrete results part 1 */

{

/* display all 8 input words in hex */

for (x=0; x<8; x++)

printf (”%04X ”, g_ipt[8*CVIM_rack + x]);

printf (”\n”);

Advertising