tweaking phasefrq etc.

This commit is contained in:
2017-01-04 16:51:39 +01:00
parent a265d91f2f
commit 95eef8ccc2
13 changed files with 1329 additions and 9 deletions

View File

@@ -36,6 +36,13 @@ Sequencer functions are:
gen_prog(self,prgId=2,file=None,host=None)
if host=None nothing will be downloaded/executed and trace of motors will not be uploaded
if file=None the program will not be saved and nothing will be executed
gen_prog modes:
-1 jog a 10mm square
0 linear motion
1 pvt motion
2 spline motion
- plot gathered data
plot_gather()
this makes only sence, if motion has been executed and data can be gathered from the powerbrick
@@ -75,8 +82,11 @@ class ShapePath:
#cfg = {"points": [[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]],"sequencer": ['gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather()']}
#cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=-1)', 'plot_gather()']}
#cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=1000)', 'plot_gather()']}
cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather()']}
#cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather()']}
#cfg = {"sequencer": ['gen_rand_points(n=400, scale=1000)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather()']}
#cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=2,pt2pt_time=10)', 'plot_gather()']}
fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/mode2'
cfg = {"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=2,pt2pt_time=10)','plot_gather("'+fn+'.npz")']}
self.cfg=dotdict(cfg)
self.args=args
@@ -115,9 +125,11 @@ class ShapePath:
def gen_prog(self,prgId=2,file=None,host=None,mode=0,**kwargs):
prg=[]
gather={"MaxSamples":100000, "Period":1 }
#Sys.ServoPeriod= 0.2
self.meta = {'timebase': 0.2*gather['Period']}
gather={"MaxSamples":1000000, "Period":1}
#Sys.ServoPeriod is dependent of !common() macro
ServoPeriod= .2
#ServoPeriod = .05
self.meta = {'timebase': ServoPeriod*gather['Period']}
#channels=["Motor[1].ActPos","Motor[2].ActPos","Motor[3].ActPos"]
channels=["Motor[1].ActPos","Motor[2].ActPos","Motor[3].ActPos","Motor[1].DesPos","Motor[2].DesPos","Motor[3].DesPos"]
prg.append('Gather.Enable=0')
@@ -130,7 +142,7 @@ class ShapePath:
prg.append('open prog %d'%(prgId))
# this uses Coord[1].Tm and limits with MaxSpeed
if mode==-1:
if mode==-1: #### jog a 10mm square
pos=self.points
prg.append(' linear abs')
prg.append('X(%g) Y(%g)' % tuple(pos[0, :]))
@@ -145,7 +157,7 @@ class ShapePath:
prg.append('jog3:-10000')
prg.append('dwell 100')
prg.append('Gather.Enable=0')
elif mode==0:
elif mode==0: #### linear motion
pos=self.points
prg.append(' linear abs')
prg.append('X(%g) Y(%g)' % tuple(pos[0, :]))
@@ -156,7 +168,7 @@ class ShapePath:
prg.append('X%g Y%g'%tuple(pos[idx,:]))
prg.append('dwell 100')
prg.append('Gather.Enable=0')
elif mode==1:
elif mode==1: #### pvt motion
try:
pt2pt_time=kwargs['pt2pt_time'] #how many ms to move to next point (pt2pt_time)
except KeyError:
@@ -187,6 +199,26 @@ class ShapePath:
prg.append('X%g Y%g' % tuple(pv[-1, (0,1)]))
prg.append('dwell 1000')
prg.append('Gather.Enable=0')
elif mode==2: #### spline motion
try:
pt2pt_time=kwargs['pt2pt_time'] #how many ms to move to next point (pt2pt_time)
except KeyError:
print 'missing pt2pt_time, use default=100ms'
pt2pt_time=100.
pos=self.points
pcor=np.ndarray(pos.shape,dtype=pos.dtype);pcor[:]=np.NaN
pcor[(0,-1),:]=pos[(0,-1),:]
pcor[1:-1,:]=(-pos[0:-2,:]+8*pos[1:-1,:]-pos[2:,:])/6.
#pcor=pos
prg.append(' linear abs')
prg.append('X(%g) Y(%g)' % tuple(pcor[0, :]))
prg.append('dwell 10')
prg.append('Gather.Enable=2')
prg.append(' spline%g abs'%pt2pt_time) #100ms to next position
for idx in range(pcor.shape[0]):
prg.append('X%g Y%g'%tuple(pcor[idx,:]))
prg.append('dwell 100')
prg.append('Gather.Enable=0')
prg.append('close')
prg.append('&1\nb%dr\n'%prgId)
@@ -291,6 +323,7 @@ class ShapePath:
hl = ax.plot(err, 'r-')
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)' % meta['timebase'])
ax.yaxis.set_label_text('pos-error um')
print('average error %g um'%err.mean())
plt.show()
if __name__=='__main__':