def limitSwitch(self):
     self.stat = MOTOR.getSENSORS(0)
     if not (self.stat&0x01) or not (self.stat&0x04):
         MOTOR.RESET(0)
         print('Limit switches hit, stopping')
         root.after_cancel(self._job)
         self.stopAll()
示例#2
0
 def resetMotor(self):
     MOTOR.RESET(0)
     stat = 0xff
     while stat:
         time.sleep(.1)
         stat = MOTOR.getINTflag0(0)
     time.sleep(.1)
示例#3
0
 def handleIote2eResult(self, iote2eResult ):
     actuatorValue = iote2eResult.pairs['actuatorValue'];
     logger.info('actuatorValue {}'.format(actuatorValue))
     if 'off' == actuatorValue:
         MOTOR.dcSTOP(0,3)
     elif 'on' == actuatorValue:
         MOTOR.dcSTART(0,3)
示例#4
0
 def neutral(self, msg):
     MOTOR.stepperSTOP(config.ADDR, config.MOTOR)
     MOTOR.stepperCONFIG(config.ADDR, config.MOTOR, 'ccw', 'M8', 500, 0)
     MOTOR.stepperJOG(config.ADDR, config.MOTOR)
     endstop(1)
     MOTOR.stepperCONFIG(config.ADDR, config.MOTOR, 'cw', 'M8', 1000, 0)
     MOTOR.stepperMOVE(config.ADDR, config.MOTOR, 300)
     wait(1)
示例#5
0
 def jog(self):
     if (self.direction.get() == 0):
         dir='cw'
     else:
         dir='ccw'
     MOTOR.stepperCONFIG( 0,self.mVal,dir,self.ss.get(),self.rate.get(),self.acc.get())
     MOTOR.stepperJOG(0,self.mVal)
     self.stepState=1
示例#6
0
 def move(self):
     if (self.direction.get() == 0):
         dir='cw'
     else:
         dir='ccw'
     MOTOR.stepperCONFIG(0,self.mVal,dir,self.ss.get(),self.rate.get(),self.acc.get())
     MOTOR.stepperMOVE(0,self.mVal,self.steps.get())
     self.stepState=2
示例#7
0
def on_terminate():
    RELAY.RESET(0)
    RELAY.RESET(1)
    MOTOR.RESET(0)
    MOTOR.RESET(1)

    print("All relays and Motors are off.")
    print("Program has been terminated!")
示例#8
0
def main():
    # clear old move commands and start fresh, remove power and reset to a know state
    MOTOR.RESET(0)
    MOTOR.RESET(1)

    mqttc = MqttClient('hardware')
    mqttc.run()

    atexit.register(on_terminate)
示例#9
0
 def jogHome(self):
     #Initialize homing variables
     self.motorA = 1
     self.motorB = 1
     #Configure motor parameters for jogging
     self.sync_config(1, 150, 0)
     #Move steppers A and B towards switches
     MOTOR.stepperJOG(0, 'a')
     MOTOR.stepperJOG(0, 'b')
     #Wait for limit switch signal
     root.after(1, self.findHome)
示例#10
0
 def stop(self):
     for m in self._LEFT + self._RIGHT:
         MOTOR.dcSTOP(m._address, m._number)
         time.sleep(m._acceleration)
         m.speed = 0
         m._direction = m._forward
         MOTOR.dcCONFIG(m._address, m._number, m.direction, m.speed,
                        m._acceleration)
         m._stopped = True
         print("motor: {0}, {1}    speed: {2}    direction: {3}".format(
             m._address, m._number, m.speed, m.direction))
示例#11
0
def stop():    
    global position
    global moving
    global jogging
    print "entered stop "
    moving = 0
    jogging = 0
    stopped = 1
    MOTOR.clrLED(0)
    MOTOR.stepperSTOP (card, motor)
    position = 0
示例#12
0
 def stopAll(self):
     global intBITS, intFLAG
     intBITS = MOTOR.getINTflag0(0)
     intFlag = 0
     GPIO.cleanup(22) 
     #root.after_cancel(self._job)
     MOTOR.RESET(0)
     self.homeComplete = 0
     self.vFinal = 0
     self.cFinal = 0
     self.cycleCount = 0
     print('Stopping all processes')
示例#13
0
def move_rel (m_dist):
    global position
    global moving
    global accel
    global velocity

    if (position + m_dist < 0):
        error = 3
        print >> sys.stderr, "Invalid relative move (negative postion) aborting\n"
        return (error)
    
    if (dist < 0):
        direction = 'cw'
    else:
        direction = 'ccw'
    position += m_dist
    
    MOTOR.stepperCONFIG(card, motor, direction, 3, velocity, accel)
    stopped = 0
    moving = 1
    MOTOR.setLED(0)
    MOTOR.move(card, motor, m_dist)
    delay = m_dist / velocity
    delay += accel
    time.sleep(delay)
    moving = 0
    stopped = 1
    MOTOR.clrLED(0)
示例#14
0
 def interval(self):
     if (self.direction.get() == 0):
         dir='cw'
     else:
         dir='ccw'
     MOTOR.stepperCONFIG( 0,self.mVal,dir,self.ss.get(),self.rate.get(),self.acc.get())
     
     a = 1
     while a < self.rptSet.get(): #10: #self.ratedelta:
         MOTOR.stepperMOVE(0,self.mVal,self.steps.get())
         time.sleep(10) #(self.delay)
         a = a + 1
     
     self.stepState=1
示例#15
0
    def __init__(self, min_speed=25):
        # make the motor banks
        self._LEFT = [
            Motor(0, 1, 'cw', 'ccw'),
            Motor(0, 2, 'cw', 'ccw'),
            Motor(0, 3, 'cw', 'ccw')
        ]
        self._RIGHT = [
            Motor(1, 1, 'ccw', 'cw'),
            Motor(1, 2, 'ccw', 'cw'),
            Motor(1, 3, 'ccw', 'cw')
        ]

        # get the motors ready to run
        for m in self._LEFT:
            MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                           m._acceleration)
            print("Starting motors at speed 0.")
            MOTOR.dcSTART(m._address, m._number)
            m._stopped = False
        for m in self._RIGHT:
            MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                           m._acceleration)
            print("Starting motors at speed 0.")
            MOTOR.dcSTART(m._address, m._number)
            m._stopped = False
示例#16
0
def motors_off():
    """Stop and cut power to all motors"""

    motor.stepperSTOP(0, 'A')
    motor.stepperSTOP(0, 'B')
    motor.stepperOFF(0, 'A')
    motor.stepperOFF(0, 'B')
示例#17
0
 def stopAll(self):
     global intBITS, intFLAG
     intBITS = MOTOR.getINTflag0(0)
     intFlag = 0
     GPIO.cleanup(22)
     root.after_cancel(self._job)
     MOTOR.RESET(0)
     self.homeComplete = 0
     self.vFinal = 0
     self.cFinal = 0
     self.cycleCount = 0
     self.direction = 1
     self.disableAllbutHome()
     self.resetClocks()
     print('Stopping all processes')
     print('Please re-Home and reset volume and cycles')
示例#18
0
def MotorOff():
    #print("Stopping Motor")
    MOTOR.dcSTOP(ctl,FL)
    MOTOR.dcSTOP(ctl,FR)
    MOTOR.dcSTOP(ctl,RL)
    MOTOR.dcSTOP(ctl,RR)
        
    status = "stopped"
    return status
示例#19
0
def right(FLspeed,FRspeed,RLspeed,RRspeed):
	status = initMotor('cw','ccw','cw','ccw')
	MOTOR.dcSTART(ctl,FL)
	MOTOR.dcSTART(ctl,FR)
	MOTOR.dcSTART(ctl,RL)
	MOTOR.dcSTART(ctl,RR)
	
	status = 'right'
	return status
示例#20
0
def fwd(FLspeed,FRspeed,RLspeed,RRspeed):
	# print("Forward motion called. CTL: ",ctl)
	status = initMotor('cw','cw','cw','cw')
	MOTOR.dcSTART(ctl, FL)
	MOTOR.dcSTART(ctl, FR)
	MOTOR.dcSTART(ctl, RL)
	MOTOR.dcSTART(ctl, RR)
	
	status = "forward"
	return status
示例#21
0
def reverse(FLspeed,FRspeed,RLspeed,RRspeed):
	#print("Reverse motion called. CTL: ")
	status = initMotor('ccw','ccw','ccw','ccw')
	MOTOR.dcSTART(ctl, FL)
	MOTOR.dcSTART(ctl, FR)
	MOTOR.dcSTART(ctl, RL)
	MOTOR.dcSTART(ctl, RR)
	
	status = "reverse"
	return status
示例#22
0
    def __init__(self,master,r,c):
        self.master=master
        self.initialization=False
        self.sm=Frame(self.master,padx=4,pady=4,bd=2,relief='sunken')
        self.sm.grid(row=r,column=c, sticky=N+S+W+E)
        
        ##Create Fonts
        self.title=tkFont.Font(family='Helvetica', size=25, weight='bold') 
        self.heading=tkFont.Font(family='Helvetica', size=18, weight='bold')
        self.content=tkFont.Font(family='Helvetica', size=12, weight='bold')


        self.dir_dict = {0:'cw', 1:'ccw'}
        self.direction=1
        self.cycleCount=1
        
        self.bigStart=Button(self.sm,text="go",height=108,width=125,command=self.makeLysate)
        self.bigStart.grid(row=2,column=0,rowspan=2,padx=30,pady=4)
        self.intBITS=MOTOR.getINTflag0(0)
        self.intFLAG=1
        
                
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(22, GPIO.FALLING, callback=self.moveDone)
#allow interrupts when a motor stops
        MOTOR.enablestepSTOPint(0,'a')
        MOTOR.enablestepSTOPint(0,'b')
        MOTOR.intEnable(0)
示例#23
0
def jog_motor(direction):
    """Jog the selected direction"""

    if direction == 'up':
        motor_name = 'B'
        motor_dir = 'CCW'
    elif direction == 'down':
        motor_name = 'B'
        motor_dir = 'CW'
    elif direction == 'right':
        motor_name = 'A'
        motor_dir = 'CW'
    elif direction == 'left':
        motor_name = 'A'
        motor_dir = 'CCW'

    motor.stepperCONFIG(0, motor_name, motor_dir, 3, 2000, 0)
    motor.stepperJOG(0, motor_name)
示例#24
0
 def configmotors(self, speed, first=False):
     if (first):
         GPIO.setmode(GPIO.BCM)
         MOTOR.intEnable(0)  #enable interrupts on Pi-Plate
         MOTOR.enablestepSTOPint(
             0, 'A')  #set up to interrupt when motor a stops
         MOTOR.enablestepSTOPint(
             0, 'B')  #set up to interrupt when motor a stops
     MOTOR.stepperCONFIG(0, 'A', 'cw', 'H', speed, 0)
     MOTOR.stepperCONFIG(0, 'B', 'cw', 'H', speed, 0)
     pwm = [None, None, time.perf_counter()]
     GPIO.setup(4, GPIO.OUT)
     GPIO.setup(5, GPIO.OUT)
     pwm[0] = GPIO.PWM(4, 50)
     pwm[0].start(0)
     pwm[1] = GPIO.PWM(5, 50)
     pwm[1].start(0)
     return pwm
示例#25
0
 def stopAll(self):
     #root.after_cancel(self._job)
     MOTOR.RESET(0)
     self.homeComplete = 0
     self.vFinal = 0
     self.cFinal = 0
     self.cycleCount = 0
     self.intReset
     print("Stopping all processes")
示例#26
0
def check_switches():
    switch_status = motor.getSENSORS(0)
    if switch_status == 15:
        return 'none'
    elif switch_status == 11:
        return 'up'
    elif switch_status == 14:
        return 'right'
    else:
        return 'error'
示例#27
0
def is_stepper_online(mtr_number):
    address = 0
    if mtr_number in (3, 4): address = 1
    elif mtr_number in (5, 6): address = 2
    elif mtr_number in (7, 8): address = 3

    if MOTOR.getADDR(address) == address:
        return {"address": address, "state": "online"}
    else:
        return {"address": address, "state": "offline"}
示例#28
0
 def jogHome(self):
     #Initialize homing variables
     self.motorA = 1
     self.motorB = 1
     self.homeButton["state"] = "disabled" 
     #Configure motor parameters for jogging
     MOTOR.stepperCONFIG(0,'a','ccw','M8',150,0)
     MOTOR.stepperCONFIG(0,'b','ccw','M8',150,0)
     #Move steppers A and B towards switches
     MOTOR.stepperJOG(0,'a')
     MOTOR.stepperJOG(0,'b')
     #Wait for limit switch signal
     root.after(1,self.findHome)
示例#29
0
    def send_data(self):
        # create the sensor data message
        if self.verbose:
            data = json.dumps(
                {
                    "00-Title": "Limit switch status",
                    "01-Sensor1 status": bool(MOTOR.getSENSORS(0) & 0x01),
                    "02-Sensor2 status": bool(MOTOR.getSENSORS(0) & 0x02),
                    "03-Sensor3 status": bool(MOTOR.getSENSORS(0) & 0x04),
                    "04-Sensor4 status": bool(MOTOR.getSENSORS(0) & 0x08),
                    "05-Timestamp": time.strftime("%Y-%m-%d %H:%M:%S")
                },
                sort_keys=True)
        else:
            #short version
            # takes a while to get the sensor reading
            data = bin(MOTOR.getSENSORS(0) & 0x0F)

        #publish.single("sensors/data", data, hostname=broker)
        self.mqttc.publish(hostname + "/sensors/switch", data, 0)  # publish
示例#30
0
def get_card_address():
    relays = []
    motors = []
    for address in range(0, 2):
        relays.append(RELAY.getADDR(address))

    for address in range(0, 8):
        motors.append(MOTOR.getADDR(address))

    # remove duplicates with set

    return {'Relays': list(set(relays)), 'Steppers': list(set(motors))}