diff --git a/Readme.md b/Readme.md index c2b14f5..dae64bc 100644 --- a/Readme.md +++ b/Readme.md @@ -201,6 +201,63 @@ sequenceDiagram deactivate py ``` +12.2.25: debugging motion code +----------------------------------------------------------- +``` +&1b2r +go to <&>coordsystem <1> eginning of program <2> and un + +s step one line +q quit program +a abort motion program +bpset set breakpoints + +list plc2,10,3 + list 3 lines strating from line 10 + +list pc + show program counter + &1b2r + +open prog 3 + linearabs + X2Y1 + dwell10 + X0Y3 + dwell10 + X3Y3 + dwell10 + X3Y0 + dwell10 + X0Y0 +close + +&1b3 + +cpx linearabs X1Y1 + +//return coordinate transcormation of all axes (in coordinate system 1) +&1 #1..8-> + +&1p // returns coordinate positions in 'wells' (in coordinate system 1) +X1.000208333333334 Y1.000104166666666 + +#1..2p + +//show were the program is: +list pc +list pc, // with line numbers + +Coord[1].ProgRunning +Coord[1].ProgActive +Coord[1].ProgProceeding +Coord[1].Program.Lsize +Coord[1].Program.Number +Coord[1].Program.Size +Coord[1].Program.Store +``` + + ------------------------------- Work log ======== diff --git a/src/triggerSync/Readme.md b/src/triggerSync/Readme.md index fbb8fed..bf4f679 100644 --- a/src/triggerSync/Readme.md +++ b/src/triggerSync/Readme.md @@ -1,8 +1,6 @@ triggerSync =========== - - ``` samples: root@:/opt/ppmac# /tmp/triggerSync 40 11 trigger all 40 ms, simulated start, use real frame triggers, verbose @@ -102,3 +100,128 @@ caput SAR-EXPMX-EVR0:FrontUnivOut4-Src-Pulse-SP 0 Gather.Enable=0 # end triggerSync ``` +19.3.25: Debug environment for real trigger +------------------------------------------- +``` +cmdt.py -tpbg -p EXPMX # select SAR-CPPM-EXPMX1 +``` + +## record user motion +``` +open prog 3 + linearabs + X0Y0 + dwell100 + L0=0 + pvt10abs + while(L0<50) + { + X1:0Y0:0 + X2:0Y0:0 + X3:0Y0:0 + X3:0Y1:0 + X2:0Y1:0 + X1:0Y1:0 + L0+=1 + } + dwell10 + linearabs + X10Y10 +close +PBGatherPlot -r2 --ssh_tunnel -p 'disp:2,scl:{pos1:[1,-2,0],pos2:[-1,-4,0],Chan0.UserFlag:[1,1],Chan1.UserFlag:[2,1]},time:10,acq_per:1,motId:[1,2],address:"Sys.ServoCount,Gate3[1].Chan[0].UserFlag,Gate3[1].Chan[1].UserFlag,Motor[1].MoveTimer,Coord[1].DesTimeBase,Motor[{motId[0]}].ActPos,Motor[{motId[0]}].DesPos,Motor[{motId[1]}].ActPos,Motor[{motId[1]}].DesPos"' +&1b3r +PBGatherPlot -r2 --ssh_tunnel -n +``` +## run triggerSync (sim start, real frame, adjust speed) +``` +// #define FLAG0 (gate3_1->Chan[0].Status&0x800) +// #define FLAG1 (gate3_1->Chan[1].Status&0x800) +// -> Gate3[1].Chan[0].UserFlag # acquire start event +// -> Gate3[1].Chan[1].UserFlag # frame trigger +Gather.Enable=1 // else triggerSync stops if value is 0 +Coord[1].Q[0]=0 // simulate motion not ready (!=-3) +LD_LIBRARY_PATH=/opt/ppmac/libppmac/ /tmp/triggerSync 11 10 0 # trigger all 10 ms, sim start real frame triggers, with sync, verbose +Coord[1].Q[0]=-3 // simulate motion ready +Coord[1].Q[10]=1 // simulate acquisition start +Gather.Enable=0 // end TriggerSync +``` +## record user motion with triggerSync (sim start, real frame, adjust speed) +``` +open prog 3 + linearabs + X0Y0 + dwell100 + Coord[1].TimeBaseSlew=1 + Coord[1].DesTimeBase=0 + Coord[1].Q[0]=-3 // simulate motion ready + + dwell100 + Coord[1].Q[10]=1 // simulate acquisition start + dwell100 + L0=0 + pvt10abs + while(L0<50) + { + X1:0Y0:0 + X2:0Y0:0 + X3:0Y0:0 + X3:0Y1:0 + X2:0Y1:0 + X1:0Y1:0 + L0+=1 + } + dwell10 + linearabs + X10Y10 + Gather.Enable=0 +close +Gather.Enable=1 // else triggerSync stops if value is 0 +Coord[1].Q[0]=0 // simulate motion not ready (!=-3) +LD_LIBRARY_PATH=/opt/ppmac/libppmac/ /tmp/triggerSync 11 10 0 # trigger all 10 ms, sim start real frame triggers, with sync, verbose +PBGatherPlot -r2 --ssh_tunnel -p 'exec:"&1b3r",disp:2,scl:{pos1:[1,0,0],pos2:[1,0,0],Chan0.UserFlag:[1,1],Chan1.UserFlag:[2,1],DesTimeBase:[100,0]},time:10,acq_per:1,motId:[1,2],address:"Sys.ServoCount,Gate3[1].Chan[0].UserFlag,Gate3[1].Chan[1].UserFlag,Motor[1].MoveTimer,Coord[1].DesTimeBase,Motor[{motId[0]}].ActPos,Motor[{motId[0]}].DesPos,Motor[{motId[1]}].ActPos,Motor[{motId[1]}].DesPos"' +``` + + +## other user motion code +``` +open prog 3 + Coord[1].DesTimeBase=Sys.ServoPeriod + linearabs + X1Y2 + dwell100 + Coord[1].TimeBaseSlew=1 + Coord[1].DesTimeBase=0 + Coord[1].Q[0]=-3 // simulate motion ready + dwell100 + Coord[1].Q[10]=1 // simulate acquisition start + dwell100 + L0=0 + while(L0<60) + { + pvt(10+int(L0/10)*10)abs + X1:0Y2:0 + X2:0Y2:0 + X3:0Y2:0 + X3:0Y3:0 + X2:0Y3:0 + X1:0Y3:0 + L0+=1 + } + dwell10 + linearabs + X10Y10 + Gather.Enable=0 +close + + + + + + + + +exec + + + +``` diff --git a/src/triggerSync/triggerSync b/src/triggerSync/triggerSync index 4c1e861..2e60ea8 100755 Binary files a/src/triggerSync/triggerSync and b/src/triggerSync/triggerSync differ diff --git a/src/triggerSync/triggerSync.c b/src/triggerSync/triggerSync.c index a3a0519..0c52fa3 100644 --- a/src/triggerSync/triggerSync.c +++ b/src/triggerSync/triggerSync.c @@ -165,7 +165,7 @@ void trigsync_func(void *arg) // rtDiff > mtPt2Pt -> increase srvPer // rtDiff < mtPt2Pt -> decrease srvPer mvTimer=pshm->Motor[1].MoveTimer; //time in current section - if(mvTimer>mtPt2Pt/2) //lagging + while(mvTimer>mtPt2Pt/2) //lagging mvTimer-=mtPt2Pt; //srvPer2*=(rtDiff/1E6-mvTimer)/mtPt2Pt; srvPer=pshm->ServoPeriod*(rtDiff/1E6-mvTimer)/mtPt2Pt; @@ -174,6 +174,22 @@ void trigsync_func(void *arg) pshm->Coord[1].Q[0]++; if(mode&8) { + + #define C_D "\033[0m" // default + #define C_R "\033[31m" // red + #define C_G "\033[32m" // green + #define C_Y "\033[33m" // yellow + #define C_RR "\033[91m" // red(bright) + #define C_GG "\033[92m" // green(bright) + #define C_YY "\033[93m" // yellow(bright) + #define C_B "\033[1m" // bold + #define C_U "\033[4m" // underline + #define C_RB "\033[1;31m" // bold, red + #define C_GB "\033[1;32m" // bold, green + #define C_YB "\033[1;33m" // bold, yellow + + + mxActPos=pshm->Motor[2].ActPos;mxDesPos=pshm->Motor[2].DesPos; myActPos=pshm->Motor[1].ActPos;myDesPos=pshm->Motor[1].DesPos; mxErr=mxDesPos-mxActPos; @@ -181,7 +197,15 @@ void trigsync_func(void *arg) //printf(" X,Y ActPos:(%.5g %.5g) DesPos:(%.5g %.5g) ", mxActPos-mxHomePos, myActPos-myHomePos, mxDesPos-mxHomePos, myDesPos-myHomePos); //printf(" X,Y Nsync:(%d) ", pshm->Coord[1].Nsync); //printf(" X,Y MoveTimer:(%.5g %.5g) ", pshm->Motor[1].MoveTimer,pshm->Motor[2].MoveTimer); - printf("Trigger count:%d, Nsync:%d, MoveTimer:%.5g srvPer:%.6f rtDiff:%.3fms scDiff:%d PosErrXY:(%.3f,%.3f)\n",i, pshm->Coord[1].Nsync,mvTimer,srvPer, rtDiff/1E6,scDiff,mxErr,myErr); + if (fabs(mvTimer)>mtPt2Pt*.05) + fputs(C_RR, stdout); + else if (mvTimer<0) + fputs(C_YY, stdout); + else + fputs(C_GG, stdout); + printf("Trigger count:%d, Nsync:%d, MoveTimer:% 10.4g srvPer:%.6f rtDiff:%6.3fms scDiff:%d PosErrXY:(% 5.3f,% 5.3f)\n",i, pshm->Coord[1].Nsync,mvTimer,srvPer, rtDiff/1E6,scDiff,mxErr,myErr); + fputs(C_D, stdout); + } rtLast=rtCur; scLast=scCur;