2-20
Sample Programs
Listings of the Sample Programs
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:SEND 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 ( ) */
/*
* Function name: transfer_data
* Parameters: none
* Return value: none
* Description: This routine transfers the waveform conversion factors and waveform data to the PC.
*/
void transfer_data ( )