290
Chapter 6 Application Programs
Example: Microsoft Visual C++ for Windows
6
//
// Linear Sweep
//
printf ("Linear Sweep\n");
IOObj->Output("sweep:time 1"); // 1 second sweep time
IOObj->Output("freq:start 100"); // Start frequency 100Hz
IOObj->Output("freq:stop 20000"); // Stop frequency 20kHz
IOObj->Output("sweep:stat on"); // Turn ON sweeping
Check_Errors(IOObj); // Routine check for errors
Pause();
IOObj->Output("sweep:stat off"); // Turn OFF sweeping
//
// Pulse period with variable Edge Times
//
printf ("Pulse Waveform with variable Edge Times\n");
IOObj->Output("output:state off"); // Disable Output BNC
IOObj->Output("volt:low 0;:volt:high 0.75"); // Low = 0V, High = 0.75V
IOObj->Output("pulse:period 1e-3"); // 1ms intervals
IOObj->Output("pulse:width 100e-6"); // 100us pulse width
IOObj->Output("pulse:tran 10e-6"); // Edge time 10us
IOObj->Output("func pulse"); // Select Function Pulse
IOObj->Output("output:state on"); // Enable Output BNC
for ( i = 0; i < 10; i++ ) { // Vary edge by 1usec steps
sprintf(cmds, "puls:tran %f\n",0.00001+0.000001*float(i));
IOObj->Output(cmds);
SleepEx(300, 0); // Wait 300msec
}
Check_Errors(IOObj); // Routine check for errors
Pause();
//
// Triggered Burst
//
printf ("Triggered Burst\n");
IOObj->Output("output:state off"); // Turn OFF Output BNC
IOObj->Output("output:sync off"); // Disable Sync BNC
IOObj->Output("func square"); // Select square wave
IOObj->Output("frequency 20e3"); // 20kHz
IOObj->Output("volt 1;:volt:offset 0"); // 1Vpp and 0V offset
IOObj->Output("func:square:dcycle 20"); // 20% duty cycle
IOObj->Output("trig:sour bus"); // Bus triggering
IOObj->Output("burst:ncycles 3"); // Burst of 3 cycles
IOObj->Output("burst:state on"); // Enable Burst
IOObj->Output("output:state on"); // Turn On Output BNC
IOObj->Output("output:sync on"); // Enable Sync BNC
Check_Errors(IOObj); // Routine check for errors
for (int i = 1; i <= 20; i++)
{
IOObj->Output("*trg"); // Send BUS trigger
SleepEx(100, 0); // Wait 100msec
}
Pause();
Continued...