Agilent Technologies 66319b Video Games User Manual


 
Example Programs - D
169
Voltage Pulse Measurement Using VISA Library Calls
#include <visa.h>
#include <stdio.h> /* for printf */
#include <stdlib.h>
ViStatus main(void)
{
ViSession defRM, instrumentHandle;
ViStatus err;
ViReal64 measvoltage, meascurrent;
ViReal64 resultDC, resultRMS, resultMIN, resultMAX, resultHIGH, resultLOW;
ViReal64 voltArray[10];
ViInt32 i, numReadings ;
/* initialize the VISA session */
err = viOpenDefaultRM(&defRM);
if (err)
{
printf("viOpenDefaultRM error, check your hardware connections\n");
exit (-1);
}
/* Open the instrument at address 5 for Communication */
err = viOpen(defRM, "GPIB0::5::INSTR", VI_NULL, 5000, &instrumentHandle);
if (err)
{
viClose(defRM);
printf("viOpen error, check the device at address 5\n");
exit (-1);
}
/* Reset the instrument */
viPrintf(instrumentHandle, "*RST\n");
/* turn on the output */
viPrintf(instrumentHandle, "OUTP 1\n");
/* Set output voltage (2V) and current (1A) levels, turn output on*/
viPrintf(instrumentHandle, "VOLT %.5lg;:CURR %.5lg\n", 2.0, 1.0);
/* Measure the dc voltage level at the output terminals */
viQueryf(instrumentHandle, "MEAS:VOLT?\n", "%lf", &measvoltage);
/* Measure the dc current level at the output terminals */
viQueryf(instrumentHandle, "MEAS:CURR?\n", "%lf", &meascurrent);
printf ("Output Voltage = %f; Output Current = %f \n",
measvoltage,meascurrent);
/* configure dc source for dynamic measurements */
/* change sweep parameters */
viPrintf(instrumentHandle, "SENS:SWE:TINT %.5lg;POIN %ld;OFFS:POIN %ld\n",
31.2E-6,/* sampling rate = 31.2us */
256, /* sweep size = 256 points */
-4); /* pre-trigger offset = 4 points (~125us) */
/* setup the voltage sensing triggered measurement parameters */
/* voltage trigger level to 2.75V */
/* hysteresis band to +/- 0.1V */
/* positive slope */
/* trigger count */
/* acquisition triggered by measurement */