Exemplo n.º 1
0
 def set_active_endstops(self):
     """
 go through the list of endstops and load their active status into the PRU
 """
     # generate a binary representation of the active status
     active = 0
     for i, es in enumerate(["X1", "Y1", "Z1", "X2", "Y2", "Z2"]):
         if self.end_stops[es].active:
             active += 1 << i
     #logging.debug("endstop active mask = " + bin(active))
     # write to shared memory
     PruInterface.set_active_endstops(active)
Exemplo n.º 2
0
    def probe(self, z, speed, accel):
        self.wait_until_done()
        
        self.printer.ensure_steppers_enabled()
        
        # save the starting position
        start = self.get_current_pos()
        
        # calculate how many steps the requested z movement will require
        steps = np.ceil(z*self.printer.steps_pr_meter[2])
        z_dist = steps/self.printer.steps_pr_meter[2]
        logging.debug("Steps total: "+str(steps))
        
        # select the relative end point
        # this is not axis_config dependent as we are not swapping 
        # axis_config like we do when homing
        end   = {"Z":-z_dist}

        # tell the printer we are now in homing mode (updates firmware if required)        
        self.printer.homing(True)
        
        # add a relative move to the path planner
        # this tells the head to move down a set distance
        # the probe end-stop should be triggered during this move
        path = RelativePath(end, speed, accel, 
                            cancelable=True, 
                            use_bed_matrix=False, 
                            use_backlash_compensation=True, 
                            enable_soft_endstops=False)
        self.add_path(path)
        self.wait_until_done()

        # get the number of steps that we haven't done 
        steps_remaining = PruInterface.get_steps_remaining()
        logging.debug("Steps remaining : "+str(steps_remaining))

        # Calculate how many steps the Z axis moved
        steps -= steps_remaining
        z_dist = steps/self.printer.steps_pr_meter[2]
        
        # make a move to take us back to where we started
        end   = {"Z":z_dist}
        path = RelativePath(end, speed, accel, 
                            cancelable=True, 
                            use_bed_matrix=False, 
                            use_backlash_compensation=True, 
                            enable_soft_endstops=False)
        self.add_path(path)
        self.wait_until_done()
        
        # reset position back to  where we actually are
        path = G92Path(start)
        
        self.add_path(path)
        self.wait_until_done()
        
        # tell the printer we are no longer in homing mode (updates firmware if required)     
        self.printer.homing(False)
        
        return -z_dist
Exemplo n.º 3
0
    def set_active_endstops(self):
        """
        go through the list of endstops and load their active status into the PRU
        """

        # generate a binary representation of the active status
        active = 0
        for i, es in enumerate(["X1","Y1","Z1","X2","Y2","Z2"]):
            if self.end_stops[es].active:
                active += 1 << i
        
        logging.debug("endstop active mask = " + bin(active))
        
        # write to shared memory
        PruInterface.set_active_endstops(active)
        
        
        
        return
Exemplo n.º 4
0
 def read_value(self):
     """ Read the current endstop value from GPIO using PRU1 """
     state = PruInterface.get_shared_long(0)
     self.hit = bool(state & self.condition_bit)
Exemplo n.º 5
0
        """ An endStop has changed state """
        type_string = "hit" if self.hit else "released"
        event_string = "End Stop {} {}!".format(self.name, type_string)
        logging.info(event_string)
        for channel in ["octoprint", "toggle"]:
            if channel in self.printer.comms:
                self.printer.comms[channel].send_message(event_string)


if __name__ == "__main__":
    print("Test endstops")

    import time

    while True:
        state = PruInterface.get_shared_long(0)
        print(bin(state) + "  ", )
        if bool(state & (1 << 0)):
            print("X1", )
        elif bool(state & (1 << 1)):
            print("Y1", )
        elif bool(state & (1 << 2)):
            print("Z1", )
        elif bool(state & (1 << 3)):
            print("X2", )
        elif bool(state & (1 << 4)):
            print("Y2", )
        elif bool(state & (1 << 5)):
            print("Z2", )
        print((" " * 30) + "\r", )
        time.sleep(0.01)
Exemplo n.º 6
0
    def probe(self, z, speed, accel):
        self.wait_until_done()

        self.printer.ensure_steppers_enabled()

        # save the starting position
        start_pos = self.get_current_pos(ideal=True)
        start_state = self.native_planner.getState()

        # calculate how many steps the requested z movement will require
        steps = np.ceil(z * self.printer.steps_pr_meter[2])
        z_dist = steps / self.printer.steps_pr_meter[2]
        logging.debug("Steps total: " + str(steps))

        # select the relative end point
        # this is not axis_config dependent as we are not swapping
        # axis_config like we do when homing
        end = {"Z": -z_dist}

        # tell the printer we are now in homing mode (updates firmware if required)
        self.printer.homing(True)

        # add a relative move to the path planner
        # this tells the head to move down a set distance
        # the probe end-stop should be triggered during this move
        path = RelativePath(end,
                            speed,
                            accel,
                            cancelable=True,
                            use_bed_matrix=True,
                            use_backlash_compensation=True,
                            enable_soft_endstops=False)
        self.add_path(path)
        self.wait_until_done()

        # get the number of steps that we haven't done
        steps_remaining = PruInterface.get_steps_remaining()
        logging.debug("Steps remaining : " + str(steps_remaining))

        # Calculate how many steps the Z axis moved
        steps -= steps_remaining
        z_dist = steps / self.printer.steps_pr_meter[2]

        # make a move to take us back to where we started
        end = {"Z": z_dist}
        path = RelativePath(end,
                            speed,
                            accel,
                            cancelable=True,
                            use_bed_matrix=True,
                            use_backlash_compensation=True,
                            enable_soft_endstops=False)
        self.add_path(path)
        self.wait_until_done()

        # reset position back to  where we actually are
        path = G92Path({"Z": start_pos["Z"]}, use_bed_matrix=True)
        self.add_path(path)
        self.wait_until_done()
        start_state = self.native_planner.getState()

        # tell the printer we are no longer in homing mode (updates firmware if required)
        self.printer.homing(False)

        return -z_dist + start_pos["Z"]