home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / gpibdv.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  1.4 KB  |  62 lines

  1. /* gpibdv.c
  2.    This example program sends a scan list to a switch and while
  3.    looping closes channels and takes measurements.
  4. */
  5.  
  6. #include <sicl.h>
  7. #include <stdio.h>
  8.  
  9. main()
  10. {
  11.    INST dvm;
  12.    INST sw;
  13.  
  14.    double res;
  15.    int i;
  16.  
  17.    #if defined(__BORLANDC__) && !defined(__WIN32__)
  18.       _InitEasyWin();   // required for Borland EasyWin programs
  19.    #endif
  20.  
  21.    /* Log message and terminate on error */
  22.    ionerror (I_ERROR_EXIT);
  23.  
  24.    /* Open the multimeter and switch sessions*/
  25.    dvm = iopen ("hpib7,9,3");
  26.    sw = iopen ("hpib7,9,14");
  27.    itimeout (dvm, 10000);
  28.    itimeout (sw, 10000);
  29.  
  30.    /*Set up trigger*/
  31.    iprintf (sw, "TRIG:SOUR BUS\n");
  32.  
  33.    /*Set up scan list*/
  34.    iprintf (sw,"SCAN (@100:103)\n");
  35.    iprintf (sw,"INIT\n");
  36.  
  37.    for (i=1;i<=4;i++)
  38.    {
  39.       /* Take a measurement */
  40.       iprintf (dvm,"MEAS:VOLT:DC?\n");
  41.  
  42.       /* Read the results */
  43.       iscanf (dvm,"%lf",&res);
  44.  
  45.       /* Print the results */
  46.       printf ("Result is %f\n",res);
  47.  
  48.       /*Trigger to close channel*/
  49.       iprintf (sw, "TRIG\n");
  50.    }
  51.    /* Close the multimeter and switch sessions */
  52.    iclose (dvm);
  53.    iclose (sw);
  54.  
  55. /* For WIN16 programs, call _siclcleanup before exiting to release
  56.    resources allocated by SICL for this application.  This call
  57.    is a no-op for WIN32 programs. */
  58.    _siclcleanup();
  59.  
  60.    return 0;
  61. }
  62.