Agilent Technologies 66311B Portable Generator User Manual


 
Example Programs - D
171
{
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 */
viPrintf(instrumentHandle, "SENS:FUNC \"VOLT\"\n");
viPrintf(instrumentHandle, "TRIG:ACQ:LEV:VOLT %.5lg\n", 2.75);
viPrintf(instrumentHandle, "TRIG:ACQ:HYST:VOLT %.5lg\n", 0.1);
viPrintf(instrumentHandle, "TRIG:ACQ:SLOP:VOLT POS\n");
viPrintf(instrumentHandle, "TRIG:ACQ:COUN:VOLT %ld\n", 1);
viPrintf(instrumentHandle, "TRIG:ACQ:SOUR INT\n");
/* initiate the acquisition system for measurement trigger */
printf ("Arm acquisition system...\n");
viPrintf(instrumentHandle, "INIT:NAME ACQ\n");
/* must allow time for pre-triggered samples */
printf ("Pre-trigger delay...\n");
/* trigger the acquisition by changing the output voltage level to 5V */
printf ("Trigger acquisition...\n");
viPrintf(instrumentHandle, "VOLT %.5lg\n", 5.0);