User Manual

Section 4: Command reference Series 2200 Programmable DC Power Supplies Reference Manual
4-44 2200S-901-01 Rev. A/November 2011
reading
CheckError("Unable to read voltage");
ErrorStatus = viPrintf(PWS4000,"MEASURE:CURRENT?\n");
//measure the output current
CheckError("Unable to write the device");
ErrorStatus = viScanf(PWS4000,"%f",&current); //retrieve
reading
CheckError("Unable to read current");
printf("Measured voltage(V) & current(A): %f,%f \n",
voltage, current);
SendSCPI("OUTPUT 0"); //turn output off
ClosePort();
while(1);
//return 0;
}
void OpenPort()
{
//Open communication session with the power supply, and
put the power supply in remote
ErrorStatus = viOpenDefaultRM(& defaultRM);
ErrorStatus =viOpen(defaultRM,
"USB0::0X0699::0X0391::006002206573001001::INSTR",0,0,&PWS4000);
CheckError("Unable to open the port");
SendSCPI("SYSTEM:REMOTE");
}
void SendSCPI(char* pString)
{
char* pdest;
strcpy(commandString,pString);
strcat(commandString, "\n");
ErrorStatus = viPrintf(PWS4000, commandString);
CheckError("Can't Write to Power Supply");
pdest = strchr(commandString, '?'); //Search for query
command
if (pdest != NULL)
{
ErrorStatus = viBufRead(PWS4000, (ViBuf)ReadBuffer,
sizeof(ReadBuffer), VI_NULL);
CheckError("Can't read from driver");
strcpy(pString, ReadBuffer);
}
}
void ClosePort()
{
viClose(PWS4000);
viClose(defaultRM);
}
void CheckError(char* pMessage)
{
if(ErrorStatus != VI_SUCCESS)
{
printf("\n %s",pMessage);
ClosePort();
exit(0);
}
}
void delay(clock_t wait)