diff --git a/python/shapepath.py b/python/shapepath.py index 5fa5fec..b3504c8 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -864,6 +864,7 @@ class ShapePath(MotionBase): hrs=HitReturnSim() pt=hrs.sim_motion(mode=0xff if verb&0x20 else 0x00 , **kwargs) pt=np.array(pt)[:,:2] + try: trf=kwargs['trf'] except KeyError as e: @@ -1199,19 +1200,25 @@ enable plc 2 tx,ty=nx//sx,ny//sy #total sections #variables - cx,cy,dx,dy,n,k,t,vx,vy,x,x0,y,y0=map(lambda x: f'L{x}',range(13)) + cx,cy,dx,dy,n,k,t,vx,vy,x,x0,y,y0,w=map(lambda x: f'L{x}',range(14)) # replace in python code of hit_and_return.py setup_motion: # (cx|cy|dx|dy|n|k|sx|sy|tsd|tsx|tsy|tx|ty|vsx|vsy|vx|vy|x|x0|y|y0) -> {\1} # if ([^:]*): -> if \(\1\){{ # else: -> }}else{{ # elif ([^:]*): -> }}else if \(\1\){{ + # w=L13: number of Sys.Udata[1] ticks the *currently queued* segment is expected to + # consume (mirrors {t}); the post-move wait blocks for exactly this many ticks + # instead of always 1, so scaled segments (tsd/tsx/tsy, at keypoints 6/7/8) + # don't get treated as 'done' after only 1/{t} of their commanded duration. tmove = kwargs['tmove'] twait = kwargs['twait'] fel_per = meta['fel_per'] pt2tp_felpulse = round((tmove + twait) / fel_per) # number of fel-pulses for a whole cycle (tmove+twait) + print("pt2tp_felpulse = {0}".format(pt2tp_felpulse)) meta['pt2pt_time'] = fel_per * pt2tp_felpulse + print("pt2tp_time = {0}".format(meta['pt2pt_time'])) twait_ = round((tmove + twait) / fel_per) * fel_per - tmove if twait != twait_: _log.warning(f'adjust twait({twait}) to {twait_} to match multiple of fel-cycles') @@ -1240,6 +1247,7 @@ enable plc 2 prg += f'''\ //mode 7: stop-go-and-return pvt motion {t}=1 // motion pvt tome scaling + {w}=1 // ticks to wait for the currently queued segment {k}=-1 // key position {cx}=0;{cy}=0 // section counter {x0}=0;{y0}=0;{n}=0 // counter well in region @@ -1267,7 +1275,9 @@ enable plc 2 {x0}+={dx};{y0}+={dy} //send 1"move(%d) X%g:0 Y%g:0",{k},{ox}+{x}*{px},{oy}+{y}*{py} X({ox}+{x}*{px}):0 Y({oy}+{y}*{py}):0 - while(Sys.Udata[2]==Sys.Udata[1]){{}};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger + {w}={t} // this segment was queued with pvt time = pt2pt_time*{t}: wait for {t} shots, not 1 + while((Sys.Udata[1]-Sys.Udata[2])<{w}){{}} + Sys.Udata[2]=Sys.Udata[2]+{w} // advance by exactly the ticks this segment consumed if ({t}!=1){{ pvt{pt2pt_time} abs;{t}=1 }}