Python wrapper for CAEN High Voltage C library.
Project description
CAEN_HV_Python
Python wrapper around C wrapper for CAEN HV crate control, whose manual is included in the git repository. Currently only impelements functions for logging into and out of a CAEN HV crate over IP, reading and setting power status, setting HV target values, reading HV monitor values, and reading current monitor values. All reads and writes are currently implemented one channel at a time, though the C wrapper supports reading and writing to multiple channels at once.
The user must specify and pass the crate IP address, username, and password to the CAENHVController initialization. It is noted in CAEN C wrapper manual that some models will disconnect if there has been no communication for 15 seconds.
An example implementation is shown below.
from caen_hv_py.CAENHVController import CAENHVController
from time import sleep
ip_address = '192.168.20.20' # Enter your CAEN HV Crate IP address
username = 'user' # Enter your CAEN HV Crate Username
password = 'pass' # Enter your CAEN HV Crate Password
slot = 1
channels = [0, 1, 2, 3, 4]
v0s = [50, 100, 150, 200, 250]
with CAENHVController(ip_address, username, password) as hv_wrapper:
print('Turning off channels')
for channel in channels:
power = hv_wrapper.get_ch_power(slot, channel)
if power:
hv_wrapper.set_ch_pw(slot, channel, 0)
sleep(1)
sleep(5)
print('Setting channels V0')
for channel, v0 in zip(channels, v0s):
hv_wrapper.set_ch_v0(slot, channel, v0)
sleep(1)
sleep(5)
print('Turning on channels')
for channel in channels:
power = hv_wrapper.get_ch_power(slot, channel)
if not power:
hv_wrapper.set_ch_pw(slot, channel, 1)
sleep(1)
sleep(10)
print('Getting channel power and Vmon')
for channel in channels:
power = hv_wrapper.get_ch_power(slot, channel)
vmon = hv_wrapper.get_ch_vmon(slot, channel)
imon = hv_wrapper.get_ch_imon(slot, channel)
print(f'Channel {channel} power: {power} Vmon: {vmon}, Imon: {imon}')
sleep(5)
print('Turning off channels')
for channel in channels:
power = hv_wrapper.get_ch_power(slot, channel)
if power:
hv_wrapper.set_ch_pw(slot, channel, 0)
print('Finshed')
The predefined functions in the example above are tailored to a specific board. A new set of generic functions were added which should allow the user to get and set any parameter by name. There are separate functions for each data type. Unsigned short and float are the only two currently implemented.
NOTE: If the parameter name is incorrect or not found, these functions will simply retrun their error codes. For the get functions, the error code is -1. For the set functions, the error code is 0 (success is 1).
An example of how to use these functions is shown below.
from caen_hv_py.CAENHVController import CAENHVController
from time import sleep
ip_address = '192.168.20.20' # Enter your CAEN HV Crate IP address
username = 'user' # Enter your CAEN HV Crate Username
password = 'pass' # Enter your CAEN HV Crate Password
slot = 1
channel = 2
with CAENHVController(ip_address, username, password) as hv_wrapper:
print('Read status')
status = hv_wrapper.get_ch_param_ushort(slot, channel, 'Status')
print(f'Status: {status}')
print('Read "Imax Set" float parameter')
imax_set = hv_wrapper.get_ch_param_float(slot, channel, 'Imax Set')
print(f'Imax Set: {imax_set}')
print('Set "Imax Set" float parameter')
hv_wrapper.set_ch_param_float(slot, channel, 'Imax Set', 1.2)
print('Finshed')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file caen_hv_py-1.10.tar.gz
.
File metadata
- Download URL: caen_hv_py-1.10.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a1f57d5d363d165641af170b2f1bc3cb8d7387106e2db7307767b1da752b25a |
|
MD5 | cb5c7b6a402cd6383e56ff31f8acb049 |
|
BLAKE2b-256 | 79627573c134e58d8e15e65e26916931ce94f724d18b6b572c0fce5ee4e11b6b |
File details
Details for the file caen_hv_py-1.10-py3-none-any.whl
.
File metadata
- Download URL: caen_hv_py-1.10-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de59129ba80f4475a592868355d10f1572c77d3d4349acb51c4c24acb7f786bd |
|
MD5 | c712f1a5013aa9c44b10de91bee8c28f |
|
BLAKE2b-256 | a5e062673e78a1fa726211cbd1ce753d07aae083f80768d1ae1f2eb217edee4f |