2-8
Sample Programs
Sample C Programs
* METHOD ONE - turn on results to indicate whether the measurement completed
* successfully. Note that this requires transmission of extra data from the scope.
*/
write_IO (":MEASure:SEND ON"); /* turn results on */
/* query -- volts peak-to-peak channel 1*/
write_IO (":MEASure:VPP? CHANnel1");
bytes_read = read_IO(vpp_str,16L); /* read in value and result flag */
if (vpp_str[bytes_read-2] != '0')
printf ("Automated vpp measurement error with result %c\n",
vpp_str[bytes_read-2]);
else
printf ("VPP is %f\n",(float)atof(vpp_str));
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */
bytes_read = read_IO(period_str,16L); /* read in value and result flag */
if period_str[bytes_read-2] != '0')
printf ("Automated period measurement error with result %c\n",
period_str[bytes_read-2]);
else
printf ("Period is %f\n",(float)atof (period_str));
/*
* METHOD TWO - perform automated measurements and error checking with
* :MEAS:RESULTS OFF.
*/
period = (float) 0;
vpp = (float) 0;
/* turn off results */
write_IO (":MEASure:SEND OFF");
write_IO (":MEASure:PERiod? CHANnel1"); /* period channel 1 */
bytes_read = read_IO (period_str,16L); /* read in value and result flag */
period = (float) atof (period_str);
if ( period > 9.99e37 )
printf ("\nPeriod could not be measured.\n");
else
printf ("\nThe period of channel 1 is %f seconds.\n", period );
write_IO (":MEASure:VPP? CHANnel1");
bytes_read = read_IO ( vpp_str,16L );
vpp = (float) atof (vpp_str);
if ( vpp > 9.99e37 )
printf ("Peak-to-peak voltage could not be measured.\n");
else
printf ("The voltage peak-to-peak is %f volts.\n", vpp );
} /* end auto_measurements() */