KEPCO KLP Series Developer's Guide, Rev 1 User Manual

Page 89

Advertising
background image

KLP-DEV 031113

6-9/(6-10 Blank)

FIGURE 6-3. TYPICAL EXAMPLE OF KLP POWER SUPPLY PROGRAM USING SCPI COMMANDS

/**************************************************************************/
/* Sample Program For KEPCO power supply, using National Instruments */
/* any interface

*/

/**************************************************************************/
#include "visa.h"// visa controls and functions
#include <stdio.h>
#include "decl.h"

ViChar rd_str[80]; // Input buffer
ViChar dat_str[80]; // Output buffer

/* select one of the following strings depending upon port to be used */

ViChar id_str{}="GPIB::06::INSTR";

// change 06 to the GPIB address of unit.

/* LAN addresses - changed the 192.168.0.100 to IP address found via the unit front panel inter-
face */

ViChar id_str()="TCIP::192.168.0.100::INSTR"; // VXI-11 instrument- via LAN port 1024
ViChar id_str()="TCIP::i92.168.0.100::5025::SOCKET"; // SCPI-RAW port (5025) LAN instrument

/* change 0 to actual communications port in use */

ViChar id_str()="ASRL0::INSTR";

// serial port

/* ViOpen uses the resource string to find the device and returns a session id to the user */

ViSession Kepco_Session;

main() {

if (viOpen(Kepco_Session,id_str,VI_NULL,VI_NULL,VI_NULL) == 0){

strcpy(dat_str,"VOLT 5;CURR 1");

// Define a set command

strcat(dat_str,"\r\n");

// Append delimiter - needed for Serial port and
// Socket operation

viWrt(Kepco_Session,dat_str);

// Send string to power supply

strcpy(dat_str,"MEAS:VOLT?;CURR?"); // Define a measure command
strcat(dat_str,"\r\n"); //

Append

delimiter

ViWrt(Kepco_Session,dat_str);

// Send string to power supply

strset(rd_str,'\0');

// Clear input buffer

ViRd(Kepco_Session,rd_str,64,i);

// Read result of measure

printf("received : %s\n",rd_str);

// Print voltage and current

viClose(Kepco_Session);

// close the instrument

}

Advertising