The release of hvps-x means the end of development and support for the original SHVPS described on this page. The files and instructions remain accessible, but we won’t provide upgrades or support. The reason for stopping support is that we don’t have any SHVPS left to work on, nor any LabVIEW license to work on the user interface. If you want to assemble a high voltage power supply, we recommend our new hvps-x.
Back to the Python HVPS User Interface
The Python user interface is built around the hvps_lib library (file hvps_lib.py), which is part of the Python interface source code available on the download page.
Content
The library contains the class HVPS, as well as a few helper functions. It enables to control the HPVS directly and makes it possible to integrate the control of the HVPS to your own programmes.
Class HVPS
The class HVPS implements all the communication functions described on the page Direct communication with the HVPS, as well as a few higher-level functions related to the user-defined waveforms.It enables you to easily write your own programmes to control the HVPS to perform specific tasks.
The only additional Python component required to use the class that is not usually included with traditional Python installation is pySerial. You can install pySerial with pip:
pip install pyserial
The documentation for the class is available in the html folder distributed with the source code, as well as here.
Helper functions
list_hvps(list_all=False)
interactive(dev)
provides a terminal for direct communication with a HVPS
input: dev: a HVPS object with which to communicate
main()
The library contains a main() function, so you can run it as a main script:
python hvps_lib.py
The function performs the following tasks:
- Search for connected HVPS
- If one HVPS is detected, connect to it. If more than one, list connected boards and ask the user to choose
- If HVPS is unconfigured, gives the opportunity to perform the initial configuration
- Launches an interactive session. Commands listed on this page can be sent directly to the HVPS. This can be used for direct communication, instead of the terminal from the Arduino IDE.
- Closes connection when user enters the command exit
Other functions
The other functions of the library are detailed on this page.
Usage Example
Here is a basic example of a Python code using the library. It assumes there is a single configured HVPS connected to the computer. Check the code of the library main() function to see how how to properly check for error when attempting to connect to the HVPS.
import hvps_lib import time ports = hvps_lib.list_hvps() keys = list(ports.keys()) dev = hvps_lib.HVPS(ports[keys[0]]) # connects to the only available HVPS dev.s_sw_mode(hvps_lib.SWMODE_OFF) # Disable output dev.s_f(2) # Set frequency to 2Hz dev.s_vset(2000) # set voltage to 2000V dev.s_cycle(20) # 20 cycles dev.s_sw_mode(hvps_lib.SWMODE_SW) # enter switching mode stop = False while not stop: # wait until 20 cycles are done time.sleep(1) dev.q_cycle() # Reads the cycle counter if dev.cycle_n == 0: # Has it gone back to 0? stop = True # Stop the loop dev.close()