From eb2afd0221b5a6ca7880d59264a2bdbf040d3515 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Mon, 19 Oct 2015 15:29:09 +0200 Subject: [PATCH] Motor Test 3: Now it should work --- script/tests/tests.properties | 6 +- .../Motor Test 1/Motor Test 1.py | 2 +- .../Motor Test 3/Motor Test 3.py | 113 +++++++++++------- 3 files changed, 73 insertions(+), 48 deletions(-) diff --git a/script/tests/tests.properties b/script/tests/tests.properties index be3b0dd..f290eaa 100644 --- a/script/tests/tests.properties +++ b/script/tests/tests.properties @@ -1,5 +1,5 @@ #TestingList for pshell: configuration properties -#Fri Oct 16 15:40:43 CEST 2015 -customPanel= +#Mon Oct 19 15:22:19 CEST 2015 +customPanel=Kollimators showEnabledTestsOnly=true -listFilter=parallelizeOneTest +listFilter=LabTests2 diff --git a/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py b/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py index adf5bcf..6d4e4e2 100644 --- a/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py +++ b/script/tests/tests/Collimator Tests pro/Motor Test 1/Motor Test 1.py @@ -53,7 +53,7 @@ def startTest(testName, DEVICE, params): 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] - idCom = Channel(DEVICE + ':COM:2' , type = 'd') # current position as from motor step counter [mm] + idCom = Channel(DEVICE + ':COM:2' , type = 'd') # motor commands [0=Stop; 1=Calibrate; 2=gotoR1; 3=gotoR2] 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] idPotiPosition = Channel(DEVICE + ':IST2:1' , type = 'd') # current position as from potentiometer [mm] 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 edbb225..7c57e2f 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 @@ -23,8 +23,8 @@ def startTest(testName, DEVICE, params): try: test.log("Running test Motor Test 3 with the following parameters:") test.log(params) - loopTimes = int(test.getParam("repeatTimes")) - direction = int(test.getParam("translation")) + loopTimes = int(test.getParam("repeatTimes")) # C times + translation = int(test.getParam("translation")) # Increment mm samplePeriod = 0.2 #seconds except: test.log("Could not retrieve testing parameters: ", sys.exc_info()[0]) @@ -33,66 +33,81 @@ def startTest(testName, DEVICE, params): test.sendFeedback(ret, success) return - scan = ManualScan(['time [1/'+ str(1/samplePeriod) + ' s]'], ['Motor Pos (IST3:2)', '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)', - 'Poti Raw (POSA:1)', 'Poti Ref1 Position (REF1:1)', 'Poti Ref2 Position (REF2:1)']) + scan = ManualScan(['traslation'], [ + '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)', + '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() - p1 = plot(None, name = "Poti Pos From Beam - Motor Position", context = plotName + " pos difference")[0] - # Creating channels: dimension 1 + p1 = plot(None, name = "Motor Position - Btvs Poti Position", context = plotName + " Motor-Poti difference")[0] + # Creating channels 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] + 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] + 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 - #remove limits - #idLimitH.put(999999.9, timeout=None) - #idLimitL.put(-999999.9, timeout=None) - - if direction == 0.0 : - direction = 1.0 - startDefault = -100.0 - endDefault = 1000.0 - end = endDefault - #find position at Low end switch: it will be the starting point of the test + + #go to position at Low end switch: it will be the starting point of the test test.log('Homing') - idInkr.put(-100.0, timeout=10) # TODO: Set appropriate timeout - start = idInkr.get()+direction + idCom.put(2, timeout=10) # go to R1 + # wait for motor to get to Ref1 + for setpoint1 in range(0, 100): + sleep( 2 ) # Settling time + MotorStatus = idMotorStatus.get() + if bool(int(MotorStatus) & 4): # arrived at Ref1 (low limit) + break + if not bool(int(MotorStatus) & 4): # not arrived at Ref1 (low limit) + ret = 'Could not reach Ref1' + success = False + test.sendFeedback( ret, success) + return + + direction = 1.0 countSteps = 0 test.log('Starting testing sequence') count = 0 for setpoint1 in range(0, (loopTimes*2)): count = count + 1 sleep( 2 ) # Settling time + # add multi cuve plot p1.addSeries(LinePlotSeries("Run"+str(count))) - #go to an end reference - for setpoint2 in frange(start, end, direction): - idInkr.put(setpoint2, timeout=10) # TODO: Set appropriate timeout + + for setpoint2 in frange(0, 1000000): + + idInkr.put(translation*direction, timeout=10) sleep(samplePeriod) # Settling time - readback2 = idInkr.get() 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() @@ -100,11 +115,24 @@ 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]) + idDiff01 = MotorPosition-Btvs + countSteps = countSteps + (translation*direction) + + # multi plot + scan.append([countSteps], [countSteps],[ + Btvs, + PotiPosition, + MotorStatus, + Inkr, + InkrRb, + Diameter, + LogicalPosition, + BtvsRaw, + MotorPosition, + PotiRaw, + PotiRef1Position, + PotiRef2Position]) + # draw curve to multi curve plot p1.getSeries(count).appendData(setpoint2, idDiff01) #extract Status bits @@ -114,15 +142,11 @@ def startTest(testName, DEVICE, params): #check if arrived to R1 or R2 if endH: #invert direction and swap start with end of translation - end = startDefault - start = readback2 - (10.0*direction) direction = -1.0 test.log('Reached R2 switch, changing target to R1') break elif endL: #invert direction and swap start with end of translation - end = endDefault - start = readback2 - (10.0*direction) direction = 1.0 test.log('Reached R1 switch, changing target to R2') break @@ -157,15 +181,16 @@ def startTest(testName, DEVICE, params): 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)'