Пример #1
0
    def __init__(self, dobotPort='/dev/ttyUSB0'):
        available_ports = glob('/dev/tty*USB*')  # mask for OSX Dobot port
        if len(available_ports) == 0:
            print('no port /dev/tty*USB* found for Dobot Magician')
            exit(1)

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort;

        self.ecRelay = Relay(18);#bcm pin for physical pin 12
        self.pdRelay = Relay(24);#bcm for physical 18
        self.rhRelay = Relay(23);#bcm for physical 16
        self.gripper = ServoGripper(2);
        self.dvc = DigitalVoltControl();

        self.lastCmd = [0,0,0,0]; #x, y, z, r

        print("Setting Port to " + self.DobotPort);
        self.device = Dobot(port=self.DobotPort)
        time.sleep(1)
        if self.device is not None:
            print("Opened connection")

        self.device.speed(60)

        self.z_up = 100
        self.z_down = -70
        #self.RH_Voltage = 2.5;
        #self.PD_Voltage = 1.9;
        #self.EC_Voltage = 4.8;
        
        self.home_xyzr = [215, 0, self.z_up, 0];                    
        global global_status
        global_status = "Rh Electroplating";
Пример #2
0
    def __init__(self, dobotPort='/dev/ttyACM0'):
        ports = list(serial.tools.list_ports.comports())
        for i in ports:
            print(i[0], " -- ", i[1], " -- ", i[2])

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort

        self.ecRelay = Relay(18)
        #bcm pin for physical pin 12
        self.pdRelay = Relay(24)
        #bcm for physical 18
        self.rhRelay = Relay(23)
        #bcm for physical 16
        self.gripper = ServoGripper(2)
        self.dvc = DigitalVoltControl()

        print("Setting Port to %s" % (self.DobotPort))

        self.dobot_interface = DobotSerialInterface(self.DobotPort)

        print("Opened connection")
        self.dobot_interface.set_speed()
        self.dobot_interface.set_playback_config()

        self.z_up = 80
        self.z_down = -65
        self.RH_Voltage = 2.5
        self.PD_Voltage = 1.9
        self.EC_Voltage = 4.8

        self.home_xyz = [215, 0, 100]

        time.sleep(1)

        global global_status
        global_status = "Rh Electroplating"
        self.move_xy(self.home_xyz[0], self.home_xyz[1], self.home_xyz[2], 0.3)
Пример #3
0
class DobotPlating():
    def __init__(self, dobotPort='/dev/ttyUSB0'):
        available_ports = glob('/dev/tty*USB*')  # mask for OSX Dobot port
        if len(available_ports) == 0:
            print('no port /dev/tty*USB* found for Dobot Magician')
            exit(1)

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort;

        self.ecRelay = Relay(18);#bcm pin for physical pin 12
        self.pdRelay = Relay(24);#bcm for physical 18
        self.rhRelay = Relay(23);#bcm for physical 16
        self.gripper = ServoGripper(2);
        self.dvc = DigitalVoltControl();

        self.lastCmd = [0,0,0,0]; #x, y, z, r

        print("Setting Port to " + self.DobotPort);
        self.device = Dobot(port=self.DobotPort)
        time.sleep(1)
        if self.device is not None:
            print("Opened connection")

        self.device.speed(60)

        self.z_up = 100
        self.z_down = -70
        #self.RH_Voltage = 2.5;
        #self.PD_Voltage = 1.9;
        #self.EC_Voltage = 4.8;
        
        self.home_xyzr = [215, 0, self.z_up, 0];                    
        global global_status
        global_status = "Rh Electroplating";
    
    def calibrate(self):
        self.device.goHome();

    def isMoveFinished(self):
        euDist = math.pow(self.lastCmd[0] - self.device.x,2) + math.pow(self.lastCmd[1] - self.device.y, 2) + math.pow(self.lastCmd[2] - self.device.z, 2) + math.pow(self.lastCmd[3] - self.device.r, 2);
        euDist = math.sqrt(euDist);
        if(euDist < 2):
            return True;
        else:
            #print("still moving ..");
            return False;
        
    def move_home(self):
        self.move_xy(self.home_xyzr[0], self.home_xyzr[1], self.home_xyzr[2], self.home_xyzr[3], 0.3);

    def move_xy(self, x, y, z, r, duration = 1):
        self.lastCmd = [x, y, z, r];
        self.device.go(x, y, z, r);  #MOVJ
#        time.sleep(duration);
#            print("in is move finished..");
        print("xyzr position: " + str(self.device.x) + ", " + str(self.device.y) + ", " + str(self.device.z) + ", " + str(self.device.r));
   
    def move_xy_linear(self, x, y, z, r, duration = 1):
        self.lastCmd = [x, y, z, r];
        self.device.goMovL(x, y, z, r);  #MOVJ
#        time.sleep(duration);
#            print("in is move finished..");
        print("xyzr position: " + str(self.device.x) + ", " + str(self.device.y) + ", " + str(self.device.z) + ", " + str(self.device.r));
        
    def shake(self, x, y, z, r, shakeDuration, dispStr):
        global global_status;
        t_end = time.time() + shakeDuration;
        tdiff = t_end - time.time();
        while tdiff > 0:
            if(dispStr is not None):
                global_status = dispStr + str(int(tdiff)) + "s"
            self.move_xy(x, y, z + 10, r, 0.1);
            self.move_xy(x, y, z - 10, r, 0.1);
            tdiff = t_end - time.time();
        
    def up_down_beaker(self,id):

        print ("Doing beaker %d now" % (id));
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3], 0.3);
        self.move_xy(Beakers[id][0], Beakers[id][1], (self.z_up + self.z_down)/2.0 , Beakers[id][3], 0.3); #adding a mid point so that the Joint motion isn't touching th edges of the beakers
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_down, Beakers[id][3], 0.3);
        dispStr = "Step " + str(id) + ": ";
        while(not self.isMoveFinished()):
            time.sleep(0.01);

        if(id == 1):
            self.ecRelay.on();
            dispStr = dispStr + "EC "
        elif(id == 8):
            self.pdRelay.on();
            dispStr = dispStr + "Pd Solution "
        elif(id == 11):
            self.rhRelay.on();
            dispStr = dispStr + "Rh Solution "
            
        if(id == 1 or id == 8 or id == 11):
            if(id == 11):
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down - 20, Beakers[id][3], Beakers[id][4], dispStr); #x, y, z and shake_duration
            else:
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down, Beakers[id][3], Beakers[id][4], dispStr); #x, y, z and shake_duration
        else:    
            self.shake(Beakers[id][0], Beakers[id][1], self.z_down, Beakers[id][3], Beakers[id][4], None); #x, y, z and shake_duration
        
        self.ecRelay.off();
        self.pdRelay.off();
        self.rhRelay.off();
        #move up
        
        #shake to drop the excess drops
        #go half way to adjust for MOVJ
        self.move_xy(Beakers[id][0], Beakers[id][1], (self.z_up + self.z_down)/2.0 , Beakers[id][3], 0.3); #adding a mid point so that the Joint motion isn't touching th edges of the beakers
        #self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3]);

        self.shake(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3], 2, None);
        
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3]);
        
        while(not self.isMoveFinished()):
            time.sleep(0.01);
     
    def startProcess(self, EC_Voltage, PD_Voltage, RH_Voltage):
        global process_running
        process_running = True;
        global global_status
        global_status = "Step 1: EC"
        #1
        if(EC_Voltage == 5.6):
            self.dvc.setMaxVoltage();
        else:
            self.dvc.setVoltage(EC_Voltage);
        self.up_down_beaker(1);
        
        #2
        global_status = "Step 2: Dragout"
        self.up_down_beaker(2);
        
        #3
        global_status = "Step 3: Water"
        self.up_down_beaker(3);

        #4
        global_status = "Step 4: Activation"
        self.up_down_beaker(4);
        
        #5
        global_status = "Step 5: Water"
        self.up_down_beaker(5);

        #6
        global_status = "Step 6: Water"
        self.up_down_beaker(6);
        
        #7
        global_status = "Step 7: Water"
        self.up_down_beaker(7);

        #8
        #global_status = "Step 8: Pd Solution"
        #self.dvc.setVoltage(PD_Voltage);
        #self.up_down_beaker(8);
        
        #9
        #global_status = "Step 9: Pd Dragout"
        #self.up_down_beaker(9);
        
        #10
        #global_status = "Step 10: Water"
        #self.up_down_beaker(10);
        
        #11
        global_status = "Step 11: Rh Solution"
        self.dvc.setVoltage(RH_Voltage);
        self.up_down_beaker(11);
        
        #12
        global_status = "Step 12: Rh Dragout"
        self.up_down_beaker(12);
        
        #13 #repeat of beaker 10
        global_status = "Step 13: Water"
        self.up_down_beaker(10);

        #Home
        self.move_home()
        global_status = "Done.."
        process_running = False;
        print("\n DONE \n");
   
    def __del__(self):
        self.device.close();        
        del self.gripper;
        del self.dvc;
        del self.ecRelay;
        del self.pdRelay;
        del self.rhRelay;
        print("Exiting Cleanly..");
Пример #4
0
class DobotPlating():
    def __init__(self, dobotPort='/dev/ttyACM0'):
        ports = list(serial.tools.list_ports.comports())
        for i in ports:
            print(i[0], " -- ", i[1], " -- ", i[2])

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort

        self.ecRelay = Relay(18)
        #bcm pin for physical pin 12
        self.pdRelay = Relay(24)
        #bcm for physical 18
        self.rhRelay = Relay(23)
        #bcm for physical 16
        self.gripper = ServoGripper(2)
        self.dvc = DigitalVoltControl()

        print("Setting Port to %s" % (self.DobotPort))

        self.dobot_interface = DobotSerialInterface(self.DobotPort)

        print("Opened connection")
        self.dobot_interface.set_speed()
        self.dobot_interface.set_playback_config()

        self.z_up = 80
        self.z_down = -65
        #self.RH_Voltage = 2.5;
        #self.PD_Voltage = 1.9;
        #self.EC_Voltage = 4.8;

        self.home_xyz = [215, 0, 100]

        time.sleep(1)

        global global_status
        global_status = "Re-Dip: Rh Electroplating"

    def move_home(self):
        self.move_xy(self.home_xyz[0], self.home_xyz[1], self.home_xyz[2], 0.3)

    def move_xy(self, x, y, z, duration=2):
        self.dobot_interface.send_absolute_position(x, y, z, 0)
        #MOVL
        time.sleep(duration)

    def move_angles(self, base, rear, front, duration=2):
        self.dobot_interface.send_absolute_angles(base, rear, front, 0)
        time.sleep(duration)

    def shake(self, x, y, z, shakeDuration, dispStr):
        global global_status
        t_end = time.time() + shakeDuration
        tdiff = t_end - time.time()
        while tdiff > 0:
            if (dispStr is not None):
                global_status = dispStr + str(int(tdiff)) + "s"
            self.move_xy(x, y, z + 10, 0.3)
            self.move_xy(x, y, z - 10, 0.3)
            tdiff = t_end - time.time()

    def up_down_beaker(self, id):

        print("Doing beaker %d now" % (id))
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up)
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_down)
        dispStr = "Step " + str(id) + ": "

        if (id == 1):
            self.ecRelay.on()
            dispStr = dispStr + "EC "
        elif (id == 8):
            self.pdRelay.on()
            dispStr = dispStr + "Pd Solution "
        elif (id == 11):
            self.rhRelay.on()
            dispStr = dispStr + "Rh Solution "

        if (id == 1 or id == 8 or id == 11):
            if (id == 11):
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down - 20,
                           Beakers[id][2], dispStr)
                #x, y, z and shake_duration
            else:
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down,
                           Beakers[id][2], dispStr)
                #x, y, z and shake_duration
        else:
            self.shake(Beakers[id][0], Beakers[id][1], self.z_down,
                       Beakers[id][2], None)
            #x, y, z and shake_duration

        self.ecRelay.off()
        self.pdRelay.off()
        self.rhRelay.off()
        #move up
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up)

        #shake to drop the excess drops
        self.shake(Beakers[id][0], Beakers[id][1], self.z_up, 1, None)

    def startProcess(self, EC_Voltage, PD_Voltage, RH_Voltage):
        global process_running
        process_running = True
        global global_status
        global_status = "Re-Dip Step 1: EC"
        #1
        self.move_angles(-40, 30, 10)
        self.move_angles(-60, 30, 10)
        self.move_angles(-90, 30, 10)
        self.move_angles(-106, 30, 10)
        self.move_angles(-132, 30, 10)
        if (EC_Voltage == 5.6):
            self.dvc.setMaxVoltage()
        else:
            self.dvc.setVoltage(EC_Voltage)
        #ecchoices = { '4.0','4.5','4.7', '5.6'}
        self.up_down_beaker(1)

        #2
        global_status = "Re-Dip Step 2: Dragout"
        self.move_angles(-112, 30, 10)
        self.up_down_beaker(2)

        #3
        global_status = "Re-Dip Step 3: Water"
        self.move_angles(-90, 30, 10)
        self.up_down_beaker(3)

        #4
        global_status = "Re-Dip Step 4: Activation"
        self.move_angles(-67, 30, 10)
        self.up_down_beaker(4)

        #5
        global_status = "Re-Dip Step 5: Water"
        self.move_angles(-45, 30, 20)
        self.up_down_beaker(5)

        #6
        global_status = "Re-Dip Step 6: Water"
        self.move_angles(-25, 30, 20)
        self.up_down_beaker(6)

        #7
        global_status = "Re-Dip Step 7: Water"
        self.move_angles(5, 30, 20)
        self.up_down_beaker(7)

        #8
        #global_status = "Re-Dip Step 8: Pd Solution"
        #        self.move_angles(5, 30, 20);
        self.move_angles(25, 30, 20)
        #       self.dvc.setVoltage(PD_Voltage);
        #       self.up_down_beaker(8);

        #9
        #       global_status = "Step 9: Pd Dragout"
        self.move_angles(45, 20, 20)
        #       self.up_down_beaker(9);

        #10
        #       global_status = "Step 10: Water"
        self.move_angles(67, 20, 20)
        #       self.up_down_beaker(10);

        #11
        global_status = "Re-Dip Step 8: Rh Solution"
        self.move_angles(89, 20, 20)
        self.move_angles(100, 20, 20)
        self.move_angles(120, 20, 20)
        self.move_angles(130, 20, 20)
        self.dvc.setVoltage(RH_Voltage)
        self.up_down_beaker(11)

        #12
        global_status = "Re-Dip Step 9: Rh Dragout"
        self.move_angles(120, 30, 10)
        self.move_angles(97, 30, 10)
        self.up_down_beaker(12)

        #13 #repeat of beaker 10
        global_status = "Re-Dip Step 10: Water"
        self.move_angles(67, 20, 20)
        self.up_down_beaker(10)

        #Home
        self.move_angles(60, 20, 10)
        self.move_angles(30, 20, 10)
        self.move_angles(0, 20, 10)

        self.move_home()
        global_status = "Re-Dip Done.."
        process_running = False
        print("\n DONE \n")

    def __del__(self):
        del self.gripper
        del self.dvc
        del self.ecRelay
        del self.pdRelay
        del self.rhRelay
Пример #5
0
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=50)
mainframe.rowconfigure(0, weight=50)
mainframe.grid_propagate(0);

s = ttk.Style()
s.configure('my.TButton', font=('Helvetica', 18))

#DobotPort = 'COM4'
DobotPort = '/dev/ttyACM0'

ecRelay = Relay(18);#bcm pin for physical pin 12
pdRelay = Relay(23);#bcm for physical 16
rhRelay = Relay(24);#bcm for physical 18
gripper = ServoGripper(2);
dvc = DigitalVoltControl();

                
if len(sys.argv) >= 2:
    DobotPort = sys.argv[1];

print ("Setting Port to %s" % (DobotPort));
    
dobot_interface = DobotSerialInterface(DobotPort)

print("Opened connection")
dobot_interface.set_speed()
dobot_interface.set_playback_config()

z_up = 60
z_down = 0
from ServoGripper import ServoGripper

import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
for i in ports:
    print(i[0], " -- ", i[1], " -- ", i[2])

DobotPort = '/dev/ttyACM0'
ecRelay = Relay(18)
#bcm pin for physical pin 12
pdRelay = Relay(23)
#bcm for physical 16
rhRelay = Relay(24)
#bcm for physical 18
gripper = ServoGripper(2)
dvc = DigitalVoltControl()

#ArduinoPort = '/dev/ttyUSB0'
#DobotPort = 'COM4'

if len(sys.argv) >= 2:
    DobotPort = sys.argv[1]

print "Setting Port to %s" % (DobotPort)

dobot_interface = DobotSerialInterface(DobotPort)

print "Opened connection"
dobot_interface.set_speed()
dobot_interface.set_playback_config()
Пример #7
0
class DobotPlating():
    def __init__(self, dobotPort='/dev/ttyUSB0'):
        available_ports = glob('/dev/tty*USB*')  # mask for OSX Dobot port
        if len(available_ports) == 0:
            print('no port /dev/tty*USB* found for Dobot Magician')
            exit(1)
        else:
            dobotPort = available_ports[0]

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort

        self.ecRelay = Relay(18)
        #bcm pin for physical pin 12
        self.pdRelay = Relay(24)
        #bcm for physical 18
        self.rhRelay = Relay(23)
        #bcm for physical 16
        self.gripper = ServoGripper(2)
        self.dvc = DigitalVoltControl()

        self.RH_Duration = 60
        self.PD_DURATION = 60

        self.lastCmd = [0, 0, 0, 0]
        #x, y, z, r

        print("Setting Port to " + self.DobotPort)
        self.device = Dobot(port=self.DobotPort)
        time.sleep(1)
        if self.device is not None:
            print("Opened connection")

        self.device.speed()

        self.z_up = 100
        self.z_down = -70
        #self.RH_Voltage = 2.5;
        #self.PD_Voltage = 1.9;
        #self.EC_Voltage = 4.8;

        self.home_xyzr = [215, 0, self.z_up, 0]
        global global_status
        global_status = "Rh Electroplating"

    def calibrate(self):
        global global_status
        response = self.device.setHomeParams(self.home_xyzr[0],
                                             self.home_xyzr[1],
                                             self.home_xyzr[2],
                                             self.home_xyzr[3])
        #if(response):
        #           global_status = "Error..";

        response = self.device.goHome()


#        if(response):
#            global_status = "Error..";

    def isMoveFinished(self):
        global global_step_indicator
        global_step_indicator = "isMoveFinished"

        euDist = math.pow(self.lastCmd[0] - self.device.x, 2) + math.pow(
            self.lastCmd[1] - self.device.y, 2) + math.pow(
                self.lastCmd[2] - self.device.z, 2) + math.pow(
                    self.lastCmd[3] - self.device.r, 2)
        euDist = math.sqrt(euDist)
        if (euDist < 10):
            return True
        else:
            #print("still moving ..");
            return False

    def move_home(self):
        global global_step_indicator
        global_step_indicator = "move_home"
        self.move_xy(self.home_xyzr[0], self.home_xyzr[1], self.home_xyzr[2],
                     self.home_xyzr[3], 0.3)

    def move_xy(self, x, y, z, r, duration=1):
        global global_step_indicator
        global_step_indicator = "move_xy"
        self.lastCmd = [x, y, z, r]
        response = self.device.go(x, y, z, r)
        #MOVJ
        #        if(response):
        #            global global_status
        #            global_status = "Error..";

        #        time.sleep(duration);
        #            print("in is move finished..");
        print("xyzr position: " + str(self.device.x) + ", " +
              str(self.device.y) + ", " + str(self.device.z) + ", " +
              str(self.device.r))

    def move_xy_linear(self, x, y, z, r, duration=1):
        self.lastCmd = [x, y, z, r]
        response = self.device.goMovL(x, y, z, r)
        #MOVJ
        #        if(response):
        #            global global_status
        #            global_status = "Error..";
        #        time.sleep(duration);
        #            print("in is move finished..");
        print("xyzr position: " + str(self.device.x) + ", " +
              str(self.device.y) + ", " + str(self.device.z) + ", " +
              str(self.device.r))

    def shake(self,
              x,
              y,
              z,
              r,
              shakeDuration,
              dispStr,
              dontShake=False,
              doInOut=False):
        global global_step_indicator
        global_step_indicator = "shake "
        global global_status
        t_end = time.time() + shakeDuration
        tdiff = t_end - time.time()
        while tdiff > 0:
            if (dispStr is not None):
                global_status = dispStr + " " + str(int(tdiff)) + "s"
            if (not dontShake):
                self.move_xy(x, y, z + 10, r, 0.1)
                self.move_xy(x, y, z - 10, r, 0.1)
            tdiff = t_end - time.time()

    def shakeHalfUp(self,
                    x,
                    y,
                    z,
                    r,
                    shakeDuration,
                    dispStr,
                    dontShake=False,
                    doInOut=False):
        global global_step_indicator
        global_step_indicator = "shake "
        global global_status
        t_end = time.time() + shakeDuration
        tdiff = t_end - time.time()
        while tdiff > 0:
            if (dispStr is not None):
                global_status = dispStr + " " + str(int(tdiff)) + "s"
            if (not dontShake):
                self.move_xy(x, y, (self.z_up + self.z_down) / 2.0, r, 0.1)
                self.move_xy(x, y, z - 10, r, 0.1)
            tdiff = t_end - time.time()

    def up_down_beaker(self, id, dispStr=None):

        print("Doing beaker %d now" % (id))
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3],
                     0.3)
        self.move_xy(Beakers[id][0], Beakers[id][1],
                     (self.z_up + self.z_down) / 2.0, Beakers[id][3], 0.3)
        #adding a mid point so that the Joint motion isn't touching th edges of the beakers
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_down,
                     Beakers[id][3], 0.3)
        #dispStr = "Step " + str(id) + ": ";

        t_end = time.time() + 25
        while (not self.isMoveFinished()):
            time.sleep(0.01)
            if (time.time() > t_end):
                global global_step_indicator
                global_step_indicator = "timing error.."
                break

        global global_step_indicator
        global_step_indicator = "up_down_beaker " + str(id)

        if (id == 1):
            self.ecRelay.on()
        #    dispStr = dispStr + "EC "
        elif (id == 8):
            self.pdRelay.on()
        #    dispStr = dispStr + "Pd Solution "
        elif (id == 11):
            self.rhRelay.on()
        #    dispStr = dispStr + "Rh Solution "

        if (id == 1 or id == 8 or id == 11):
            if (id == 11):
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down - 10,
                           Beakers[id][3], self.RH_Duration, dispStr)
                #x, y, z and shake_duration
            elif (id == 1):  #dont' shake
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down,
                           Beakers[id][3], Beakers[id][4], dispStr, True)
                #x, y, z and shake_duration
            else:  #this means id is 8 i.e. Pd
                self.shake(Beakers[id][0], Beakers[id][1], self.z_down,
                           Beakers[id][3], self.PD_Duration, dispStr)
                #x, y, z and shake_duration
        else:
            self.shakeHalfUp(Beakers[id][0], Beakers[id][1], self.z_down,
                             Beakers[id][3], Beakers[id][4], None)
            #x, y, z and shake_duration

        global global_step_indicator
        global_step_indicator = "bottom_shake_finished"

        self.ecRelay.off()
        self.pdRelay.off()
        self.rhRelay.off()
        #move up

        #shake to drop the excess drops
        #go half way to adjust for MOVJ
        self.move_xy(Beakers[id][0], Beakers[id][1],
                     (self.z_up + self.z_down) / 2.0, Beakers[id][3], 0.3)
        #adding a mid point so that the Joint motion isn't touching th edges of the beakers
        #self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3]);

        self.shake(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3],
                   2, None)

        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up, Beakers[id][3])

        global_step_indicator = "excess_shake_finished"

        t_end = time.time() + 25
        while (not self.isMoveFinished()):
            time.sleep(0.01)
            if (time.time() > t_end):
                global global_step_indicator
                global_step_indicator = "timing error.."
                break

        global_step_indicator = "excess_shake_move_finished"

    def startProcess(self, EC_Voltage, PD_Voltage, RH_Voltage, processType,
                     pdTimeToDo, rhTimeToDo):
        global process_running
        process_running = True
        global global_status

        self.RH_Duration = rhTimeToDo
        #if(processType == PROCESS_RH_20):
        #    self.RH_Duration = 20;
        self.PD_Duration = pdTimeToDo

        global_status = "Step 1: EC"
        #1
        if (EC_Voltage == 5.6):
            self.dvc.setMaxVoltage()
        else:
            self.dvc.setVoltage(EC_Voltage)
        self.up_down_beaker(1, global_status)

        #2
        global_status = "Step 2: Dragout"
        self.up_down_beaker(2)

        #3
        global_status = "Step 3: Water"
        self.up_down_beaker(3)

        #4
        global_status = "Step 4: Activation"
        self.up_down_beaker(4)

        #5
        global_status = "Step 5: Water"
        self.up_down_beaker(5)

        #6
        global_status = "Step 6: Water"
        self.up_down_beaker(6)

        #7
        global_status = "Step 7: Water"
        self.up_down_beaker(7)

        #8
        if (processType == PROCESS_RH_PD):
            global_status = "Step 8: Pd Solution"
            self.dvc.setVoltage(PD_Voltage)
            self.up_down_beaker(8, global_status)

            #9
            global_status = "Step 9: Pd Dragout"
            self.up_down_beaker(9)

            #10
            global_status = "Step 10: Water"
            self.up_down_beaker(10)

        #11
        if (processType == PROCESS_RH_PD):
            global_status = "Step 11: Rh Solution"
        else:
            global_status = "Step 8: Rh Solution"
        self.dvc.setVoltage(RH_Voltage)
        self.up_down_beaker(11, global_status)

        #12
        if (processType == PROCESS_RH_PD):
            global_status = "Step 12: Rh Dragout"
        else:
            global_status = "Step 9: Rh Dragout"
        self.up_down_beaker(12)

        #13 #repeat of beaker 10
        if (processType == PROCESS_RH_PD):
            global_status = "Step 13: Water"
        else:
            global_status = "Step 10: Water"
        self.up_down_beaker(10)

        #Home
        self.move_home()
        global_status = "Done.."
        process_running = False
        print("\n DONE \n")

    def __del__(self):
        self.device.close()
        del self.gripper
        del self.dvc
        del self.ecRelay
        del self.pdRelay
        del self.rhRelay
        print("Exiting Cleanly..")
Пример #8
0
class DobotPlating():
    def __init__(self, dobotPort='/dev/ttyACM0'):
        ports = list(serial.tools.list_ports.comports())
        for i in ports:
            print(i[0], " -- ", i[1], " -- ", i[2])

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort

        self.ecRelay = Relay(18)
        #bcm pin for physical pin 12
        self.pdRelay = Relay(24)
        #bcm for physical 18
        self.rhRelay = Relay(23)
        #bcm for physical 16
        self.gripper = ServoGripper(2)
        self.dvc = DigitalVoltControl()

        print("Setting Port to %s" % (self.DobotPort))

        self.dobot_interface = DobotSerialInterface(self.DobotPort)

        print("Opened connection")
        self.dobot_interface.set_speed()
        self.dobot_interface.set_playback_config()

        self.z_up = 80
        self.z_down = -65
        self.RH_Voltage = 2.5
        self.PD_Voltage = 1.9
        self.EC_Voltage = 4.8

        self.home_xyz = [215, 0, 100]

        time.sleep(1)

        global global_status
        global_status = "Rh Electroplating"
        self.move_xy(self.home_xyz[0], self.home_xyz[1], self.home_xyz[2], 0.3)

    def move_xy(self, x, y, z, duration=2):
        self.dobot_interface.send_absolute_position(x, y, z, 0)
        #MOVL
        time.sleep(duration)

    def move_angles(self, base, rear, front, duration=2):
        self.dobot_interface.send_absolute_angles(base, rear, front, 0)
        time.sleep(duration)

    def shake(self, x, y, z, shakeDuration):
        t_end = time.time() + shakeDuration
        while time.time() < t_end:
            self.move_xy(x, y, z + 10, 0.3)
            self.move_xy(x, y, z - 10, 0.3)

    def up_down_beaker(self, id):

        print("Doing beaker %d now" % (id))
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up)
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_down)

        if (id == 1):
            self.ecRelay.on()
        elif (id == 8):
            self.pdRelay.on()
        elif (id == 11):
            self.rhRelay.on()

        self.shake(Beakers[id][0], Beakers[id][1], self.z_down, Beakers[id][2])
        #x, y, z and shake_duration

        self.ecRelay.off()
        self.pdRelay.off()
        self.rhRelay.off()
        #move up
        self.move_xy(Beakers[id][0], Beakers[id][1], self.z_up)

        #shake to drop the excess drops
        self.shake(Beakers[id][0], Beakers[id][1], self.z_up, 1)

    def startProcess(self):
        global process_running
        process_running = True
        global global_status
        global_status = "Step 1: EC"
        #1
        self.move_angles(-40, 30, 10)
        self.move_angles(-60, 30, 10)
        self.move_angles(-90, 30, 10)
        self.move_angles(-106, 30, 10)
        self.move_angles(-132, 30, 10)
        self.dvc.setVoltage(self.EC_Voltage)
        self.up_down_beaker(1)

        #2
        global_status = "Step 2: Dragout"
        self.move_angles(-112, 30, 10)
        self.up_down_beaker(2)

        #3
        global_status = "Step 3: Water"
        self.move_angles(-90, 30, 10)
        self.up_down_beaker(3)

        #4
        global_status = "Step 4: Activation"
        self.move_angles(-67, 30, 10)
        self.up_down_beaker(4)

        #5
        global_status = "Step 5: Water"
        self.move_angles(-45, 30, 20)
        self.up_down_beaker(5)

        #6
        global_status = "Step 6: Water"
        self.move_angles(-25, 30, 20)
        self.up_down_beaker(6)

        #7
        global_status = "Step 7: Water"
        self.move_angles(5, 30, 20)
        self.up_down_beaker(7)

        #8
        global_status = "Step 8: Pd Solution"
        self.move_angles(5, 30, 20)
        self.move_angles(25, 30, 20)
        self.dvc.setVoltage(self.PD_Voltage)
        self.up_down_beaker(8)

        #9
        global_status = "Step 9: Pd Dragout"
        self.move_angles(45, 20, 20)
        self.up_down_beaker(9)

        #10
        global_status = "Step 10: Water"
        self.move_angles(67, 20, 20)
        self.up_down_beaker(10)

        #11
        global_status = "Step 11: Rh Solution"
        self.move_angles(89, 20, 20)
        self.move_angles(100, 20, 20)
        self.move_angles(120, 20, 20)
        self.move_angles(130, 20, 20)
        self.dvc.setVoltage(self.RH_Voltage)
        self.up_down_beaker(11)

        #12
        global_status = "Step 12: Rh Dragout"
        self.move_angles(120, 30, 10)
        self.move_angles(97, 30, 10)
        self.up_down_beaker(12)

        #Home
        self.move_angles(60, 20, 10)
        self.move_angles(30, 20, 10)
        self.move_angles(0, 20, 10)
        self.move_xy(self.home_xyz[0], self.home_xyz[1], self.home_xyz[2])
        global_status = "Done.."
        process_running = False
        print("\n DONE \n")

    def __del__(self):
        del self.gripper
        del self.dvc
        del self.ecRelay
        del self.pdRelay
        del self.rhRelay