Beispiel #1
0
 def on_go_baf(self):
     """Do a back-and-forth move."""
     p1 = self.ui.posSpinBox_baf1.value()
     v1 = self.ui.velSpinBox_baf1.value()
     v2 = self.ui.velSpinBox_baf2.value()
     a1 = self.ui.accSpinBox_baf1.value()
     a2 = self.ui.accSpinBox_baf2.value()
     if self.ui.rbRelative_baf.isChecked():
         relflag = "r"
         p2 = -p1
     else:
         relflag = ""
         p2 = self.ui.posSpinBox_baf2.value()
     txt = "GLOBAL INT move\n"
     txt += "JERK({}) = 1\n".format(self.axis)
     txt += "move = 1\n"
     txt += "WHILE move\n"
     txt += "    ACC({}) = {}\n".format(self.axis, a1)
     txt += "    DEC({}) = {}\n".format(self.axis, a1)
     txt += "    VEL({}) = {}\n".format(self.axis, v1)
     txt += "    ptp/e{} {}, {}\n".format(relflag, self.axis, p1)
     txt += "    ACC({}) = {}\n".format(self.axis, a2)
     txt += "    DEC({}) = {}\n".format(self.axis, a2)
     txt += "    VEL({}) = {}\n".format(self.axis, v2)
     txt += "    ptp/e{} {}, {}\n".format(relflag, self.axis, p2)
     if not self.ui.checkBox_loop.isChecked():
         txt += "    move = 0\n"
     txt += "END\n"
     txt += "STOP\n"
     acsc.loadBuffer(self.hcomm, 19, txt, 512)
     acsc.runBuffer(self.hcomm, 19)
Beispiel #2
0
 def on_JogPendant(self):
     if self.jogmode == False:
         self.jogmode = True
         acsc.runBuffer(self.hcomm, 5, None)
     elif self.jogmode == True:
         acsc.stopBuffer(self.hcomm, 5)
         self.jogmode = False
Beispiel #3
0
 def on_runHoming(self):
     if self.simulator:
         self.homecounter += 1
     else:
         acsc.runBuffer(self.hcomm, 2, None)
     self.ui.rbAbsolute.setChecked(True)
     self.ui.rbAbsolute_baf.setChecked(True)
     self.on_abs()
     self.ui.actionOverride.setEnabled(False)
     self.override = False
Beispiel #4
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.runfinished.emit()
Beispiel #5
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.runfinished.emit()
Beispiel #6
0
def test_upload_prg():
    """Test that a program can be uploaded and run in the simulator."""
    hc = acsc.openCommDirect()
    txt = "enable 0\nVEL(0) = 1333\nptp 0, 1.33\nSTOP"
    acsc.loadBuffer(hc, 19, txt, 64)
    acsc.runBuffer(hc, 19)
    time.sleep(0.2)
    vel = acsc.getVelocity(hc, 0)
    pos = acsc.getRPosition(hc, 0)
    print("Position:", pos)
    print("Velocity:", vel)
    assert vel == 1333.0
    assert pos == 1.33
    acsc.closeComm(hc)
Beispiel #7
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.enable(self.hc, 5)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     if self.nidaq:
         self.daqthread.clear()
         print("NI tasks cleared")
     if self.fbg:
         self.fbgthread.stop()
     if self.vectrino:
         if self.settling:
             # Wait 10 minutes to measure tank settling time
             print("Waiting 10 minutes")
             t0 = time.time()
             dt = 0.0
             while not self.aborted and dt < 600:
                 time.sleep(0.5)
                 dt = time.time() - t0
         if self.recordvno:
             self.vec.stop_disk_recording()
         self.vec.stop()
         self.vec.disconnect()
     print("Tow finished")
     if self.vectrino:
         if self.vec.state == "Not connected":
             self.vecstatus = "Vectrino disconnected "
         print("Resetting Vectrino")
         self.reset_vec()
     self.towfinished.emit()
Beispiel #8
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.enable(self.hc, 5)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     if self.nidaq:
         self.daqthread.clear()
         print("NI tasks cleared")
     if self.fbg:
         self.fbgthread.stop()
     if self.vectrino:
         if self.settling:
             # Wait 10 minutes to measure tank settling time
             print("Waiting 10 minutes")
             t0 = time.time()
             dt = 0.0
             while not self.aborted and dt < 600:
                 time.sleep(0.5)
                 dt = time.time() - t0
         if self.recordvno:
             self.vec.stop_disk_recording()
         self.vec.stop()
         self.vec.disconnect()
     print("Tow finished")
     if self.vectrino:
         if self.vec.state == "Not connected":
             self.vecstatus = "Vectrino disconnected "
         print("Resetting Vectrino")
         self.reset_vec()
     self.towfinished.emit()
Beispiel #9
0
 def run(self):
     if self.makeprg:
         self.makedaqprg()
         acsc.loadBuffer(self.hc, 19, self.prg, 1024)
         acsc.runBuffer(self.hc, 19)
     collect = acsc.readInteger(self.hc, acsc.NONE, "collect_data")
     while collect == 0:
         time.sleep(0.01)
         collect = acsc.readInteger(self.hc, acsc.NONE, "collect_data")
     while self.collectdata:
         time.sleep(self.sleeptime)
         t0 = acsc.readReal(self.hc, acsc.NONE, "start_time")
         newdata = acsc.readReal(self.hc, acsc.NONE, "data", 0, 2, 0, self.dblen//2-1)
         t = (newdata[0] - t0)/1000.0
         self.data["time"] = np.append(self.data["time"], t)
         self.data["carriage_vel"] = np.append(self.data["carriage_vel"], newdata[1])
         self.data["turbine_rpm"] = np.append(self.data["turbine_rpm"], newdata[2])
         time.sleep(self.sleeptime)
         newdata = acsc.readReal(self.hc, acsc.NONE, "data", 0, 2, self.dblen//2, self.dblen-1)
         t = (newdata[0] - t0)/1000.0
         self.data["time"] = np.append(self.data["time"], t)
         self.data["time"] = self.data["time"] - self.data["time"][0]
         self.data["carriage_vel"] = np.append(self.data["carriage_vel"], newdata[1])
         self.data["turbine_rpm"] = np.append(self.data["turbine_rpm"], newdata[2])
Beispiel #10
0
prg = prgs.ACSPLplusPrg()
prg.declare_2darray("global", "real", "data", 2, dblen)
prg.addline("global real foo")
prg.addline("foo = 6.5")
prg.addline("ENABLE 0")
prg.add_dc("data", dblen, sr, "TIME, FVEL(0)", "/c")
for n in xrange(3):
    prg.addptp(0, 10000, "/e")
    prg.addptp(0, 0, "/e")
prg.addline("WAIT 10000")
prg.addline("STOPDC")
prg.addstopline()

acsc.setAcceleration(hc, 0, 10000)
acsc.loadBuffer(hc, 0, prg, 1024)
acsc.runBuffer(hc, 0)

astate = acsc.getAxisState(hc, 0)
#print astate

for n in xrange(3):
    time.sleep(sleeptime)
    newdata = acsc.readReal(hc, acsc.NONE, "data", 0, 1, 0, dblen/2-1)
    print acsc.readInteger(hc, acsc.NONE, "S_DCN")
    t = np.append(t, newdata[0])
    data = np.append(data, newdata[1])
    time.sleep(sleeptime)
    newdata = acsc.readReal(hc, acsc.NONE, "data", 0, 1, dblen/2, dblen-1)
    t = np.append(t, newdata[0])
    data = np.append(data, newdata[1])
Beispiel #11
0
then uploading it to the controller and running it.
"""

from __future__ import division, print_function
from acspy import acsc
import time

#file = open("test/test.prg", "w+")

acs_prg = """
ENABLE 1""" + \
"""
VEL(1) = 1000
PTP/r 1, -900
STOP
"""

#file.write(acs_prg)
#file.close()

print(acs_prg)
hc = acsc.openCommDirect()
acsc.loadBuffer(hc, 0, acs_prg, 512)
acsc.enable(hc, 0)
#acsc.LoadBuffersFromFile(hc, "test/test.prg")
acsc.runBuffer(hc, 0)
time.sleep(1)
print(acsc.getRPosition(hc, 1))
print(acsc.getMotorState(hc, 1))
acsc.closeComm(hc)
Beispiel #12
0
    def initialization(self):

        print "Waiting for Motorized Stage (ACS) Initialization"
        self.hc = acsc.openCommEthernetTCP(address="10.0.0.100",
                                           port=701)  ## craete comminucation

        acsc.runBuffer(self.hc, 0)
        acsc.runBuffer(self.hc, 1)
        acsc.runBuffer(self.hc, 2)
        acsc.runBuffer(self.hc, 4)
        acsc.runBuffer(self.hc, 5)
        acsc.runBuffer(self.hc, 6)

        time.sleep(30)

        ## Homing process

        ## Axis 6
        acsc.waitMotionEnd(self.hc, axis=6)  ## stop at left limit
        if acsc.setFPosition(self.hc, axis=6, fposition=0) != 0:
            print 'Axis 6 (Receiver Z): Homing completed'
        else:
            print 'Axis 6 (Receiver Z): Homing failed'

        ## Axis 0
        acsc.waitMotionEnd(self.hc, axis=0)
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=0, target=47.5)
        acsc.waitMotionEnd(self.hc, axis=0)
        if acsc.setFPosition(self.hc, axis=0, fposition=0) == 1:
            print 'Axis 0 (Sample X): Homing completed'
        else:
            print 'Axis 0 (Sample X): Homing failed'

        ## Axis 1
        acsc.waitMotionEnd(self.hc, axis=1)
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=1, target=19.51)
        acsc.waitMotionEnd(self.hc, axis=1)
        if acsc.setFPosition(self.hc, axis=1, fposition=0) == 1:
            print 'Axis 1 (Sample Y): Homing completed'
        else:
            print 'Axis 1 (Sample Y): Homing failed'

        ## Axis 2
        acsc.waitMotionEnd(self.hc, axis=2)  ## stop at left limit
        acsc.toPoint(self.hc, flags=0, axis=2, target=2.8915)
        print 'Axis 2 (Lens array): Homing completed'

        ## Axis 4
        acsc.waitMotionEnd(self.hc, axis=4)  ## stop at left limit
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=4, target=4.42)
        acsc.waitMotionEnd(self.hc, axis=4)
        if acsc.setFPosition(self.hc, axis=4, fposition=0) == 1:
            print 'Axis 4 (Receiver X): Homing completed'
        else:
            print 'Axis 4 (Receiver X): Homing failed'

        ## Axis5
        acsc.waitMotionEnd(self.hc, axis=5)  ## stop at left limit
        acsc.toPoint(self.hc, flags=acsc.AMF_RELATIVE, axis=5, target=23.8)
        acsc.waitMotionEnd(self.hc, axis=5)
        if acsc.setFPosition(self.hc, axis=5, fposition=0) == 1:
            print 'Axis 5 (Receiver Y): Homing completed'
        else:
            print 'Axis 5 (Receiver Y): Homing failed'

        ## parameter setting
        acsc.setVelocity(self.hc, 0, 30)  ## axis 0 (linear X)
        acsc.setAcceleration(self.hc, 0, 100)
        acsc.setDeceleration(self.hc, 0, 100)
        acsc.setJerk(self.hc, 0, 1000)

        acsc.setVelocity(self.hc, 1, 30)  ## axis1 (linear Y)
        acsc.setAcceleration(self.hc, 1, 100)

        acsc.setDeceleration(self.hc, 1, 100)
        acsc.setJerk(self.hc, 1, 1000)

        acsc.setVelocity(self.hc, 2, 30)  ## axis 2 (revolver)
        acsc.setAcceleration(self.hc, 2, 100)
        acsc.setDeceleration(self.hc, 2, 100)
        acsc.setJerk(self.hc, 2, 1000)

        acsc.setVelocity(self.hc, 4, 30)  ## axis4 (step X)
        acsc.setAcceleration(self.hc, 4, 100)
        acsc.setDeceleration(self.hc, 4, 100)
        acsc.setJerk(self.hc, 4, 1000)

        acsc.setVelocity(self.hc, 5, 30)  ## axis 5 (step Y)
        acsc.setAcceleration(self.hc, 5, 100)
        acsc.setDeceleration(self.hc, 5, 100)
        acsc.setJerk(self.hc, 5, 1000)

        acsc.setVelocity(self.hc, 6, 5)  ## axis 6 (step Z)
        acsc.setAcceleration(self.hc, 6, 50)
        acsc.setDeceleration(self.hc, 6, 50)
        acsc.setJerk(self.hc, 1, 100)