tuning Servo Parameters of XY stage without load and horizontal on the table
This commit is contained in:
@@ -26,7 +26,7 @@ import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
import subprocess as sprc
|
||||
import telnetlib
|
||||
import telnetlib, re
|
||||
from utilities import *
|
||||
|
||||
os.environ['PATH']='/home/zamofing_t/scripts/:'+os.environ['PATH']
|
||||
@@ -38,8 +38,9 @@ class MoveRecord:
|
||||
self.fnNpz=fn+'.npz'
|
||||
#cfg = {"sequencer": ['prog_1(host="SAROP11-CPPM-MOT6871",acq_per=10)', 'plot_1()']}
|
||||
#cfg = {"sequencer": ['plot_1()']}
|
||||
cfg = {"sequencer": ['prog_2(host="SAROP11-CPPM-MOT6871",acq_per=10)', 'plot_2()']}
|
||||
#cfg = {"sequencer": ['prog_2(host="SAROP11-CPPM-MOT6871",acq_per=10)', 'plot_2()']}
|
||||
#cfg = {"sequencer": ['plot_2()']}
|
||||
cfg = {"sequencer": ['prog_3(host="SAROP11-CPPM-MOT6871",acq_per=10)', 'plot_2()']}
|
||||
self.cfg=dotdict(cfg)
|
||||
self.args=args
|
||||
|
||||
@@ -98,7 +99,7 @@ class MoveRecord:
|
||||
meta = self.meta
|
||||
channels = self.channels
|
||||
fnLoc='/tmp/gather.txt'
|
||||
rec = np.genfromtxt(fnLoc, delimiter=' ')
|
||||
self.rec=rec=np.genfromtxt(fnLoc, delimiter=' ')
|
||||
# rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos
|
||||
# res=rot.ActPos,y.ActPos,x.ActPos,rot.DesPos,y.DesPos,x.DesPos
|
||||
# idx 0 1 2 3 4 5
|
||||
@@ -119,7 +120,7 @@ class MoveRecord:
|
||||
self.file=file
|
||||
self.host=host
|
||||
self.gather={"MaxSamples":1000000, "Period":acq_per}
|
||||
self.channels=["Motor[3].ActPos","Motor[3].DesPos","Motor[3].PhasePos","Motor[3].idMeas","Motor[3].iqMeas"]
|
||||
self.channels=channels=["Motor[3].ActPos","Motor[3].DesPos","Motor[3].PhasePos","Motor[3].idMeas","Motor[3].iqMeas"]
|
||||
self.meta=meta = {'timebase': ServoPeriod*self.gather['Period']}
|
||||
|
||||
self.prg=prg=[]
|
||||
@@ -130,21 +131,27 @@ class MoveRecord:
|
||||
prg=self.prg
|
||||
|
||||
prg.append(' linear abs')
|
||||
prg.append('jog3=100')
|
||||
prg.append('jog3=300')
|
||||
prg.append('dwell 100')
|
||||
prg.append('Gather.Enable=2')
|
||||
#for spd in (5,10,20,30,40):
|
||||
#for spd in (10,20):
|
||||
for spd in (10,10,10,10,20,20,20,20,20,20):
|
||||
prg.append('Motor[3].JogSpeed=%d'%spd)
|
||||
#prg.append('jog3=27000')
|
||||
prg.append('jog3=28500')
|
||||
prg.append('dwell 100')
|
||||
prg.append('jog3=100')
|
||||
prg.append('jog3=300')
|
||||
prg.append('dwell 100')
|
||||
prg.append('Gather.Enable=0')
|
||||
|
||||
meta['HomePos']=-4885.72 #set the value of Motor[3].HomePos
|
||||
self.prg_epilog()
|
||||
rec=self.rec
|
||||
meta['HomePos']=rec[0,1]-300 #rec[0,1]= first DesPos, 300 um is the start position of the motion
|
||||
print meta
|
||||
if self.fnNpz:
|
||||
np.savez_compressed(self.fnNpz, rec=rec, prg=prg, channels=channels, meta=meta)
|
||||
|
||||
#!mx-stage()
|
||||
# &1 #1->0
|
||||
# &1 #2->0
|
||||
@@ -170,6 +177,7 @@ class MoveRecord:
|
||||
channels=self.channels
|
||||
meta=self.meta
|
||||
except AttributeError:
|
||||
print 'load file %s'%self.fnNpz
|
||||
fh=np.load(self.fnNpz)
|
||||
rec=fh['rec']
|
||||
prg=list(fh['prg'])
|
||||
@@ -385,6 +393,60 @@ class MoveRecord:
|
||||
plt.show()
|
||||
|
||||
|
||||
def prog_3(self,prgId=2,host=None,acq_per=1):
|
||||
'''
|
||||
kwargs:
|
||||
acq_per : acquire period: acquire data all acq_per servo loops (default=1)
|
||||
prgId : used program number
|
||||
file : used filename to save if None, not saved
|
||||
host : host to send and execute program, if None, nothing is executed
|
||||
'''
|
||||
ServoPeriod= .2 #0.2ms Sys.ServoPeriod is dependent of !common() macro
|
||||
|
||||
self.prgId=prgId
|
||||
self.file=file
|
||||
self.host=host
|
||||
self.gather={"MaxSamples":1000000, "Period":acq_per}
|
||||
self.channels=channels=["Motor[3].ActPos","Motor[3].DesPos","Motor[3].PhasePos","Motor[3].idMeas","Motor[3].iqMeas"]
|
||||
self.meta=meta = {'timebase': ServoPeriod*self.gather['Period']}
|
||||
|
||||
self.prg=prg=[]
|
||||
#prg.append('#1..3$')
|
||||
#prg.append('#1..3j/')
|
||||
|
||||
self.prg_prolog()
|
||||
prg=self.prg
|
||||
|
||||
fh=open('/tmp/shapepath.prg','r')
|
||||
lines=fh.read().splitlines()
|
||||
fh.close()
|
||||
prg.extend(lines[11:-3])
|
||||
self.prg_epilog()
|
||||
#print '\n'.join(prg)
|
||||
rec=self.rec
|
||||
lines[12]
|
||||
x0=float(re.match('X(\S+)\sY\S+',lines[12]).group(1))
|
||||
meta['HomePos']=rec[0,1]-x0 #rec[0,1]= first DesPos is x0, the start position of the motion
|
||||
print meta
|
||||
if self.fnNpz:
|
||||
np.savez_compressed(self.fnNpz, rec=rec, prg=prg, channels=channels, meta=meta)
|
||||
|
||||
|
||||
# &1 #1->0
|
||||
# &1 #2->0
|
||||
# #3$
|
||||
# an anschlag (kabel) bewegen
|
||||
# #3hmz
|
||||
# Motor[3].PhasePos=1200 # or for motor 2: Motor[2].PhasePos=300
|
||||
# #3j/
|
||||
# &1p
|
||||
|
||||
|
||||
#folgende parameter setzen: Motor[3].HomePos
|
||||
meta['HomePos']=-223.8 #Motor[3].HomePos
|
||||
meta['PhasePos']=1200 #Motor[3].PhasePos
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
from optparse import OptionParser, IndentedHelpFormatter
|
||||
class MyFormatter(IndentedHelpFormatter):
|
||||
|
||||
Reference in New Issue
Block a user