optimize section fw/bw by row

This commit is contained in:
2024-11-22 09:35:00 +01:00
parent ec54867904
commit ae7882651e
2 changed files with 53 additions and 32 deletions

View File

@@ -62,6 +62,7 @@ ssh root@$PPMAC
sendgetsends -1
cmdt.py -tpbg -p EXPMX1
caqtdm -macro P=SAR-EXPMX SwissMX_exp.ui
'''
import logging
@@ -733,11 +734,12 @@ class ShapePath(MotionBase):
(tmove+twait will be rounded to a multiple of fel_per)
mode:6 pvt motion 'hit and return using grid parameters. continous motion on 2n ells to pump then same 2n wells to probe, then go 2 rows down
common kwargs plus:
trf : transformation that will be done on 'grid points'
grid : grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
ssz : section size (in wells)
smv : time(in num of shots) to move to next section (horiz/vert)
swait: wait after <swait> section for motion trigger. swait=0:never wait
trf : transformation that will be done on 'grid points'
grid : grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
ssz : section size (in wells)
smv : time(in num of shots) to move to next section (horiz/vert)
default is (ssz[0]-1,ssz[1]+1)
sdelay: shots count of delay. Default is ssz[0]*ssz[1]
'''
#scan=0 # snake motion X fast, Y slow
scan=1 # snake motion Y fast, X slow (default)
@@ -849,9 +851,16 @@ class ShapePath(MotionBase):
px, py=(1,1)
self.mot_pts=(np.hstack((pt, np.ones((pt.shape[0], 1))))*np.asmatrix(trf)).A # pt*trf
sx,sy=kwargs['ssz'] #section size (in wells)
tmx,tmy=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert)
swait=kwargs['smv'] #wait after <swait> section for motion trigger. swait=0:never wait
try:
tmx,tmy=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert)
except KeyError as e:
tmx=sx-1
tmy=sy+1
try:
sdl=kwargs['sdelay']
except KeyError as e:
sdl=sx*sy
sdl+=1-sx*sy # sdl are shots to wait at position #(6)
prg+=f' linear abs\n X{ox-px:g} Y{oy-py:g}\n' # start one position out of grid
prg+=' dwell 10\n'
try: prg+=self.sync_prg
@@ -862,7 +871,10 @@ class ShapePath(MotionBase):
prg+=' P100=%d\n'%cnt
prg+='N100:\n'
if mode in (1,3):
prg+=' pvt%g abs\n'%pt2pt_time # 100ms to next position
prg+=f'''\
//mode {mode}: pvt motion with each point in program code
pvt{pt2pt_time} abs
'''
for idx in range(1,pv.shape[0]):
#prg+=f'N{idx} ' + 'X%g:%g Y%g:%g\n'%tuple(pv[idx,(0,2,1,3)])
prg+=f' X%g:%g Y%g:%g\n'%tuple(pv[idx, (0, 2, 1, 3)])
@@ -874,10 +886,9 @@ class ShapePath(MotionBase):
else: # scan=1
vx=px/(pt2pt_time)*scale*CoordFeedTime #scaling for Deltatau
vy=py/(pt2pt_time)*scale*CoordFeedTime #scaling for Deltatau
prg+=f'''\
//mode 4: grid pvt motion
pvt{pt2pt_time} abs
//grid pvt motion
L1=0 //slow loop x
L0=0 //fast loop y
while(L1<{nx})
@@ -956,10 +967,9 @@ close
enable plc 2
'''
comm.gpascii.send_block(syncPlc, verb&0x08)
prg+=f'''\
//mode 5: grid pvt motion
pvt{tmove} abs
//grid pvt motion
L1=0 //slow loop x
L0=0 //fast loop y
while(L1<{nx})
@@ -1020,14 +1030,14 @@ enable plc 2
vsx=px/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau
vsy=py/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau
#variables
m,x0,y0,n,dx,dy,x1,y1,t,vx,vy=map(lambda x: f'L{x}',range(11))
r,x0,y0,n,dx,dy,x1,y1,t,vx,vy=map(lambda x: f'L{x}',range(11))
prg+=f'''\
//hit-and-return pvt motion
{m}=0
//mode 6: hit-and-return pvt motion
{r}=0 // row
{x0}=0;{y0}=-1;{n}=0 // counter well in region
{dx}=0;{dy}=1 // motion pitch
{x1}=0;{y1}=0 // counter region start
{t}=1 // motion pvt tome scaling
{dx}=0;{dy}=1 // motion pitch
{x1}=0;{y1}=0 // counter region start
{t}=1 // motion pvt time scaling
pvt{pt2pt_time} abs
while(1){{
{x0}+={dx};{y0}+={dy}
@@ -1054,12 +1064,18 @@ enable plc 2
}}
}}else if ({y0}==0){{
if ({n}==1 && {x0}==1){{ // (7 or 8)
if ({x1}+2*{sx}<={nx}){{// (7)
if ({r}%2==0 && {x1}+2*{sx}<={nx}){{ // (7 even)
{x1}+={sx}
{vx}={vsx};{vy}=0
pvt{pt2pt_time*tmx} abs;{t}={tmx}
}}else if ({y1}+2*{sy}<={ny}){{// (8)
{x1}=0;{y1}+={sy}
}}
else if ({r}%2==1 && {x1}>0){{ //(7 odd)
{x1}-={sx}
{vx}=-{vsx};{vy}=0
pvt{pt2pt_time*tmx} abs;{t}={tmx}
}}
else if ({y1}+2*{sy}<={ny}){{ //(8)
{y1}+={sy};{r}+=1
{vx}=0;{vy}={vsy}
pvt{pt2pt_time*tmy} abs;{t}={tmy}
}}else{{
@@ -1071,6 +1087,7 @@ enable plc 2
}}else if ({x0}==1){{ // (6)
{dx}=-1;{dy}=0;{n}+=1
{vx}=-{vsx};{vy}=0
pvt{pt2pt_time*sdl} abs;{t}={tmy}
}}else if ({x0}==0){{ // (0)
{dx}=0;{dy}=1
{vx}=0;{vy}={vsy}
@@ -1261,10 +1278,6 @@ if __name__=='__main__':
num_pts=gp.points.shape[0]
except AttributeError as e:
num_pts=np.array(grid['count'], np.int32).prod()
if mode==6:
ssz=(4,5) # section size (in wells)
smv=(4-1,grid['count'][0]//2) # time(in num of shots) to move to next section (horiz/vert)
swait=0 # wait after <swait> section for motion trigger. swait=0:never wait
try:
num_pts=gp.points.shape[0]
except AttributeError as e:
@@ -1284,7 +1297,13 @@ if __name__=='__main__':
elif mode==5:
sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=5,grid=grid,tmove=tmove,twait=twait)
elif mode==6:
sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=6,grid=grid,ssz=ssz,smv=smv,swait=swait)
grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(16, 20)}
# section size (in wells)
ssz=(4, 5)
#ssz=(6, 10)
#ssz=(2, 5)
#sdelay=ssz[0]*ssz[1] # wait after <swait> section for motion trigger. swait=0:never wait
sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=6,grid=grid,ssz=ssz)
else:
raise(ValueError(f'unsupported mode:{mode}'))