enhance triggering
This commit is contained in:
@@ -1140,6 +1140,7 @@ zamofing_t@ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python$
|
||||
|
||||
cp -farL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py \
|
||||
~/Documents/prj/SwissFEL/PBTools/pbtools/ \
|
||||
~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/src/triggerSync/triggerSync \
|
||||
/sf/bernina/config/swissmx/zamofing_t/
|
||||
cp -farL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/ShapePathAnalyser/*.py \
|
||||
/sf/bernina/config/swissmx/zamofing_t/ShapePathAnalyser/
|
||||
|
||||
@@ -44,7 +44,7 @@ class MotionBase:
|
||||
self.meta={'srv_per':ServoPeriod,'pt2pt_time':40,'sync_flag':0,'sync_mode':2}
|
||||
self.meta.update(kwargs)
|
||||
|
||||
def setup_sync(self, crdId=1, prgId=2,verbose=False):
|
||||
def setup_sync(self, crdId=1, prgId=2,verbose=False, timeOfs=0.):
|
||||
'''setup the timing synchronization for the motion program
|
||||
kwargs:
|
||||
sync_mode : default=2
|
||||
@@ -122,7 +122,7 @@ class MotionBase:
|
||||
sftp.put(src, dst)
|
||||
sftp.chmod(dst, 0o755)
|
||||
cmd = 'LD_LIBRARY_PATH=/opt/ppmac/libppmac/ ' + dst
|
||||
cmd+=' %g %d'%(pt2pt_time,arg)
|
||||
cmd+=' %g %g %d'%(pt2pt_time,timeOfs,arg)
|
||||
self.cmdSync = cmd
|
||||
print ('starting '+cmd)
|
||||
self.syncShell=comm.shell_channel(cmd)
|
||||
|
||||
@@ -56,7 +56,8 @@ class MPLCanvasErr(FigureCanvas):
|
||||
hl += ax.plot(erry, 'g-',label='y-error')
|
||||
hl += ax.plot(err, 'r-',label='error')
|
||||
|
||||
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)'%meta['timebase'])
|
||||
tb=meta['srv_per']*meta['acq_per']
|
||||
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)'%tb)
|
||||
ax.yaxis.set_label_text('pos-error um')
|
||||
legend = ax.legend(loc='upper right', shadow=True)
|
||||
ax.plot([.5,.5],[0.01, 0.99],'k',transform=ax.transAxes)
|
||||
|
||||
@@ -59,7 +59,8 @@ class MPLCanvasVelo(FigureCanvas):
|
||||
hl += ax.plot(velAct, 'r-',label='vel act')
|
||||
hl += ax.plot(velDes, 'r--',label='vel des')
|
||||
|
||||
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)'%meta['timebase'])
|
||||
tb=meta['srv_per']*meta['acq_per']
|
||||
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)'%tb)
|
||||
ax.yaxis.set_label_text('um/ms')
|
||||
legend = ax.legend(loc='upper right', shadow=True)
|
||||
#axvline(linewidth=4, color='r')
|
||||
@@ -143,9 +144,9 @@ class MAVelocityFrame(wx.Frame):
|
||||
try:
|
||||
vel=doc.vel
|
||||
except AttributeError:
|
||||
tb=meta['timebase']
|
||||
tb=meta['srv_per']*meta['acq_per']
|
||||
#data points are um
|
||||
#datapoint timebase: 2 ms () per data point
|
||||
#datapoint tb= timebase of datapoint sampling
|
||||
#velocity: um/ms (deltatau desVel= motor units per serco cycle)
|
||||
rec=doc.fh['rec']
|
||||
velyAct = np.diff(rec[:, 0])/tb
|
||||
|
||||
@@ -289,7 +289,7 @@ class DebugPlot:
|
||||
idxTrigger = np.where(np.diff(idxTrigger) == 1)[0] + 1
|
||||
if idxTrigger.shape[0] > 0:
|
||||
hl += ax.plot(rec[idxTrigger, 1], rec[idxTrigger, 0], 'xr', label='trig') # actual path
|
||||
hl2 += ax2.plot(rec[:, 4], 'b-', label='trigger')
|
||||
hl2 += ax2.plot(rec[:, 4]*10, 'b-', label='trigger')
|
||||
|
||||
ax.xaxis.set_label_text('x-pos um')
|
||||
ax.yaxis.set_label_text('y-pos um')
|
||||
@@ -854,7 +854,8 @@ if __name__=='__main__':
|
||||
#sp.gen_closed_shifted()
|
||||
#sp.gen_swissmx_points(width=1000,ofs=(-500,0))
|
||||
#sp.gen_swissfel_points(width=1000,ofs=(-500,0))
|
||||
sp.gen_rand_points(n=2000, scale=1000);sp.sort_points(xy=False)
|
||||
#sp.gen_rand_points(n=20, scale=100,ofs=(-950,+2780));sp.sort_points(xy=False)
|
||||
sp.gen_rand_points(n=200, scale=100,ofs=(0,+2000));sp.sort_points(xy=False)
|
||||
#sp.gen_swissmx_points(width=1000, ofs=(-500, 0));
|
||||
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0))
|
||||
#sp.gen_spiral_points(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0))
|
||||
@@ -868,7 +869,7 @@ if __name__=='__main__':
|
||||
gtMaxLn=116508;ovhdTime=100
|
||||
acq_per=int(np.ceil((sp.meta['pt2pt_time']*sp.points.shape[0]+ovhdTime)/(gtMaxLn*sp.meta['srv_per'])))
|
||||
sp.setup_gather(acq_per=acq_per)
|
||||
sp.setup_sync(verbose=args.verbose&32)
|
||||
sp.setup_sync(verbose=args.verbose&32,timeOfs=0.55)
|
||||
sp.setup_coord_trf() # reset to shape path system
|
||||
#sp.meta['pt2pt_time']=10 #put between setup_sync and setup_motion to have more motion points than FEL syncs
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1.,dwell=10)
|
||||
|
||||
1
python/triggerSync
Symbolic link
1
python/triggerSync
Symbolic link
@@ -0,0 +1 @@
|
||||
../src/triggerSync/triggerSync
|
||||
BIN
src/triggerSync/triggerSync
Executable file
BIN
src/triggerSync/triggerSync
Executable file
Binary file not shown.
@@ -33,7 +33,7 @@
|
||||
extern struct SHM *pshm;
|
||||
static char mode=0;
|
||||
static float mtPt2Pt=40.f; //motion point to point time
|
||||
|
||||
static float timeOfs=0.f; //time ofset
|
||||
#define CLOCK_RES 1e-9 //Clock resolution is 1 ns by default
|
||||
|
||||
#define SIMFLAG0 (pshm->Coord[1].Q[10])
|
||||
@@ -115,10 +115,11 @@ void trigsync_func(void *arg)
|
||||
scStart=scLast=pshm->ServoCount;
|
||||
mtAct=0.f;
|
||||
pshm->Coord[1].Q[0]=0;
|
||||
pshm->Coord[1].DesTimeBase=srvPer; //start motion at default speed
|
||||
srvPer=0.2f;
|
||||
//pshm->Coord[1].DesTimeBase=srvPer; //start motion at default speed
|
||||
pshm->Coord[1].DesTimeBase=srvPer*(mtPt2Pt+timeOfs)/mtPt2Pt; //start motion at default speed
|
||||
if(mode&8)
|
||||
printf("Start: %d, rtDiff: %.3f ms scDiff %d mtAct %.3f mtDes %.3f srvPer %.6f\n", i, rtLast/1E6,scLast, mtAct,mtDes,srvPer);
|
||||
|
||||
printf("Start: rtStart:%.3f ms scStart:%d mtAct:%.3f mtDes:%.3f srvPer:%.6f\n", i, rtLast/1E6,scLast, mtAct,mtDes,srvPer);
|
||||
|
||||
for(i=1;pshm->Gather.Enable;i++)
|
||||
{
|
||||
@@ -145,12 +146,12 @@ void trigsync_func(void *arg)
|
||||
scDiff=scCur-scLast;
|
||||
|
||||
mtAct+=scDiff*srvPer;
|
||||
mtDes=i*mtPt2Pt;
|
||||
mtDes=i*mtPt2Pt+timeOfs;
|
||||
srvPer=(mtPt2Pt+mtDes-mtAct)/scDiff;
|
||||
pshm->Coord[1].DesTimeBase=srvPer;
|
||||
pshm->Coord[1].Q[0]++;
|
||||
if(mode&8)
|
||||
printf("Trigger count: %d, rtDiff: %.3f ms scDiff %d mtAct %.3f mtDes %.3f srvPer %.6f\n", i, rtDiff/1E6,scDiff, mtAct,mtDes,srvPer);
|
||||
printf("Trigger count:%d, rtDiff:%.3fms scDiff:%d mtAct:%.3f mtDes:%.3f srvPer:%.6f\n", i, rtDiff/1E6,scDiff, mtAct,mtDes,srvPer);
|
||||
rtLast=rtCur;
|
||||
scLast=scCur;
|
||||
}
|
||||
@@ -179,8 +180,8 @@ void trigsim_func(void *arg)
|
||||
|
||||
for(i=0,rtSlice=rtStart;;i++)
|
||||
{
|
||||
//rtSlice=rtStart+i*40*1E6; // a slice is 40 ms
|
||||
rtSlice=rtStart+i*40.2*1E6; // a slice is 40 ms
|
||||
rtSlice=rtStart+i*40*1E6; // a slice is 40 ms
|
||||
//rtSlice=rtStart+i*40.2*1E6; // a slice is 40 ms
|
||||
//rtSlice+=(rand()%(int)(1*1E6)); //0.1ms jitter
|
||||
rt_task_sleep_until(rtSlice); //in ns
|
||||
if(mode&4)
|
||||
@@ -296,7 +297,7 @@ Coord[1].Q[0]= 0 : got frame trigger 0\n\
|
||||
Coord[1].Q[0] is incremented at each trigger\n\
|
||||
sync task ends when Gather.Enable==0\n\
|
||||
";
|
||||
printf("usage:\n%s pt2ptTime mode\n",cmd);
|
||||
printf("usage:\n%s pt2ptTime timeOfs mode\n",cmd);
|
||||
puts(s);
|
||||
return -1;
|
||||
}
|
||||
@@ -307,15 +308,22 @@ int main(int argc, char *argv[])
|
||||
int initialized=0;
|
||||
int i;
|
||||
char *s;
|
||||
if(argc!=3)
|
||||
if(argc!=4)
|
||||
return usage(argv[0]);
|
||||
mtPt2Pt= strtof(argv[1], &s);
|
||||
mtPt2Pt=strtof(argv[1], &s);
|
||||
if (argv[1]==s)
|
||||
return usage(argv[0]);
|
||||
mode= (int)strtol(argv[2], &s, 10);
|
||||
timeOfs=strtof(argv[2], &s);
|
||||
if (argv[2]==s)
|
||||
return usage(argv[0]);
|
||||
|
||||
mode=(int)strtol(argv[3], &s, 10);
|
||||
if (argv[3]==s)
|
||||
return usage(argv[0]);
|
||||
puts(argv[0]);
|
||||
puts(argv[1]);
|
||||
puts(argv[2]);
|
||||
puts(argv[3]);
|
||||
printf("mtPt2Pt:%g timeOfs:%g mode:%d\n",mtPt2Pt,timeOfs,mode);
|
||||
if ((err = InitLibrary()) != 0) {
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="triggerSync.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3035" topLine="181" />
|
||||
<Cursor1 position="6215" topLine="189" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="Makefile" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
|
||||
Reference in New Issue
Block a user