forked from zietzm/Helmholtz_Test_Bench
started work on 3-axis handling
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# import time
|
||||
|
||||
from pyps2000b import PS2000B
|
||||
import globals as g
|
||||
|
||||
|
||||
def set_devices(xPort, yPort, zPort):
|
||||
g.xDevice = PS2000B.PS2000B(xPort)
|
||||
g.yDevice = PS2000B.PS2000B(yPort)
|
||||
g.zDevice = PS2000B.PS2000B(zPort)
|
||||
|
||||
|
||||
def current_vec(mag_vec): # calculates needed current in each axis for given magnetic field vector
|
||||
i_vec = mag_vec/g.Coil_const
|
||||
return i_vec
|
||||
|
||||
|
||||
def set_current_vec(i_vec):
|
||||
set_current(g.xDevice, i_vec[0])
|
||||
set_current(g.yDevice, i_vec[1])
|
||||
set_current(g.zDevice, i_vec[2])
|
||||
|
||||
|
||||
def set_current(device, value):
|
||||
# ToDo: Check behaviour with only current or only voltage set
|
||||
# ToDo: Check behaviour when trying to set too high currents
|
||||
if value > 0:
|
||||
device.current1 = value
|
||||
device.voltage2 = 0
|
||||
elif value < 0:
|
||||
device.voltage1 = 0
|
||||
device.current2 = -value
|
||||
elif value == 0:
|
||||
device.voltage1 = 0
|
||||
device.voltage2 = 0
|
||||
else:
|
||||
raise ValueError("Invalid current value. (This should never happen.)")
|
||||
@@ -0,0 +1,5 @@
|
||||
global Coil_const
|
||||
|
||||
global xDevice
|
||||
global yDevice
|
||||
global zDevice
|
||||
@@ -0,0 +1,18 @@
|
||||
# import platform
|
||||
# import time
|
||||
import numpy as np
|
||||
import globals as g
|
||||
import cage_func as func
|
||||
# from pyps2000b import PS2000B
|
||||
|
||||
# User Inputs/Configuration----------------------------------
|
||||
# Coil data:
|
||||
g.Coil_const = np.array([38.6, 38.45, 37.9])*1e-9 # Coil constants [x,y,z] in T/A
|
||||
|
||||
# COM-Ports for power supply units:
|
||||
xPort = "COM1" # placeholders
|
||||
yPort = "COM3"
|
||||
zPort = "COM5"
|
||||
|
||||
func.set_devices(xPort, yPort, zPort)
|
||||
print(func.current_vec(np.array([10, 10, 5])*1e-6))
|
||||
Reference in New Issue
Block a user