From 544ff43caced2d6ccd1419fa097f610f4d7a2371 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Tue, 20 Oct 2015 17:02:59 +0200 Subject: [PATCH] Collimator tests fixed/improved --- script/tests/config/CollimatorTests | Bin 11431 -> 23652 bytes script/tests/tests.properties | 2 +- .../Motor Test 1/Motor Test 1.py | 41 +++--- .../Collimator Tests pro/Motor Test 2/.config | 2 +- .../Motor Test 2/Motor Test 2.py | 133 +++++++++--------- .../Motor Test 2/help.html | 7 +- .../Motor Test 3/Motor Test 3.py | 9 +- 7 files changed, 101 insertions(+), 93 deletions(-) diff --git a/script/tests/config/CollimatorTests b/script/tests/config/CollimatorTests index ccabe1279e1c4ca3996de93c1292478a125dbfed..51e3e3f2f4c5676d317aae5b56288d31d350b930 100644 GIT binary patch literal 23652 zcmeHP>2DlK6>r-~Hg>$h;gDE9p!xvITHqPtB#RVB5sppRNj$dk*g3G1rDvwb)4M(0 z?XKz>TOs7Wl>5GjkOCX!0}|4L6c+x1uwDW}`++Zf;t~>(0<27&ogUt+?wQGqW3R_{ zjAK=6x~977y{cbTy?XVkkN4AmDodHIG`yvz)quk_J+O_&xM~0K>fZkSEkCQOQEEcU zs+el2F^!LejF?SR)Zihdp6VjjW;zD%S629!?J8Hf@|pe)EHJ36#$d23`W6(~GHfZ{ z(dgKDf&dZ(e1dbo-SMLa)~Hu2ilF@_8&ZDY^C-$n2d`@2dL`gpCGZOFO{S?+)%bwe z`#=2Q_`_buI)w5mH4O5uw4tMBe=Zr|3_*%oQ)h;XH`%iluhHG*xc69HGW-XvfXNEkKZjHo2k8R{i5GnG<}IN>JYNlM~04Jf}xR7N0qgm5iI zftCTCk*{O_bQ<6z) zu_TT>w@n>{2jnAW>bjOvVJWKiUtJ@IWm={pZ zG&TgI8(~(YO+5{wl`_+U-xI%{)dYpHrMyqiBG7G4#*2FBXt=~*GUu! zbx<-ij*Vz9)*3S%o6&q}pb-R7q3wW`Sk%_cIC*XDx~6Y@9m;`DjI%~jp_qep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&8@4u9=mJT=TSwTq9MaRFP6eN)@>XRAe1K zzJYhR6S&R(cE#K5JTIund{in&sT`$pl*(~YDM#2~&saI)_S#pDa&s+Tjg+rO%2y*7 z!>f@?BJdJ6S6V8x8IfxM18FBpJ5kz+(oTFq?8M^7%J7xWvd!Vv)jN9Ni?WEN>hNy3 z{Dw?^*h?0~hrQy1f@y!pE~qp3uJ14g@R|MmeDN>~fd9uAk7t9r{AIoQd;f11sOR}L zoH;@|4^PAA2&1=_8suXC)27g9UnlF&%LFVaBGs zFII3@QqCp3*$8Jcele452B+UdT)lpb!A~%F2fkb`uaiuz7AD0?nkS$olikOgQ@m3v zhsp7-nTU6?C)U%)TP{M-nU(lFnh$?B!j_S)6~M`jbgeMawF0Vz>5Ds3zl*`oG5E!E z^mikrR(ffg)JxM0HghFXyP%ir5~MG{a{UQ-7xZ!s;N)`cJ6M$N=@!0wx)~_G_i?2j z#ozyr8P0xZ{`fOml{*XU2Uw@vsH?ul^am7d6Y(gVJX zDTyRC;meSC2lzrRO~-E}S*g3i_Q{{gKZCdEqp%n&xgRs%9)xEwjsA>!|1TK)^;y1y zyDRLFX*mxTFl&omoGRO0mLRV8+!IH@)wKg-xn(ABJ!aq0v3F52igN;VMcDWH0)7m* Z@G}gknbCi6!cc0+S6@B_?jsl4mSo;B!nXNi9++C`v8M%r7l2VPGg>;0Xxw zcQY`unmm`IX|n^H9Mfi7?o!st3gKLnO__uyA8-s4=PG2VW8f+PlORH{7(@z9zOS0c zD6zRvTZsj(Jkcqe6y=$!@uVnUuOCT@@_aYK%H>$Nz`kJz1_i@pLng7w!tU::[;::] -parameters=repeatTimes:1:Repeat N times;midPoint:41.0:Middle point A;spanFromMidPoint:2.0:B steps around middle point A +parameters=repeatTimes:1:Repeat N times;midPoint:41.0:Middle point A [mm];spanFromMidPoint:2.0:B steps around middle point A [integer];translationStep:5.0:Step lenght [mm] diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py b/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py index 7fef0f6..09e806a 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 2/Motor Test 2.py @@ -28,60 +28,57 @@ def startTest(testName, DEVICE, params): middle = float(test.getParam("midPoint")) loopTimes = int(test.getParam("repeatTimes")) span = float(test.getParam("spanFromMidPoint")) - settlingTime = 0.2 #seconds + translationStep = float(test.getParam("translationStep")) # each translation will be this amount of mm + settlingTime = 0.2 # seconds except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() success = False test.sendFeedback(ret, success) return - scan = ManualScan(['time [1/'+ str(1/settlingTime) + ' s]'], ['Motor Pos (IST3:2)', 'Poti Position (IST2:1)', + scan = ManualScan(['time [1/'+ str(1/settlingTime) + ' s]'], ['Btvs Poti Position (IST3:2)', 'Mcs Poti Position (IST2:1)', 'Motor Status (STA:1)', 'Inkr (INKR:2)', 'InkrRb (INKRRB:2)', 'Diameter (DIAM:2)', 'Logical Position (IST:2)', - 'Motor Pos Raw (IST3:1)','Poti Pos From Beam (IST1:2)', + 'Btvs Raw (IST3:1)','Motor Position (IST1:2)', 'Poti Raw (POSA:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) scan.setPlotName(plotName) scan.start() # coloured plot (one colour per scan) - p1 = plot(None, name="Poti-Increment difference", context=plotName + " difference")[0] - p2 = plot(None, name="Poti-MotorPosition difference", context=plotName + " difference")[0] + p1 = plot(None, name="Motor Position - Btvs Poti Position", context=plotName + " difference")[0] # Creating channels: dimension 1 try: idMotorStatus = Channel(DEVICE + ':STA:1' , type = 'd') # DSP device_status reg idLogicalPosition = Channel(DEVICE + ':IST:2' , type = 'd') # Shows current position in logical units as calculated from motor step counter [1..n] idPotiRaw = Channel(DEVICE + ':POSA:1' , type = 'd') # poti raw data [ADC units] - idMotorPositionRaw = Channel(DEVICE + ':IST3:1' , type = 'd') # shows current position in steps as as obtained from motor step counter [steps] + idBtvsRaw = Channel(DEVICE + ':IST3:1' , type = 'd') # shows current position in steps as as obtained from motor step counter [steps] idInkr = Channel(DEVICE + ':INKR:2' , type = 'd') # move relative distance (positive means towards R2) [mm] idInkrRb = Channel(DEVICE + ':INKRRB:2' , type = 'd') # readback of move relative distance (positive means towards R2) [mm] idDiameter = Channel(DEVICE + ':DIAM:2' , type = 'd') # collimator diameter [mm] - idMotorPosition = Channel(DEVICE + ':IST3:2' , type = 'd') # current position as from motor step counter [mm] - idPotiPosFromBeam = Channel(DEVICE + ':IST1:2' , type = 'd') # current position from beam as from potentiometer [mm] + idBtvs = Channel(DEVICE + ':IST3:2' , type = 'd') # current position as from motor step counter [mm] + idMotorPosition = Channel(DEVICE + ':IST1:2' , type = 'd') # current position from beam as from potentiometer [mm] idPotiPosition = Channel(DEVICE + ':IST2:1' , type = 'd') # current position as from potentiometer [mm] idPotiRef1Position = Channel(DEVICE + ':REF1:1' , type = 'd') # R1 position as from potentiometer [mm] idPotiRef2Position = Channel(DEVICE + ':REF2:1' , type = 'd') # R2 position as from potentiometer [mm] + idCom = Channel(DEVICE + ':COM:2' , type = 'd') # motor commands [0=Stop; 1=Calibrate; 2=gotoR1; 3=gotoR2] except: ret = 'Unable to create channel - ' + traceback.format_exc() success = False test.sendFeedback(ret, success) return - direction = 1.0 - startDefault = middle - span - endDefault = middle + span - end = endDefault + 1 + # find position: it will be the middle point of the test + test.log('Moving to initial position R1') + idCom.put(2, timeout=None) # go to R1 start limit test.log('Moving to middle point ' + str(middle)) idInkr.put(middle, timeout=None) # TODO: Set appropriate timeout - readback2 = idInkr.get() if abs(readback2 - middle) > 5: # TODO: Check accuracy - ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str( - readback2) + ')' + ret = 'Actor idInkr could not be set to the value ' + str(middle) + ' (current value: ' + str(readback2) + ')' success = False test.sendFeedback(ret, success) return - start = readback2 + direction - countSteps = 0 + direction = 1.0 count = 0 test.log('Moving around middle point (+-' + str(span) + ')') for setpoint1 in range(0, (loopTimes * 2)): @@ -89,18 +86,17 @@ def startTest(testName, DEVICE, params): sleep(5) # Settling time p1.addSeries(LinePlotSeries("Run" + str(count))) # RegionPositioner idInkr - for setpoint2 in frange(start, end, direction): - readback1 = setpoint1 - idInkr.put(setpoint2, timeout=None) # TODO: Set appropriate timeout + for setpoint2 in range(0, span+1): + idInkr.put(translationStep*direction, timeout=None) sleep(settlingTime) # Settling time - readback2 = idInkr.get() + currentTime = float(java.lang.System.currentTimeMillis()) MotorStatus = idMotorStatus.get() LogicalPosition = idLogicalPosition.get() PotiRaw = idPotiRaw.get() - MotorPositionRaw = idMotorPositionRaw.get() + BtvsRaw = idBtvsRaw.get() + Btvs = idBtvs.get() MotorPosition = idMotorPosition.get() - PotiPosFromBeam = idPotiPosFromBeam.get() PotiPosition = idPotiPosition.get() PotiRef1Position = idPotiRef1Position.get() PotiRef2Position = idPotiRef2Position.get() @@ -108,86 +104,87 @@ def startTest(testName, DEVICE, params): Inkr = idInkr.get() InkrRb = idInkrRb.get() - idDiff01 = PotiPosition - MotorPosition - countSteps = countSteps + 1 - scan.append([setpoint2], [setpoint2], - [MotorPosition, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, LogicalPosition, - MotorPositionRaw, PotiPosFromBeam, PotiRaw, PotiRef1Position, PotiRef2Position]) - p1.getSeries(count).appendData(setpoint2, idDiff01) - if (direction > 0.0 and setpoint2 >= end - 1): + idDiff01 = MotorPosition - Btvs + + # plots + scan.append([currentTime], [currentTime], + [Btvs, PotiPosition, MotorStatus, Inkr, InkrRb, Diameter, LogicalPosition, + BtvsRaw, MotorPosition, PotiRaw, PotiRef1Position, PotiRef2Position]) + # plot error against position + p1.getSeries(count).appendData(MotorPosition, idDiff01) + + # end of loop: invert direction + if setpoint2 == span: + direction = direction*(-1.0) + break + + # check if reached end of span before the end of loop; if so, invert direction + if (direction > 0.0 and MotorPosition >= middle+span): # invert direction and swap start with end of translation - end = startDefault - 1 - start = setpoint2 - direction direction = -1.0 - test.log('End of span (' + str(setpoint2) + '), changing direction to ' + str(direction)) + test.log('End of span (' + str(MotorPosition) + '), changing direction to towards R1') break - if (direction < 0.0 and setpoint2 <= end + 1): + if (direction < 0.0 and MotorPosition <= middle-span): # invert direction and swap start with end of translation - end = endDefault + 1 - start = setpoint2 - direction direction = 1.0 - test.log('End of span (' + str(setpoint2) + '), changing direction to ' + str(direction)) + test.log('End of span (' + str(MotorPosition) + '), changing direction to towards R2') break - - #extract Status bits - endH = bool(int(MotorStatus) & 8) #Ref2 (high limit) - endL = bool(int(MotorStatus) & 4) #Ref1 (low limit) - - #check if arrived to R1 or R2; if so, invert direction + # extract Status bits + endH = bool(int(MotorStatus) & 8) # Ref2 (high limit) + endL = bool(int(MotorStatus) & 4) # Ref1 (low limit) + # check if arrived to R1 or R2; if so, invert direction if endH: # invert direction and swap start with end of translation - end = startDefault - 1 - start = setpoint2 - direction direction = -1.0 - test.log('Reached R2 switch, changing direction to ' + str(direction)) + test.log('Reached R2, changing direction to ' + str(direction)) break elif endL: # invert direction and swap start with end of translation - end = endDefault + 1 - start = setpoint2 - direction direction = 1.0 - test.log('Reached R1 switch, changing direction to ' + str(direction)) + test.log('Reached R1, changing direction to ' + str(direction)) break - #check if any error bit is raised - if bool(int(MotorStatus) & int('10000',2)): #error: abort test - test.sendFeedback('Motor switched off (bit#4)', False) + + # check if any error bit is raised + if bool(int(MotorStatus) & int('10000',2)): # error: abort test + test.sendFeedback('Motor switched off (bit# 4)', False) return - if bool(int(MotorStatus) & int('100000',2)): #error: abort test - test.sendFeedback('No motor link (bit#5)', False) + if bool(int(MotorStatus) & int('100000',2)): # error: abort test + test.sendFeedback('No motor link (bit# 5)', False) return - if bool(int(MotorStatus) & int('1000000',2)): #error: abort test - test.sendFeedback('No poti link (bit#6)', False) + if bool(int(MotorStatus) & int('1000000',2)): # error: abort test + test.sendFeedback('No poti link (bit# 6)', False) return - if bool(int(MotorStatus) & int('10000000',2)): #error: abort test - test.sendFeedback('Calibration error (bit#7)', False) + if bool(int(MotorStatus) & int('10000000',2)): # error: abort test + test.sendFeedback('Calibration error (bit# 7)', False) return - if bool(int(MotorStatus) & int('100000000',2)): #error: abort test - test.sendFeedback('Cannot get to R1 (bit#8)', False) + if bool(int(MotorStatus) & int('100000000',2)): # error: abort test + test.sendFeedback('Cannot get to R1 (bit# 8)', False) return - if bool(int(MotorStatus) & int('1000000000',2)): #error: abort test - test.sendFeedback('Cannot get to R2 (bit#9)', False) + if bool(int(MotorStatus) & int('1000000000',2)): # error: abort test + test.sendFeedback('Cannot get to R2 (bit# 9)', False) return - if bool(int(MotorStatus) & int('10000000000',2)): #error: abort test - test.sendFeedback('Position measurement mismatch (bit#10)', False) + if bool(int(MotorStatus) & int('10000000000',2)): # error: abort test + test.sendFeedback('Position measurement mismatch (bit# 10)', False) return - if bool(int(MotorStatus) & int('100000000000',2)): #error: abort test - test.sendFeedback('Movement timeout (bit#11)', False) + if bool(int(MotorStatus) & int('100000000000',2)): # error: abort test + test.sendFeedback('Movement timeout (bit# 11)', False) return # Closing channels idMotorStatus.close() idLogicalPosition.close() idPotiRaw.close() - idMotorPositionRaw.close() + idBtvsRaw.close() + idBtvs.close() idMotorPosition.close() - idPotiPosFromBeam.close() idPotiPosition.close() idPotiRef1Position.close() idPotiRef2Position.close() idDiameter.close() idInkr.close() idInkrRb.close() + idCom.close() scan.end() ret = 'Slide moved back and forth (' + str(count) + ' runs)' diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html b/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html index f5bddb1..1fa73d6 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html +++ b/script/tests/tests/Collimator Tests pro/Motor Test 2/help.html @@ -5,9 +5,10 @@ Oscillate around a specified position

Details

Go to absolute position A, then move +B steps, then -2B steps, then +2Bsteps (ie oscillate round centre position, logging after each movement); repeat N times

Parameters

-repeatTimes Repeat the Initialisation N times
-midPoint Position A -spanFromMidPoint The B steps +repeatTimes Repeat N times
+midPoint Position A [mm]
+spanFromMidPoint The B steps [integer]
+translationStep Length of the movement per each traslation step [mm]

Contact

Marco Boccioli diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py b/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py index 707c3c4..e01781f 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 3/Motor Test 3.py @@ -33,7 +33,7 @@ def startTest(testName, DEVICE, params): test.sendFeedback(ret, success) return - scan = ManualScan(['traslation'], [ + scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], [ 'Btvs Poti Position (IST3:2)', 'Mcs Poti Position (IST2:1)', 'Motor Status (STA:1)', @@ -101,6 +101,7 @@ def startTest(testName, DEVICE, params): idInkr.put(translation*direction, timeout=10) sleep(samplePeriod) # Settling time + currentTime = float(java.lang.System.currentTimeMillis()) MotorStatus = idMotorStatus.get() LogicalPosition = idLogicalPosition.get() @@ -119,7 +120,7 @@ def startTest(testName, DEVICE, params): countSteps = countSteps + (translation*direction) # multi plot - scan.append([countSteps], [countSteps],[ + scan.append([currentTime], [currentTime],[ Btvs, PotiPosition, MotorStatus, @@ -132,8 +133,8 @@ def startTest(testName, DEVICE, params): PotiRaw, PotiRef1Position, PotiRef2Position]) - # draw curve to multi curve plot - p1.getSeries(count).appendData(setpoint2, idDiff01) + # draw diff against steps + p1.getSeries(count).appendData(countSteps, idDiff01) #extract Status bits endH = bool(int(MotorStatus) & 8) #Ref2 (high limit)