Ejemplo n.º 1
0
    def zero_me(self):
        '''Zero the plotter(move it to home)'''
        # The delay in us
        delay = frequency_to_delay(mm_to_steps(config.ZERO_RATE))

        # 1 Second of waves are generated at a time(just in case)
        safety_pregen_no = mm_to_steps(config.ZERO_RATE)
        # For each axis
        for is_x, triggerp, extent, endinverted in [[
                True, config.X_MIN, config.X_EXTENT, config.X_END_INVERTED
        ], [False, config.Y_MIN, config.Y_EXTENT, config.Y_END_INVERTED]]:

            self.wait_till_idle()

            theoretical_maximum_steps = mm_to_steps(extent)
            steps_moved = 0
            while steps_moved < theoretical_maximum_steps:
                # This limits just in case of malfunction (inversion for endstops -> high when pressed)
                endstop = (self.gpio.read(triggerp) == 1) == endinverted
                if endstop:
                    self.stop()
                    logger.info("ZERO AXIS SUCCESS")
                    break
                if not self.dma.is_active():
                    self._set_direction(False, False)
                    for _ in range(safety_pregen_no):
                        steps_moved += 1
                        self._pulse_steppers(is_x, not is_x, delay)
        # We are now zeroed.
        self.location = Point(0, 0)
Ejemplo n.º 2
0
 def __init__(self, x, y, unit='mm'):
     # Initialise as either mm or steps
     # Internally stored as steps
     if unit == 'mm':
         self.x = utils.mm_to_steps(x)
         self.y = utils.mm_to_steps(y)
     else:
         self.x = x
         self.y = y
Ejemplo n.º 3
0
    def goto(self, point):
        logger.info("GOTO " + str(point))
        # Get no. steps to endpoint
        x, y = self._get_steps_to(point)
        dirx = diry = True
        # If steps are negative, change direction and make steps positive
        if (x < 0):
            dirx = False
            x = abs(x)
        if (y < 0):
            diry = False
            y = abs(y)

        # Add the pulse for setting the direction
        self._set_direction(dirx, diry)
        # Rate is a frequency, get us between pulses
        delay_per_pulseset = frequency_to_delay(mm_to_steps(config.GOTO_RATE))

        # -DEBUG-
        pulse_count = 0

        # Add pulses until correct no. of steps is achieved.
        while (x > 0) or (y > 0):
            # Decrement
            if x > 0:
                x -= 1
            if y > 0:
                y -= 1
            # Add the pulse for the steppers
            self._pulse_steppers(x > 0, y > 0, delay_per_pulseset)
            pulse_count += 1

        logger.debug("GOTO generated {} pulses".format(pulse_count))
        # Update location
        self.location = point
Ejemplo n.º 4
0
    def draw_line(self, start, finish, rate):
        logger.info("LINE from {} to {}".format(str(start), str(finish)))
        # ensure at start point
        if self.location != start:
            self.goto(start)
        # Get no. steps to endpoint
        x, y = self._get_steps_to(finish)
        dirx = diry = True
        # If steps are negative, change direction and make steps positive
        if (x < 0):
            dirx = False
            x = abs(x)
        if (y < 0):
            diry = False
            y = abs(y)

        # Add the pulse for setting the direction
        self._set_direction(dirx, diry)
        # generate pulses
        pulse_count = self._generate_line_pulses((x, y), mm_to_steps(rate))
        logger.debug("LINE generated {} pulses".format(pulse_count))

        self.location = finish
Ejemplo n.º 5
0
 def y_mm(self, value):
     self.y = utils.mm_to_steps(value)
Ejemplo n.º 6
0
 def x_mm(self, value):
     self.x = utils.mm_to_steps(value)