Chapter 6 Application Programs
Example Program for C and C++
136
OpenPort();
/* Query the power supply id, read response and print it */
sprintf(Buffer,"*IDN?");
SendSCPI(Buffer);
printf("Instrument identification string:\n
%s\n\n",Buffer);
SendSCPI("*RST");
/* Set power-on condition
*/
SendSCPI("Current 2");
/* Set current limit to 2A
*/
SendSCPI("Output on");
/* Turn output on
*/
printf("Voltage
Current\n\n");
/* Print heading
*/
/*Step from 0.6 to 0.8 volt in 0.02 steps */
for(voltage = 0.6; voltage <=0.8001; v=0.02)
{
printf("%.3f",voltage);
/* Display diode voltage*/
/* Set output voltage */
ErrorStatus = viPrintf(power_supply,"Volt %f\n",voltage);
if(!bGPIB)
delay(500);/* 500 msec wating for RS-232 port*/
CheckError("Unable to set voltage");
/* Measure output current */
ErrorStatus = viPrintf(power_supply,"Measure:Current?\n");
CheckError("Unable to write device");
delay(500);
/* Allow output to wait for 500 msec */
/* Retrieve reading */
ErrorStatus = viScanf(power_supply,"%lf",¤t);
CheckError("Unable to read voltage");
printf("%6.4f\n",current);
/* Display diode current */
}
SendSCPI("Output off");
/* Turn output off */
ClosePort();
}
/* Build the address required to open commnuication with GPIB card or RS-232.*/
/* The address format looks like this: "GPIB0::5::INSTR".
*/
/* To use the RS-232 interface using COM1 port, change it to "ASRL1::INSTR" */
/* address format */
void OpenPort()
{
char
GPIB_Address[3];
char
COM_Address[2];
char
VISA_address[40];
/* Complete VISA address sent to card */
if(bGPIB)
strcpy(GPIB_Address,"5");
/* Select GPIB address between 0 to 30*/
else
strcpy(COM_Address,"1");
/* Set the number to 2 for COM2 port */
Continued on next page
Summary of Contents for 2110-0457
Page 9: ...8...
Page 15: ...14 Contents Contents...
Page 16: ...1 Quick Start...
Page 26: ...2 General Information...
Page 38: ...3 Front Panel Operation and Features...
Page 70: ...4 Remote Interface Reference...
Page 122: ...5 Error Messages...
Page 133: ...Chapter 5 Error Messages Calibration Errors 132...
Page 134: ...6 Application Programs...
Page 145: ...Chapter 6 Application Programs Example Program for Excel 97 144...
Page 146: ...7 Tutorial...
Page 157: ...Chapter 7 Tutorial Remote Programming 156...
Page 158: ...8 Specifications...
Page 166: ...Appendix Service Information...
Page 175: ...Appendix Service Information General Disassembly 174 General Disassembly...
Page 202: ......
Page 203: ......
Page 204: ......
Page 205: ......
Page 209: ...208 Index Index...