User Manual
Section 4: Command reference  Series 2200 Programmable DC Power Supplies Reference Manual 
4-46  2200S-901-01 Rev. A/November 2011 
Example 4 
This example is written in the C programming language; NI VISA can be used. The program 
demonstrates setting up and executing a list. It shows how to use the Operation Condition Register to 
determine when the list has finished executing. 
// pws_visa.c 
// 
#undef MICROSOFT // Change this to #define if Microsoft 
#ifdef MICROSOFT 
#include “stdafx.h” 
#include <conio.h> 
#else 
typedef char_TCHAR; 
#endif 
#include <visa.h> 
#include <stdio.h> 
#include <string.h> 
#include <time.h> 
#include <stdlib.h> 
ViSession defaultRM; //Resource manager id 
ViSession PWS4000; //Identifies the power supply 
long ErrorStatus; 
char commandString[256]; 
char ReadBuffer[256]; 
// 
// Some compilers do not require that void arguments be 
declared, however, all should accept declaration of 
// void argument lists. 
// 
void OpenPort(); // void added 
void SendSCPI(char* pString); 
void CheckError(char* pMessage); 
void delay(clock_t wait); 
void ClosePort(); // void added 
int main(int argc, _TCHAR* argv[]) 
{ 
double voltage; 
char Buffer[256]; 
double current; 
int OPERreg,i; 
float meas_voltage, meas_current; 
int List_count=10; 
int List_step =3; 
double List_Volt[3]= {3.0, 4.0, 6.0}; 
double List_Curr[3] = {0.1, 0.1, 0.1}; 
int List_Time[3]= {1,2,3}; 
} 
OpenPort(); 
//Query the power supply id, read response and print it 
sprintf(Buffer, "*IDN?"); 
SendSCPI(Buffer); 
printf("Instrument identification string:%s \n", Buffer); 
SendSCPI("*RST"); //reset the power supply 
delay(100) 
SendSCPI("CURRENT 0.1A"); //set the current to 0.1A 










