forked from atelier-ritz/CoilSystemPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfieldManager.py
58 lines (50 loc) · 1.64 KB
/
fieldManager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# assign pin # to the coil
PIN_X1 = [0, 5.003] # pin number, factor number (mT/V)
PIN_X2 = [3, 4.879]
PIN_Y1 = [4, 5.143]
PIN_Y2 = [1, 5.024]
PIN_Z1 = [2, 5.024]
PIN_Z2 = [5, 4.433]
class FieldManager(object):
def __init__(self,dac):
self.x = 0
self.y = 0
self.z = 0
self.dac = dac
# Uniform field
def setX(self,mT):
self.dac.s826_aoPin(PIN_X1[0], mT / PIN_X1[1])
self.dac.s826_aoPin(PIN_X2[0], mT / PIN_X2[1])
self.x = mT
def setY(self,mT):
self.dac.s826_aoPin(PIN_Y1[0], mT / PIN_Y1[1])
self.dac.s826_aoPin(PIN_Y2[0], mT / PIN_Y2[1])
self.y = mT
def setZ(self,mT):
self.dac.s826_aoPin(PIN_Z1[0], mT / PIN_Z1[1])
self.dac.s826_aoPin(PIN_Z2[0], mT / PIN_Z2[1])
self.z = mT
def setXYZ(self,x_mT,y_mT,z_mT):
self.setX(x_mT)
self.setY(y_mT)
self.setZ(z_mT)
# Generate a pulling force by applying current to only one coil
# mT is a measurement of current in the coil. It has nothing to do with actual field strength.
def setXGradient(self,mT):
if mT > 0:
self.dac.s826_aoPin(PIN_X1[0], mT / PIN_X1[1])
else:
self.dac.s826_aoPin(PIN_X2[0], mT / PIN_X2[1])
self.x = 0
def setYGradient(self,mT):
if mT > 0:
self.dac.s826_aoPin(PIN_Y1[0], mT / PIN_Y1[1])
else:
self.dac.s826_aoPin(PIN_Y2[0], mT / PIN_Y2[1])
self.y = 0
def setZGradient(self,mT):
if mT > 0:
self.dac.s826_aoPin(PIN_Z1[0], mT / PIN_Z1[1])
else:
self.dac.s826_aoPin(PIN_Z2[0], mT / PIN_Z2[1])
self.z = 0