#include "stdafx.h"
#include <visa.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
ViSession defaultRM; // Resource manager ID
ViSession KI200; // Identifies the power supply
long ErrorStatus;
char commandString[256];
char ReadBuffer[256];
void OpenPort();
void SendSCPI(char* pString);
void CheckError(char* pMessage);
void delay(clock_t wait);
void ClosePort();
int main(int argc, _TCHAR* argv[])
{
char Buffer[256];
float setting[3][2]={
{11.9, 0.55},
{15.15, 0.25},
{2.5, 0.15}
} ; // Voltage, current for three channels
float query[3][2];
unsigned int i;
OpenPort();
// Query the power supply ID, read the response and print it
sprintf(Buffer, "*IDN?");
SendSCPI(Buffer);
printf("Instrument identification string:%s \n", Buffer);
SendSCPI("*RST"); // Reset the power supply
SendSCPI("OUTPut 1"); // Turn the output on
for (i=0; i<3; i++)
{
printf("setting Channel: %d, voltage(V):%f, current(A):%f \n", i+1,
setting[i][0], setting[i][1]);
ErrorStatus = viPrintf(KI200, "INSTrument:NSELect %d\n", i+1); // Select the channel
CheckError("Unable to select the channel");
ErrorStatus = viPrintf(KI200,"VOLTage %f\n",setting[i][0]); // Set the output voltage
CheckError("Unable to set voltage");
ErrorStatus = viPrintf(KI200, "CURRent %f\n",setting[i][1]); // Set the output current
CheckError("Unable to set current");
}
SendSCPI("*SAV 4");
delay (10);
for (i=0; i<3; i++)
B-2
Series 2200 Programmable Multichannel DC Power Supplies Programmer Manual