Agilent Technologies 86100-90086 Sprinkler User Manual


 
2-6
Sample Programs
Sample C Programs
init.c - Making Automatic Measurements
/*
* Function name: auto_measurements
* Parameters: none
* Return value: none
* Description: This routine performs automatic measurements of volts
* peak-to-peak and period on the acquired data. It also demonstrates
* two methods of error detection when using automatic measurements.
*/
void auto_measurements ( )
{
float period, vpp;
unsigned char vpp_str[16];
unsigned char period_str[16];
int bytes_read;
/*
* Error checking on automatic measurements can be done using one of two methods.
* The first method requires that you turn on results in the Measurements
* subsystem using the command :MEASure:SEND ON. When this is on, the analyzer
* will return the measurement and a result indicator. The result flag is zero
* if the measurement was successfully completed, otherwise a non-zero value is
* returned which indicates why the measurement failed. See the Programmer's Manual
* for descriptions of result indicators.
*
* The second method simply requires that you check the return value of the
* measurement. Any measurement not made successfully will return with the value
* +9.999E37. This could indicate that either the measurement was unable to be
* performed, or that insufficient waveform data was available to make the
* measurement.
*/
/*
* 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 */
write_IO (":MEASure:VPP? CHANnel1"); /* query -- volts peak-to-peak channel 1*/
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",