KEPCO KLP Series Developers Guide, Rev 3 User Manual

Page 67

Advertising
background image

KLP-DEV 041213

5-5

5.4.2

EXAMPLE 2: USING THE POWER SUPPLY TO CREATE A VOLTAGE RAMP

A ramp is created by sending a series of points to the power supply at a defined interval. The
example shown in Figure 5-2 initializes the power supply to the starting voltage and current and
turns the output on. The “for” loop provides the actual voltage changes to the power supply once
every 500 milliseconds. The loop uses the set value function to only update the voltage setting
during the loop. This speeds up the process and follows the Kepco’s recommended program-
ming practice of only changing one variable during the loop. The current setting is set for the
worst case output setting of the power supply to insure it remains in voltage mode of operation
and has the cleanest and fastest rise times.

FIGURE 5-2. EXAMPLE 2: USING THE POWER SUPPLY TO CREATE A VOLTAGE RAMP (SHEET 1 OF 2)

#include <formatio.h>

#include <visa.h>

#include "kp_klp.h"

/* Order of the H files is important

visa.h uses some of the formation functions

kp:klp.h needs definitions from visa.h to compile correctly

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

ViByte ps_type;

ViSession KLP_Session;

void main{

/* these three variables determine the ramp

start voltage, end voltage and rate of change */

ViReal64 voltage_start=0;

ViReal64 voltage_end= 10;

ViReal64 voltage_change=.5;

ViReal64 voltage=0; // used during the ramp startup

ViReal64 current=16; // current during the ramp execution

Unsigned int i;

ViStatus power_supply_status = VI_SUCCESS;

/* 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 - 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

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

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

if (

(power_supply_status = Kpklp_init ( &id_str, 1, &ps_type, &KLP_Session)) !=Visuccess)

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

/* init the power supply operation

Power supply handle is now created provided product is KLP

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

Advertising