beautypg.com

Figure 5-1. example 1: setting voltage and current, Example 1: setting voltage and current -4 – KEPCO KLR Series Developers Guide User Manual

Page 66

background image

5-4

KLR-DEV 060713

FIGURE 5-1. EXAMPLE 1: SETTING VOLTAGE AND CURRENT

#include

#include

#include "kp_KLR.h"

/* Order of the H files is important.

visa.h uses some of the formation functions

kp:KLR.h needs definitions from vias.h to compile correctly

***** end of required h files */

Void main{

/* call function to set power supply to 15 volts at 12 amperes */

Set_powersupply(15,12);

}

/* function Set_powersupply

Sets power supply to the supplied voltage and current.

Also sets the output on as setting to a voltage and current

implies output being placed on */

ViStatus Set_powersupply (ViReal64 voltage, ViReal64 current){

ViByte ps_type;

ViSession KLR_Session;

ViStatus power_supply_status = VI_SUCCESS;

/* select one of the following ViChar id_str{}strings depending upon port to be used and

comment out the rest */

ViChar id_str{}="GPIB::06::INSTR"; // change 06 to the GPIB address of unit.

/* For LAN ports ( - change 192.168.0.100 to IP address found via front panel interface

*/

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

/* For RS 232 change 0 to actual communications port in use */

ViChar id_str()="ASRL0::INSTR"; // serial port

if (

(power_supply_status = Kpklr_init ( &id_str, 1, &ps_type, &KLR_Session)) !=Visuccess)

return (power_supply_status); // could not open power supply

/* init the power supply operation

Power supply handle is now created if unit is KLR

************************************/

Kpklr_Set_Volt_Curr (KLR_Session, voltage, current); //voltage and current

/*

The above function sets both the voltage and current setpoint of the power supply

*/

0..._OutputOnOff ( KLR_Session, 1); // output on

Kpklr_close(&KLR_Session); // free up memory and close VISA session

return (power_supply_status);

} // end of main

// if not created as a project, include the driver code at end of program

#include "Kp_klr.c"