This page describes the usage of the Python library of functions, which makes it possible to control a hvps-x from your own programs. You can for example integrate a hvps-x to an automatic test bed and generate a ramp of voltage while you measure actuation with a camera or a laser displacement sensor. The possibilities are endless.
Requirements to use the library of functions
The requirements to use the library of functions are described on the software page. The library is contained in the file hvps_lib.py that is part of the GUI source code, available on the download page.
Using the library of functions
Although the library can be run as a stand-alone Python script giving you access to a 3 helper scripts, its main use is as a package included in another Python program. To access the library’s functions from a Python script located in the same folder as the library file, use
import hvps_lib
at the top of your Python script.
Documentation of the library of functions
All the functions are documented on the following page:
Examples
Connecting to a hvps-x connected to a known COM port
import hvps_lib as h dev = h.HVPS('COM5') [call to other functions according to needs] dev.close()
Connecting to a hvps-x without knowing the COM port
If you are unsure of the COM port to which your hvps-x is connected, you can use the helper function connect_to_hvps(). If a single hvps-x is connected to the computer, this function will connect to it. If more than one hvps-x is connected, the names of the connected hvps-x will be printed in the terminal window and the users must chose which want they want to connect to.
import hvps_lib as h dev = h.connect_to_hvps() # use parameter unconf=True to connect to an unconfigured hvps-x [call to other functions according to needs] dev.close()
Practical example 1
import hvps_lib as h from time import sleep dev = h.connect_to_hvps() dev.s_v_mode(h.VMODE_R) # set the voltage control mode to regulated dev.s_sw_src(h.SWSRC_TMR) # set the switching source to timer dev.s_vset(2000) # set the voltage to 2000 V dev.s_f(3.8) # set the frequency to 3.8 Hz dev.s_duty(0.7) # set the duty cycle to 70% dev.s_sw_mode(h.SWMODE_SW) # set the output to switching mode. The LEDs should be blinking. sleep(10) #wait 10 s dev.s_sw_mode(h.SWMODE_OFF) # Set switching mode to off. The LEDs should be off v = dev.q_vnow(h.VNOW_POS) # queries voltage at the output of the voltage converter print("V Converter = {0} V".format(v)) # This should return a value close to 2000 dev.close() # close communication with the device
Loading parameters from memory
Instead of setting all parameters one by one to make sure the hvps-x is in the desired configuration, these parameters can be saved in the current settings and will be loaded as active settings when the hvps-x is powered up. However, as a program doesn’t know whether the unit has just been powered up, or if some parameters have been changed, it is possible to reload the ‘Current settings’ (see page on memory for more information)
import hvps_lib as h dev = h.connect_to_hvps() dev.load_settings(h.SETTINGS_CURRENT) #Current settings have now been loaded in RAM (active settings) [call to other functions according to needs] dev.close()