AnsweredAssumed Answered

remote control of oscilloscope using RS232:ag33250a

Question asked by kg on Dec 31, 2008
Latest reply on Dec 31, 2008 by kg
I want to use rs232 to trigger a burst of sine wave ( 1Mhz,100mv) in 1 sec through rs232. I'm using head file:ag33250a.h. there is some problem during command execution:363 input buffer overrun. Both computer and the oscilloscope are set as the same: Baud rate:9600, parity:none/8bits,handshake:DTR.  I tried to use "*opc", but still experience exception interuption. The code is shown below.

#define     CHECK(func)     \
do {\
    ViStatus _s = (func);\
    if (_s < 0)\
     fprintf(stderr, "Error: %s returned %d\n", #func, _s);\
} while (0)

/* Specify the default address */

ViStatus check(ViSession vi1, ViString mesg11, ViStatus errStatus1);

void DataCollectionWin::Onburst()
     ViSession   vi;
     ViRsrc      TxtAddress = DEFAULT_LOGICAL_ADDRESS;

     long i,j;
     clock_t start,finish;
     double duration;
     char pszTemp[256];
     ViPInt16 opc;

     CHECK(ag33250a_init(TxtAddress, 0, 0, &vi));                    /* This funcion initializes the instrument */
     CHECK(ag33250a_reset(vi));                                             /* Reset the function generator */
          CHECK(ag33250a_dcl(vi));                                             /* Clear errors and status registers */

    CHECK(ag33250a_outpSync(vi, ag33250a_OUTPUT_SYNC_OFF));          /* Disable the SYNC Output */
     CHECK(ag33250a_funcShap(vi, ag33250a_OUTPUT_FUNC_SIN));          /* Select waveshape */
   CHECK(ag33250a_outpLoad(vi, ag33250a_OUTPUT_LOAD_50));          /* Set the load impedance to 50 Ohms (default) */

   CHECK(ag33250a_volt(vi,0.1));                                        /* Set the amplitude to 100 mVpp. */
      CHECK(ag33250a_opc_Q(vi, opc));
    CHECK(ag33250a_voltOffs(vi, 0));                                   /* Set the offset to 0 V */
      CHECK(ag33250a_opc_Q(vi, opc));
     CHECK(ag33250a_freq(vi,1000000));                                   /* Frequency at 1MHz  */

   CHECK(ag33250a_opc_Q(vi, opc));

    CHECK(ag33250a_trigSour(vi, ag33250a_TRIGGER_SOUR_BUS));     /* Triggers will be received from the I/O bus */
     CHECK(ag33250a_opc_Q(vi, opc));

     CHECK(ag33250a_bmSour(vi,ag33250a_BM_MOD_SOUR_TRIG));          /* Triggered burst (rather than GATed) */
      CHECK(ag33250a_opc_Q(vi, opc));
     CHECK(ag33250a_bmNcyc(vi,1000000));                              /* 1000000 cycles will be output per trigger */
      CHECK(ag33250a_opc_Q(vi, opc));
CHECK(ag33250a_bmStat(vi, ag33250a_BM_STAT_ON));               /* Enable burst */
  CHECK(ag33250a_opc_Q(vi, opc));
    CHECK(ag33250a_outpSync(vi,ag33250a_OUTPUT_SYNC_ON));          /* Enable the SYNC Output to trigger oscilloscope */
     CHECK(ag33250a_opc_Q(vi, opc));
     CHECK(ag33250a_outpSetup(vi, ag33250a_OUTPUT_SETUP_ON));     /* Turn on the instrument output */

      CHECK(ag33250a_opc_Q(vi, opc));
    CHECK(ag33250a_opc_Q(vi, opc));


when I just use ag33250a_opc(vi), still I get the 363 error message. But if I use ag33250a_opc_Q(vi, opc)) as shown above, the program will   close automatically due to exception interruption.

Can anyone show me the correct way to use ag33250a_opc_Q? ALso should I check opc each time before executing the next command, which means it will have a lot of "if" loop?