enhance triggering

This commit is contained in:
2019-03-20 14:34:12 +01:00
parent eda8caf985
commit 399282cba9
9 changed files with 36 additions and 23 deletions

BIN
src/triggerSync/triggerSync Executable file

Binary file not shown.

View File

@@ -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();
}

View File

@@ -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">