home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / FLOPPY / SICL / WIN31 / DISK2 / FORMATIO.C_ / FORMATIO.C
Encoding:
C/C++ Source or Header  |  2001-03-02  |  883 b   |  36 lines

  1. /*formatio.c
  2.   This example program makes a multimeter measurement with a comma
  3.   separated list passed with formatted I/O and prints the results. 
  4.   Note that you must change the device address. */
  5.  
  6. #include <visa.h>
  7. #include <stdio.h>
  8.  
  9. void main () {
  10.  
  11.   ViSession defaultRM, vi;
  12.   double res;
  13.   double list [2] = {1,0.001};
  14.  
  15.   /* Open session to GPIB device at address 22 */
  16.   viOpenDefaultRM (&defaultRM);
  17.   viOpen (defaultRM, "GPIB0::22::INSTR", VI_NULL,VI_NULL, &vi);
  18.  
  19.   /* Initialize device */
  20.   viPrintf (vi, "*RST\n");
  21.  
  22.   /* Set up device and send comma separated list */
  23.   viPrintf (vi, "CALC:DBM:REF 50\n");
  24.   viPrintf (vi, "MEAS:VOLT:AC? %,2f\n", list);
  25.  
  26.   /* Read results */
  27.   viScanf (vi, "%lf", &res);
  28.  
  29.   /* Print results */
  30.   printf ("Mesurement Results: %lf\n", res);
  31.  
  32.   /* Close session */
  33.   viClose (vi);
  34.   viClose (defaultRM);
  35. }
  36.