diff --git a/PBinspect.pbi b/PBinspect.pbi index b8dcdcc..788b605 100644 --- a/PBinspect.pbi +++ b/PBinspect.pbi @@ -24,45 +24,134 @@ [ "WatchListCtrl", [ - ["EncTable[1].PrevEnc",null], - ["Motor[1].Pos","lambda v: '%.8g'%float(v)"], - ["Motor[1].DesPos","lambda v: '%.8g'%float(v)"], - ["Motor[1].PosError","lambda v: '%.8g'%float(v)"], - ["Motor[1].Servo.Integrator","lambda v: '%.8g'%float(v)"], - ["Motor[1].ServoOut","lambda v: '%.8g'%float(v)"], - ["Motor[1].idCmd","lambda v: '%.8g'%float(v)"], - ["Motor[1].iqCmd","lambda v: '%.8g'%float(v)"], - ["Motor[1].idMeas","lambda v: '%.8g'%float(v)"], - ["Motor[1].iqMeas","lambda v: '%.8g'%float(v)"], - ["Motor[1].iaMeas","lambda v: '%.8g'%float(v)"], - ["Motor[1].ibMeas","lambda v: '%.8g'%float(v)"], - ["Motor[1].I2tSum","lambda v: '%.8g'%float(v)"], - ["EncTable[2].PrevEnc",null], - ["Motor[2].Pos","lambda v: '%.8g'%float(v)"], - ["Motor[2].DesPos","lambda v: '%.8g'%float(v)"], - ["Motor[2].PosError","lambda v: '%.8g'%float(v)"], - ["Motor[2].Servo.Integrator","lambda v: '%.8g'%float(v)"], - ["Motor[2].ServoOut","lambda v: '%.8g'%float(v)"], - ["Motor[2].idCmd","lambda v: '%.8g'%float(v)"], - ["Motor[2].iqCmd","lambda v: '%.8g'%float(v)"], - ["Motor[2].idMeas","lambda v: '%.8g'%float(v)"], - ["Motor[2].iqMeas","lambda v: '%.8g'%float(v)"], - ["Motor[2].iaMeas","lambda v: '%.8g'%float(v)"], - ["Motor[2].ibMeas","lambda v: '%.8g'%float(v)"], - ["Motor[2].I2tSum","lambda v: '%.8g'%float(v)"], - ["EncTable[3].PrevEnc",null], - ["Motor[3].Pos","lambda v: '%.8g'%float(v)"], - ["Motor[3].DesPos","lambda v: '%.8g'%float(v)"], - ["Motor[3].PosError","lambda v: '%.8g'%float(v)"], - ["Motor[3].Servo.Integrator","lambda v: '%.8g'%float(v)"], - ["Motor[3].ServoOut","lambda v: '%.8g'%float(v)"], - ["Motor[3].idCmd","lambda v: '%.8g'%float(v)"], - ["Motor[3].iqCmd","lambda v: '%.8g'%float(v)"], - ["Motor[3].idMeas","lambda v: '%.8g'%float(v)"], - ["Motor[3].iqMeas","lambda v: '%.8g'%float(v)"], - ["Motor[3].iaMeas","lambda v: '%.8g'%float(v)"], - ["Motor[3].ibMeas","lambda v: '%.8g'%float(v)"], - ["Motor[3].I2tSum","lambda v: '%.8g'%float(v)"] + [ + "Motor[1].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[1].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[1].idMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[1].iqMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "EncTable[2].PrevEnc", + null + ], + [ + "Motor[2].Pos", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].DesPos", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].PosError", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].Servo.Integrator", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].idMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].iqMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].iaMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].ibMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[2].I2tSum", + "lambda v: '%.8g'%float(v)" + ], + [ + "EncTable[3].PrevEnc", + null + ], + [ + "Motor[3].Pos", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].DesPos", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].PosError", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].Servo.Integrator", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].ServoOut", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].idCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].iqCmd", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].idMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].iqMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].iaMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].ibMeas", + "lambda v: '%.8g'%float(v)" + ], + [ + "Motor[3].I2tSum", + "lambda v: '%.8g'%float(v)" + ], + [ + "P2000", + null + ], + [ + "P3000", + null + ] ], "name=w;caption=watch;state=67377148;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=200;besth=369;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=221;floaty=858;floatw=208;floath=377;notebookid=-1;transparent=255" ], diff --git a/cfg/init.cfg b/cfg/init.cfg new file mode 100644 index 0000000..e102288 --- /dev/null +++ b/cfg/init.cfg @@ -0,0 +1,68 @@ +define(PLC_Homing='1') + +open subprog 12 +enable plc PLC_Homing +close + +open plc PLC_Homing +define(status='P100',timer='P101') + +L20=Motor[2].MaxDac +Motor[2].MaxDac=500 +L21=Motor[2].FatalFeLimit +Motor[2].FatalFeLimit=2000 +L22=Motor[2].JogSpeed +Motor[2].JogSpeed=1 + +L30=Motor[3].MaxDac +Motor[3].MaxDac=500 +L31=Motor[3].FatalFeLimit +Motor[3].FatalFeLimit=2000 +L32=Motor[3].JogSpeed +Motor[3].JogSpeed=1 + + +Motor[2].PhaseFindingStep=1 +Motor[3].PhaseFindingStep=1 +timer = Sys.RunTime + 1;while (Sys.RunTime < timer){} //wait 1 sec + +Motor[2].HomeVel=2 +Motor[3].HomeVel=2 + +P200=Motor[2].HomeInProgress +home2 +home3 +timer = Sys.RunTime + 1;while (Sys.RunTime < timer){} //wait 1 sec +P201=Motor[2].HomeInProgress + +status=1 +while(1) +{ + if(Motor[2].FeFatal && (status&2)==0) + { + status=status|2 + Motor[2].HomeVel=-Motor[2].HomeVel + home2 + } + if(Motor[3].HomeInProgress==0 && (status&4)==0) + { + status=status|4 + Motor[3].HomeVel=-Motor[3].HomeVel + home3 + } + if(Motor[2].HomeInProgress==0 && Motor[3].HomeInProgress==0) + { + status=status|8 + break + } +} + +Motor[2].MaxDac=L20 +Motor[2].FatalFeLimit=L21 +Motor[2].JogSpeed=L22 +Motor[3].MaxDac=L30 +Motor[3].FatalFeLimit=L31 +Motor[3].JogSpeed=L32 + +disable plc PLC_Homing +close diff --git a/cfg/init_limit.cfg b/cfg/init_limit.cfg new file mode 100644 index 0000000..60f8309 --- /dev/null +++ b/cfg/init_limit.cfg @@ -0,0 +1,71 @@ +//home by bove to physical limits and set these to -5000um + +define(PLC_Homing='1') + +open plc PLC_Homing +define(status='P100',timer='P101') + +L20=Motor[2].MaxDac +Motor[2].MaxDac=500 +L21=Motor[2].FatalFeLimit +Motor[2].FatalFeLimit=2000 +L22=Motor[2].JogSpeed +Motor[2].JogSpeed=1 + +L30=Motor[3].MaxDac +Motor[3].MaxDac=500 +L31=Motor[3].FatalFeLimit +Motor[3].FatalFeLimit=2000 +L32=Motor[3].JogSpeed +Motor[3].JogSpeed=1 + + +Motor[2].PhaseFindingStep=1 +Motor[3].PhaseFindingStep=1 +timer = Sys.RunTime + 1;while (Sys.RunTime < timer){} //wait 1 sec + +jog-2; jog-3; + +status=1 +while(1) +{ + if(Motor[2].FeWarn==1 && (status&2)==0) + { + status=status|2 + jog/2 + Motor[2].PhasePos=310 + Motor[2].HomePos=Motor[2].ActPos+5000 + jog2=0 + } + if(Motor[3].FeWarn==1 && (status&4)==0) + { + status=status|4 + jog/3 + Motor[3].PhasePos=1210 + Motor[3].HomePos=Motor[3].ActPos+5000 + jog3=0 + } + if(status==7) + { + status=status|8 + break + } +} + +timer = Sys.RunTime + 2 +while (Sys.RunTime < timer){} //wait 2 sec +status=100 +timer = Sys.RunTime + 2 +status=200 +while (Sys.RunTime < timer){} //wait 2 sec +status=201 + +Motor[2].MaxDac=L20 +Motor[2].FatalFeLimit=L21 +Motor[2].JogSpeed=L22 +Motor[3].MaxDac=L30 +Motor[3].FatalFeLimit=L31 +Motor[3].JogSpeed=L32 + +disable plc PLC_Homing +close diff --git a/cfg/mx-stage.cfg b/cfg/mx-stage.cfg index ea43e0a..485513f 100644 --- a/cfg/mx-stage.cfg +++ b/cfg/mx-stage.cfg @@ -43,6 +43,7 @@ $$$*** //!common(PhaseFreq=40000) !torqueCtrl() +!init() &1 @@ -51,8 +52,8 @@ $$$*** //#3-> + .5X +1. Y + 0.01A #1-> A -#2-> Y -#3-> X +#2-> X +#3-> Y Coord[1].AltFeedRate=0 Coord[1].Tm=1 //1ms time diff --git a/cfg/torqueCtrl.cfg b/cfg/torqueCtrl.cfg index a7ae7ff..f0aaedf 100644 --- a/cfg/torqueCtrl.cfg +++ b/cfg/torqueCtrl.cfg @@ -53,8 +53,9 @@ Motor[1].pPhaseEnc=Acc84B[0].Chan[0].SerialEncDataA.a //use um as motor unit !encoder_sim(enc=2,tbl=10,mot=10,posSf=13000./2048) !encoder_inc(enc=2,tbl=2,mot=2,posSf=13000./650000) -!motor_servo(mot=2,ctrl='ServoCtrl',Kp=20,Kvfb=1000,Ki=0.07,Kvff=1000,Kaff=4000,MaxInt=1000) -!motor(mot=2,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=200,WarnFeLimit=100,InPosBand=2) +//!motor_servo(mot=2,ctrl='ServoCtrl',Kp=20,Kvfb=1000,Ki=0.07,Kvff=1000,Kaff=4000,MaxInt=1000) +!motor_servo(mot=2,ctrl='ServoCtrl',Kp=20,Kvfb=220,Ki=0.02,Kvff=240,Kaff=1500,MaxInt=1000) +!motor(mot=2,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=200,WarnFeLimit=100,InPosBand=2,homing='enc-index') //Stage X Parker MX80L (top stage, mounted on Y stage) @@ -68,7 +69,7 @@ Motor[1].pPhaseEnc=Acc84B[0].Chan[0].SerialEncDataA.a !encoder_inc(enc=3,tbl=3,mot=3,posSf=13000./650000) !motor_servo(mot=3,ctrl='ServoCtrl',Kp=20,Kvfb=220,Ki=0.02,Kvff=240,Kaff=1500,MaxInt=1000) //PhaseFreq=20000,PhasePerServo=1 -> Kvfb=220*4 Ki/=4,Kvff*=4,Kaff*=4*4 -!motor(mot=3,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=2000,WarnFeLimit=100,InPosBand=2) +!motor(mot=3,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=10.,numPhase=3,invDir=True,servo=None,PhasePosSf=1./81250,PhaseFindingDac=100,PhaseFindingTime=50,SlipGain=0,AdvGain=0,PwmSf=10000,FatalFeLimit=200,WarnFeLimit=100,InPosBand=2,homing='enc-index') //Interferometer 1 Stage Y Parker MX80L (bottom stage) //---------------------------------------------------- diff --git a/logbook.md b/logbook.md index 347a709..15af451 100644 --- a/logbook.md +++ b/logbook.md @@ -592,14 +592,299 @@ Grid path at speed: -Interferometer --------------- +Interferometer 11.4.2017 +------------------------ + + +adding to torqueCtrl lines: +!encoder_inc(enc=4,tbl=4,mot=4)# ,posSf=13000./650000) +!encoder_inc(enc=5,tbl=5,mot=5)# ,posSf=13000./650000) gpasciiCommander --host SAR-CPPM-EXPMX1 -i +!mx-stage() +#1..3$ +&1 +#1..3j/ -$$$*** +both interferometer works +homing and move: + +#2..5p +-0.04000000000000008 0.0200000000000023 -298.8984375 39.890625 +> #2j=10000;#3j=0000 +#2j=10000;#3j=0000 +> #2..5p +#2..5p +10000 2.380040609040179e-15 -500672.5625 4334.390625 +> #2j=0000;#3j=0000 +#2j=0000;#3j=0000 +> #2j=0000;#3j=10000 +#2j=0000;#3j=10000 +> #2..5p +#2..5p +-0.02000000000000006 10000 -3559.06640625 -499752.609375 + + + + +#2..5p +-0.08000000000000007 -0.003515624999636202 -0.5 7.2890625 + +#2j=10000 +#2..5p +9999.980000000001 -0.01000000000021828 4290.96875 -500362.453125 +#2j=0;#3j=10000 +#2..5p +0 9999.992812500001 -499789.3984375 -3260.984375 + +Interferometer have 500000 counts per 10000um = 50 counts per um =20nm +at Motor[2].JogSpeed=10 the interferometer can not follow the motion. +It will not loose steps, but the maximum frequency is limiting during motion. +at Motor[2].JogSpeed=10 the interferometer and the encoder delivers similar values. + + +interfero_move_rec.py + self.gather={"MaxSamples":1000000, "Period":acq_per} + self.channels=channels=["Motor[3].ActPos","Motor[3].DesPos","Motor[3].PhasePos","Motor[3].idMeas","Motor[3].iqMeas"] + +Gather.Enable=0 +Gather.Items=6 +Gather.MaxSamples=1000000 +Gather.Period=10 +Gather.Addr[0]=Motor[2].DesPos.a +Gather.Addr[1]=Motor[3].DesPos.a +Gather.Addr[2]=Motor[2].ActPos.a +Gather.Addr[3]=Motor[3].ActPos.a +Gather.Addr[4]=Motor[4].ActPos.a +Gather.Addr[5]=Motor[5].ActPos.a +open prog 2 + linear abs + X0 Y0 + dwell 10 + Gather.Enable=2 + X10000 Y0 + dwell 100 + X0 Y0 + dwell 100 + X0 Y10000 + dwell 100 + X0 Y0 + dwell 1000 +Gather.Enable=0 +close +&1 +b2r + +download data with +PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 + +cat /tmp/gather.txt + +Motor[2].MaxSpeed=50 +Motor[3].MaxSpeed=50 +->gather50.txt + +Motor[2].MaxSpeed=5 +Motor[3].MaxSpeed=5 +->gather5.txt + +Motor[2].MaxSpeed=1 +Motor[3].MaxSpeed=1 +->gather1.txt + +Changing encoder frequency on atto cube makes it run even at high speed + + +28. 4.2017 prepare for vibration measurement +-------------------------------------------- +PPMAC=SAR-CPPM-EXPMX1 + +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX +PBInspect --host $PPMAC --cfg PBinspect.pbi + +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/src/usrServo +make + + +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg +gpasciiCommander --host SAR-CPPM-EXPMX1 -i +!mx-stage() +#1..3$ +&1 +#1..3j/ + +#1j=360000 //360deg gegenuhrzeiger + +#2j:100 //100 um right +#3j:100 //100 um up + +move bottom left +#2,3$ +Motor[2].PhasePos;Motor[3].PhasePos + +Motor[2].PhasePos=310;Motor[3].PhasePos=1210 +#2,3hmz +Motor[3].HomePos=Motor[3].HomePos+15000 + + +Motor 2 vibriert mit 76ms =13.15 Hz + + +b2r +Load is now Alublock + mirrors + +at 50 Hz peak to peak 200um +at 100Hz peak to Peak 50um +at 200Hz peak to Peak 13um +at 400Hz peak to Peak 1.5um + + + +2. 5.2017 Vertical stage with load +---------------------------------- + + scale=0.83832 #np.sqrt(3)/2*32767/33.850/1000 + +Motor[3].I2tSet=670.65601 +670.65601/0.83832 = 800.000 + +ohne Platte iqCmd = 625 +Platte 133.2g iqCmd = 910 +Platte 156.8g iqCmd = 965 + +Motor[3].IaMeas=-660 +Motor[3].IbMeas=580 +Motor[3].IqMeas=634.15991 + + +Motor[3].IaMeas=-708 +Motor[3].IbMeas=256 + + + +Motor[3].IaMeas=436 =520 +Motor[3].IbMeas=-632 =-753 +Motor[3].IqMeas=566.46863 = 675 + + +Claude messungen: +Phase 1: 330mA +Phase 2: 125mA +Phase 3: 694mA + +Stromzange: 650 mA + + + +Interferometer 29.5.2017 +------------------------ +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX;PBInspect --cfg PBinspect.pbi --host SAR-CPPM-EXPMX1 + +gpasciiCommander --host SAR-CPPM-EXPMX1 -i +!mx-stage() +#1..3$ +&1 +#1..3j/ + +zero to neative inc values +move motor 2,3 from 500 to 28500 +#1..5hmz + +read acquire statements and program at to of plot_interfero.py + + +Motor[2].MaxSpeed=30;Motor[3].MaxSpeed=30 +Motor[2].MaxSpeed=10;Motor[3].MaxSpeed=10 + +PPMAC=SAR-CPPM-EXPMX1 +PBGatherPlot -m24 -v7 --host $PPMAC --dat gather1.txt + + +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather0.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather1.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather2.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather3.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather4.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather5.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather6.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather7.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather8.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather9.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather10.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather11.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather12.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather13.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather14.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather15.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather16.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather17.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather18.txt +b2r +!sh PBGatherPlot -m24 -v7 --host SAR-CPPM-EXPMX1 --dat ../data_interfero_spd10/gather19.txt + + +Konstantfeder 2.6.2017 +---------------------- + +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX;PBInspect --cfg PBinspect.pbi --host SAR-CPPM-EXPMX1 +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg/;gpasciiCommander --host SAR-CPPM-EXPMX1 -i +!mx-stage() + +//#1..3$ +//move bottom left +#2,3$ +Motor[2].PhasePos;Motor[3].PhasePos + +Motor[2].PhasePos=310;Motor[3].PhasePos=1210 +#2,3hmz +Motor[2].HomePos=Motor[2].HomePos+5000 +Motor[3].HomePos=Motor[3].HomePos+5000 + + +&1 + +#1..3j/ +#2..3j=0 +L2=Motor[2].MaxDac +L3=Motor[3].MaxDac + + +Motor[2].MaxDac=500 +#2j+ + +enable plc 1 + +Motor[2].HomeVel=2 +Motor[3].HomeVel=2 +#2,3$ + +Homing 12.6.2017 +--------------- + +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX;PBInspect --cfg PBinspect.pbi --host SAR-CPPM-EXPMX1 +cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg/;gpasciiCommander --host SAR-CPPM-EXPMX1 -i +!mx-stage() +//!init() +//!init_limit() + +enable plc 1 -!common() -!encoder_inc(enc=8,tbl=8,mot=8) -!encoder_inc(enc=1,tbl=1,mot=1) -!encoder_inc(enc=2,tbl=2,mot=2) diff --git a/python/MAError.py b/python/MAError.py index fbf4213..cc25517 100644 --- a/python/MAError.py +++ b/python/MAError.py @@ -133,8 +133,8 @@ class MAErrorFrame(wx.Frame): err=doc.err except AttributeError: rec=doc.fh['rec'] - errx = (rec[:, 2] - rec[:, 5]) - erry = (rec[:, 1] - rec[:, 4]) + errx = (rec[:, 1] - rec[:, 4]) + erry = (rec[:, 2] - rec[:, 5]) errxy = np.sqrt(errx ** 2 + erry ** 2) doc.err = err = (errx, erry, errxy) canvas.InitChild(meta,err) diff --git a/python/MAVelocity.py b/python/MAVelocity.py index b2ee517..ca4f245 100644 --- a/python/MAVelocity.py +++ b/python/MAVelocity.py @@ -148,10 +148,10 @@ class MAVelocityFrame(wx.Frame): #datapoint timebase: 2 ms () per data point #velocity: um/ms (deltatau desVel= motor units per serco cycle) rec=doc.fh['rec'] - velxAct = np.diff(rec[:, 2])/tb - velxDes = np.diff(rec[:, 5])/tb - velyAct = np.diff(rec[:, 1])/tb - velyDes = np.diff(rec[:, 4])/tb + velxAct = np.diff(rec[:, 1])/tb + velxDes = np.diff(rec[:, 4])/tb + velyAct = np.diff(rec[:, 2])/tb + velyDes = np.diff(rec[:, 5])/tb velAct = np.sqrt(velxAct**2+velyAct**2) velDes = np.sqrt(velxDes**2+velyDes**2) doc.vel = vel = (velxAct,velxDes,velyAct,velyDes,velAct,velDes) diff --git a/python/MAxyPlot.py b/python/MAxyPlot.py index 74a46df..b3889a9 100644 --- a/python/MAxyPlot.py +++ b/python/MAxyPlot.py @@ -59,8 +59,8 @@ class MPLCanvasImg(FigureCanvas): ax.add_collection(ec) - hl+=ax.plot(rec[:, 5], rec[:, 4], 'b-',label='recDesPos') - hl+=ax.plot(rec[:,2],rec[:,1],'g-',label='recActPos') + hl+=ax.plot(rec[:, 4], rec[:, 5], 'b-',label='recDesPos') + hl+=ax.plot(rec[:,1],rec[:,2],'g-',label='recActPos') ax.xaxis.set_label_text('x-pos um') ax.yaxis.set_label_text('y-pos um') @@ -267,13 +267,13 @@ class MAxyPlotFrame(wx.Frame): idx=usrData rec=self.doc.fh['rec'] hl=canvas.hl - hl[2].set_data(rec[:idx+1, 5], rec[:idx+1, 4]) - hl[3].set_data(rec[:idx+1, 2], rec[:idx+1, 1]) + hl[2].set_data(rec[:idx+1, 4], rec[:idx+1, 5]) + hl[3].set_data(rec[:idx+1, 1], rec[:idx+1, 2]) #ax.draw_artist(hl[2]) x=ax.get_xlim();x=(x[1]-x[0])/2; y=ax.get_ylim();y=(y[1]-y[0])/2; - ax.set_xlim(rec[idx, 2]-x,rec[idx, 2]+x) - ax.set_ylim(rec[idx, 1]-y,rec[idx, 1]+y) + ax.set_xlim(rec[idx, 1]-x,rec[idx, 1]+x) + ax.set_ylim(rec[idx, 2]-y,rec[idx, 2]+y) canvas.draw() @staticmethod diff --git a/python/plot_interfero.py b/python/plot_interfero.py new file mode 100755 index 0000000..6305f77 --- /dev/null +++ b/python/plot_interfero.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# *-----------------------------------------------------------------------* +# | | +# | Copyright (c) 2016 by Paul Scherrer Institute (http://www.psi.ch) | +# | | +# | Author Thierry Zamofing (thierry.zamofing@psi.ch) | +# *-----------------------------------------------------------------------* + +#Testing the interferometer +''' +zamofing_t@ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg$ gpasciiCommander --host $PPMAC -i +$$$*** +!common() +!mx-stage() + +Gather.Enable=0 +Gather.Items=6 +Gather.MaxSamples=1000000 +Gather.Period=10 +Gather.Addr[0]=Motor[2].DesPos.a +Gather.Addr[1]=Motor[3].DesPos.a +Gather.Addr[2]=Motor[2].ActPos.a +Gather.Addr[3]=Motor[3].ActPos.a +Gather.Addr[4]=Motor[4].ActPos.a +Gather.Addr[5]=Motor[5].ActPos.a +open prog 2 + linear abs + X1000 Y1000 + dwell 10 + Gather.Enable=2 + X28000 Y1000 + dwell 100 + X1000 Y1000 + dwell 100 + X1000 Y28000 + dwell 100 + X1000 Y1000 + dwell 1000 +Gather.Enable=0 +close +&1 +b2r + +download data with +PPMAC=SAR-CPPM-EXPMX1 +PBGatherPlot -m24 -v7 --host $PPMAC --dat gather.txt + +cat /tmp/gather.txt + +Motor[2].MaxSpeed=20;Motor[3].MaxSpeed=20 +Motor[2].MaxSpeed=5;Motor[3].MaxSpeed=5 +Motor[2].MaxSpeed=2 +Motor[3].MaxSpeed=2 +b2r + + + +''' + +import os, sys, json +import numpy as np +import matplotlib as mpl +import matplotlib.pyplot as plt +import subprocess as sprc +import telnetlib + +if __name__=='__main__': + def plot_gather(base): + #rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos + #res=rot.ActPos,y.ActPos,x.ActPos,rot.DesPos,y.DesPos,x.DesPos + #idx 0 1 2 3 4 5 + f1=plt.figure() + #f2 = plt.figure() + ax1 = f1.add_subplot(1,1,1) + #ax2 = f2.add_subplot(1, 1, 1) + + for fn in sorted(os.listdir(base)): + print fn + rec = np.genfromtxt(base+'/'+fn, delimiter=' ') + print rec.shape + + x=range(len(rec[:,0])) + #hl=ax[0].plot(x, y, color=col) + + hl=ax1.plot(x,-(rec[:,0]-rec[0,0]),'k') + hl=ax1.plot(x,-(rec[:,2]-rec[0,2]),'r') + hl=ax1.plot(x,-(rec[:,4]-rec[0,4])/100,'m') + hl=ax1.plot(x,rec[:,1]-rec[0,1],'k') + hl=ax1.plot(x,rec[:,3]-rec[0,3],'b') + hl=ax1.plot(x,-(rec[:,5]-rec[0,5])/100,'c') + + plt.show() + +#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/gather5/') +#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/gather50/') +#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/tmp/') +#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/data_interfero_spd10') +#plot_gather(base='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/data_interfero_spd20') +plot_gather(base='data_interfero_spd10') diff --git a/python/shapepath.py b/python/shapepath.py index 22a208b..3278b73 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -83,11 +83,11 @@ class ShapePath: #cfg = {"points": [[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]],"sequencer": ['gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=0)', 'plot_gather("'+fn+'.npz")']} #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=-1)', 'plot_gather("'+fn+'.npz")']} #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=1000)', 'plot_gather("'+fn+'.npz")']} - cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=50,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=10,acq_per=10)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=50,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=10,acq_per=10)', 'plot_gather("'+fn+'.npz")']} #cfg = {"sequencer": ['gen_rand_points(n=400, scale=1000)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} - #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=2,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} - #cfg = {"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=10,acq_per=1)','plot_gather("'+fn+'.npz")']} - cfg = {"sequencer": ['gen_swissfel_points(scale=300)','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=100,acq_per=10)', 'plot_gather("'+fn+'.npz")']} + cfg = {"sequencer": ['gen_grid_points(w=15,h=15,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=2,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=20,acq_per=10)','plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_swissfel_points(scale=300)','gen_prog(file="'+fn+'.prg",host="SAR-CPPM-EXPMX1",mode=1,pt2pt_time=100,acq_per=10)', 'plot_gather("'+fn+'.npz")']} self.cfg=dotdict(cfg) self.args=args @@ -281,10 +281,10 @@ class ShapePath: idx=np.ndarray(cnt,dtype=np.int32) grp_cnt=int(np.sqrt(cnt)) grp_sz=int(np.ceil(float(cnt)/grp_cnt)) - if self.args.yx==True: - idxA=0;idxB=1 - else: + if self.args.xy==True: idxA=1;idxB=0 + else: + idxA=0;idxB=1 #sort points along idxA pts=pts[pts[:,idxA].argsort()] @@ -327,10 +327,10 @@ class ShapePath: pts=self.points # X,Y array rec = np.genfromtxt(fnLoc, delimiter=' ') #rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos - #res=rot.ActPos,y.ActPos,x.ActPos,rot.DesPos,y.DesPos,x.DesPos + #res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos #idx 0 1 2 3 4 5 - ofsy=-rec[0,4]+pts[0,1] - ofsx=-rec[0,5]+pts[0,0] + ofsy=-rec[0,4]+pts[0,0] + ofsx=-rec[0,5]+pts[0,1] rec[:,(1,4)]+=ofsy rec[:,(2,5)]+=ofsx if fnOut: @@ -345,8 +345,8 @@ class ShapePath: #hl=ax[0].plot(x, y, color=col) hl=ax.plot(pts[:,0],pts[:,1],'r.') hl=ax.plot(pts[:,0],pts[:,1],'y--') - hl = ax.plot(rec[:, 5], rec[:, 4], 'b-') # desired path - hl=ax.plot(rec[:,2],rec[:,1],'g-') # actual path + hl = ax.plot(rec[:, 4], rec[:, 5], 'b-') # desired path + hl=ax.plot(rec[:,1],rec[:,2],'g-') # actual path ax.xaxis.set_label_text('x-pos um') ax.yaxis.set_label_text('y-pos um') cid = fig.canvas.mpl_connect('button_press_event', self.onclick) @@ -356,8 +356,8 @@ class ShapePath: fig = plt.figure() ax = fig.add_subplot(1, 1, 1) - errx=rec[:,2]-rec[:,5] - erry=rec[:,1]-rec[:,4] + errx=rec[:,1]-rec[:,4] + erry=rec[:,2]-rec[:,5] err=np.sqrt(errx**2+erry**2) hl = [] @@ -388,11 +388,8 @@ if __name__=='__main__': 'main command line interpreter function' #usage: gpasciiCommunicator.py --host=PPMACZT84 myPowerBRICK.cfg (h, t)=os.path.split(sys.argv[0]);cmd='\n '+(t if len(h)>3 else sys.argv[0])+' ' - exampleCmd=('--host=PPMAC1391 -m 63 --cfg gather.cfg', - 'samplePowerBrick.cfg', - '-n stackCheck1.cfg', - '--host=PPMACZT84 stackCheck1.cfg', - '--host=PPMACZT84 stackCheck1.cfg -v15', + exampleCmd=('-n', + '-v15' ) epilog=__doc__+''' Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' @@ -402,7 +399,7 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' parser.add_option('-v', '--verbose', type="int", dest='verbose', help='verbosity bits (see below)', default=0) parser.add_option('-n', '--dryrun', action='store_true', help='dryrun to stdout') - parser.add_option('--yx', action='store_true', help='sort y,x instead x,y') + parser.add_option('--xy', action='store_true', help='sort x,y instead y,x') parser.add_option('--cfg', help='config file containing json configuration structure') (args, other)=parser.parse_args() diff --git a/python/stage_rms_current.py b/python/stage_rms_current.py new file mode 100644 index 0000000..92a7373 --- /dev/null +++ b/python/stage_rms_current.py @@ -0,0 +1,44 @@ +#plot and calculate rms values of sine, six state trapezoidal etc. + +import numpy as np +import matplotlib as mpl +import matplotlib.pyplot as pyplot +pyplot.figure() +x=np.arange(360.) +y=np.sin(x/360.*2.*np.pi) +y1=x.copy() +y1[0: 60]=x[0:60]/60 +y1[ 60:120]=1 +y1[120:180]=1-x[0:60]/60 +y1[180:240]=-x[0:60]/60 +y1[240:300]=-1 +y1[300:360]=-1+x[0:60]/60 + +y2=x.copy() +y2[0: 30]=0 +y2[30:150]=1 +y2[150:210]=0 +y2[210:330]=-1 +y2[330:360]=0 + +y3=x.copy() +y3[0: 60]=.5 +y3[60:120]=1 +y3[120:180]=.5 +y3[180:240]=-.5 +y3[240:300]=-1 +y3[300:360]=-.5 + +pyplot.plot(x,y,x,y1,x,y2,x,y3);pyplot.show() + +rms=np.sqrt(np.mean(y**2)) +b=np.sqrt(2)/2 +rms1=np.sqrt(np.mean(y1**2)) +rms2=np.sqrt(np.mean(y2**2)) +rms3=np.sqrt(np.mean(y3**2)) +print rms,rms1,rms2,rms3,b + +print 0.8/rms, 0.8/rms1, 0.8/rms2, 0.8/rms3 + + +#https://e2e.ti.com/blogs_/b/motordrivecontrol/archive/2013/11/08/generate-your-own-commutation-table-trapezoidal-control-3-phase-bldc-motors-using-hall-sensors \ No newline at end of file diff --git a/qt/ESB_MX_exp.ui b/qt/ESB_MX_exp.ui new file mode 100644 index 0000000..b8a29ac --- /dev/null +++ b/qt/ESB_MX_exp.ui @@ -0,0 +1,236 @@ + + + Form + + + + 0 + 0 + 776 + 221 + + + + Form + + + + + 20 + 10 + 721 + 28 + + + + + 18 + 75 + true + + + + ESB MX $(P) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + 160 + 160 + 164 + + + + + + + 20 + 80 + 725 + 72 + + + + +P=$(P),M=MOTOR_ROT_Y1; +P=$(P),M=MOTOR_X1; +P=$(P),M=MOTOR_Y1 + + + ESB_MX_motor.ui + + + 3 + + + + + + 20 + 50 + 731 + 21 + + + + + 2 + + + + + + 0 + 0 + + + + DESC + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + VAL + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + RBV + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 25 + 0 + + + + + 20 + 16777215 + + + + LLS + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 25 + 0 + + + + + 20 + 16777215 + + + + HLS + + + Qt::AlignCenter + + + + + + + Motors Panels + + + Qt::AlignCenter + + + + + + + + + 640 + 160 + 100 + 22 + + + + Homing + + + $(P).ASYN + + + enable plc 1 + + + + + + caMessageButton + QPushButton +
caMessageButton
+
+ + caLabel + QLabel +
caLabel
+
+ + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/qt/ESB_MX_motor.ui b/qt/ESB_MX_motor.ui new file mode 100644 index 0000000..9b7d533 --- /dev/null +++ b/qt/ESB_MX_motor.ui @@ -0,0 +1,152 @@ + + + Form + + + + 0 + 0 + 725 + 24 + + + + Form + + + + 2 + + + 0 + + + 0 + + + 0 + + + 1 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + $(P):$(M).DESC + + + + + + + + 0 + 0 + + + + $(P):$(M).VAL + + + + + + + + 0 + 0 + + + + $(P):$(M).RBV + + + true + + + + + + + + 25 + 4 + + + + $(P):$(M).LLS + + + + + + + + 25 + 4 + + + + $(P):$(M).HLS + + + + + + + + 128 + 136 + 255 + + + + $(M) + + + motorx_all.ui + + + P=$(P):,M=$(M) + + + + + + + + caRelatedDisplay + QWidget +
caRelatedDisplay
+
+ + caTextEntry + caLineEdit +
caTextEntry
+
+ + caLed + QWidget +
caLed
+
+ + caLineEdit + QLineEdit +
caLineEdit
+
+
+ + +
diff --git a/src/usrServo/Makefile b/src/usrServo/Makefile index 2b95b4b..68a6abc 100644 --- a/src/usrServo/Makefile +++ b/src/usrServo/Makefile @@ -19,6 +19,9 @@ # arm,i386,i385hv,ppc460-2,ppc460-1,ppc405 #------------------------------------------------------------------------------ +PPMAC=SAR-CPPM-EXPMX1 +#PPMAC=SAROP11-CPPM-MOT6871 + PMAC_ARCH=ppc465-2 ifeq ($(PMAC_ARCH),ppc465-2) @@ -71,10 +74,10 @@ KBUILD_EXTRA_SYMBOLS := /usr/local/dtlibs/libppmac/Module.symvers # cp -f /usr/local/usralgo/usralgomain.c $(PWD) all: $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules - scp usralgo.ko root@SAROP11-CPPM-MOT6871:/tmp - scp pp_proj.ini root@SAROP11-CPPM-MOT6871:/var/ftp/usrflash/Project/Configuration/pp_proj.ini - scp pp_proj.ini root@SAROP11-CPPM-MOT6871:/tmp/pp_proj.ini - ssh root@SAROP11-CPPM-MOT6871 projpp + scp usralgo.ko root@$(PPMAC):/tmp + scp pp_proj.ini root@$(PPMAC):/var/ftp/usrflash/Project/Configuration/pp_proj.ini + scp pp_proj.ini root@$(PPMAC):/tmp/pp_proj.ini + ssh root@$(PPMAC) projpp # $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules V=1 # mv -f usralgo.ko ../../bin/Debug/