291
Chapter 6 Application Programs
Example: Microsoft Visual C++ for Windows
4
6
//
// Download a 20 point Arbitrary waveform using ASCII.
//
printf ("Download a 20 point Arbitrary waveform using ASCII\n");
// Download 20 point waveform
{
double Real_array[20];
Fill_array(Real_array);
IWritePtr pWrite = IOObj->Write();
pWrite->Command ("data volatile, ", VARIANT_FALSE); // Command into buffer
for (int i = 0; i < 20; i++)
pWrite->PutArgument(i, Real_array[i]); // Comma separated list to buffer
pWrite->Send (); // Send buffer to the instrument
}
IOObj->Output("func:user volatile"); // Select downloaded waveform
IOObj->Output("apply:user 10e3,1,0"); // Output waveform: 10kHz, 1Vpp
Check_Errors(IOObj); // Routine check for errors
Pause();
//
// Download a 6 point arbitrary waveform using Binary.
//
printf ("Download a 6 point Arbitrary waveform using Binary\n");
long Len;
_variant_t DataArray = "2047,-2047,2047,2047,-2047,-2047";
SAFEARRAY *pBlock;
// Create SCPI command with Binary block appended on end
Len = IOUtils->CreateIEEEBlock(DataArray, IIOUtils_Short, IIOUtils_BigEndian,
_variant_t("data:dac volatile, "), &pBlock);
IOObj->WriteBytes(Len, &pBlock); // Send command and data
SleepEx(100, 0); // Wait 100msec for interface
// (for RS-232 only)
IOObj->Output("apply:user 5000,1,0"); // Output waveform: 5kHz, 1Vpp
Check_Errors(IOObj); // Routine check for errors
Pause();
Continued...