79 lines
2.8 KiB
Python
Executable File
79 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# *-----------------------------------------------------------------------*
|
|
# | |
|
|
# | Copyright (c) 2017 by Paul Scherrer Institute (http://www.psi.ch) |
|
|
# | |
|
|
# | Author Thierry Zamofing (thierry.zamofing@psi.ch) |
|
|
# *-----------------------------------------------------------------------*
|
|
'''
|
|
generate code to find HomeOffset for the 5cam systems
|
|
|
|
the results are:
|
|
amplitude: 5mm
|
|
#1: homeoffset: -20907.5928142
|
|
#2: homeoffset: 102320.329068
|
|
#3: homeoffset: 168946.772022
|
|
#4: homeoffset: -87830.7554146
|
|
#5: homeoffset: -47956.2759182
|
|
'''
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
def meas_rot_ctr(y,per=1):
|
|
# find the amplitude bias and phase of an equidistant sampled sinus
|
|
# it needs at least 3 measurements e.g. at 0,120 240 deg or 0 90 180 270 deg
|
|
# per is the number of persiods, default is 1 period =360 deg
|
|
n=len(y)
|
|
f = np.fft.fft(y)
|
|
idx=int(per)
|
|
bias=np.absolute(f[0]/n)
|
|
phase=np.angle(f[idx])
|
|
ampl=np.absolute(f[idx])*2/n
|
|
print('len: '+str(n))
|
|
print('bias: '+str(bias))
|
|
print('amplitude: '+str(ampl))
|
|
print('phase: '+str(phase*360./2/np.pi))
|
|
print('homeoffset: '+str(-phase*360./2/np.pi*1000))
|
|
|
|
def gen_code():
|
|
pos=np.arange(0,360000,12000)
|
|
mot=range(1,6)
|
|
#mot=range(1,2)
|
|
for m in mot:
|
|
print('''open prog %i
|
|
call15
|
|
abslinear
|
|
'''%(10+m))
|
|
for p in pos:
|
|
print(""" jog%i=%i
|
|
dwell 5000"""%(m,p))
|
|
print(""" jog%i=0
|
|
call16
|
|
close
|
|
"""%(m,))
|
|
for m in mot:
|
|
print("&1;b%ir"%(10+m))
|
|
|
|
def plot():
|
|
'''
|
|
&1;b11r
|
|
&1;b12r
|
|
&1;b13r
|
|
&1;b14r
|
|
&1;b15r
|
|
'''
|
|
data1=[0,-.475,-1.123,-1.916,-2.819,-3.797,-4.799,-5.786,-6.708,-7.531,-8.219,-8.746,-9.085,-9.229,-9.176,-8.929,-8.499,-7.895,-7.142,-6.271,-5.320,-4.325,-3.329,-2.377,-1.513,-.780,-.216,.151,.305,.241]
|
|
data2=[0,1.04,2.092,3.108,4.041,4.847,5.496,5.946,6.184,6.196,5.976,5.540,4.907,4.110,3.181,2.162,1.103,0.051,-.953,-1.859,-2.639,-3.252,-3.677,-3.892,-3.893,-3.677,-3.256,-2.648,-1.878,-.980]
|
|
data3=[0,.296,0.785,1.445,2.248,3.160,4.146,5.165,6.170,7.120,7.968,8.676,9.210,9.541,9.660,9.564,9.274,8.807,8.154,7.340,6.398,5.378,4.318,3.271,2.310,1.485,.790,.282,-.028,-.130,]
|
|
data4=[0,-1.035,-2.021,-2.930,-3.713,-4.333,-4.777,-5.018,-5.057,-4.888,-4.522,-3.967,-3.249,-2.393,-1.430,-0.402,.650,1.678,2.633,3.470,4.146,4.626,4.887,4.916,4.711,4.297,3.69,2.917,2.010,1.021]
|
|
data5=[0,-.847,-1.786,-2.794,-3.815,-4.808,-5.727,-6.537,-7.194,-7.681,-7.987,-8.089,-7.990,-7.688,-7.204,-6.547,-5.745,-4.831,-3.840,-2.814,-1.799,-.844,0.015,.726,1.257,1.58,1.683,1.562,1.223,.685]
|
|
data=[data1,data2,data3,data4,data5]
|
|
for d in data:
|
|
meas_rot_ctr(d,1)
|
|
plt.plot(d)
|
|
plt.show()
|
|
gen_code()
|
|
plot()
|
|
|
|
|