From 5dc077adab0353f0cf0e05a455174ed3a625b86f Mon Sep 17 00:00:00 2001 From: Nikolay Khabarov <2xl@mail.ru> Date: Sun, 14 May 2017 15:23:12 +0300 Subject: [PATCH 1/2] add travis badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ce61d6c..b252c74 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/Nikolay-Kha/PyCNC.svg?branch=master)](https://travis-ci.org/Nikolay-Kha/PyCNC) + +# PyCNC This project bring CNC control for Raspberry Pi or any ARM based Linux boards. Typically there is no way to control stepper motors from Linux runtime environment due to the lack of real time GPIO control. Even kernel based From 0e27a645a6b5871a811c77fceec9ecd93d3985b5 Mon Sep 17 00:00:00 2001 From: Nikolay Khabarov <2xl@mail.ru> Date: Sun, 14 May 2017 16:42:32 +0300 Subject: [PATCH 2/2] user friendly calibration --- cnc/hal_raspberry/hal.py | 54 ++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/cnc/hal_raspberry/hal.py b/cnc/hal_raspberry/hal.py index 3a8ef95..8946ce0 100644 --- a/cnc/hal_raspberry/hal.py +++ b/cnc/hal_raspberry/hal.py @@ -51,25 +51,41 @@ def init(): pins = STEP_PIN_MASK_X | STEP_PIN_MASK_Y | STEP_PIN_MASK_Z dma.clear() dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) - while True: - if (STEP_PIN_MASK_X & pins) != 0 and gpio.read(ENDSTOP_PIN_X) == 0: - pins &= ~STEP_PIN_MASK_X - dma.clear() - dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) - if (STEP_PIN_MASK_Y & pins) != 0 and gpio.read(ENDSTOP_PIN_Y) == 0: - pins &= ~STEP_PIN_MASK_Y - dma.clear() - dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) - if (STEP_PIN_MASK_Z & pins) != 0 and gpio.read(ENDSTOP_PIN_Z) == 0: - pins &= ~STEP_PIN_MASK_Z - dma.clear() - dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) - if pins == 0: - break - dma.run(False) - # limit velocity at ~10% of top velocity - time.sleep((1 / 0.10) / (STEPPER_MAX_VELOCITY_MM_PER_MIN - / 60 * STEPPER_PULSES_PER_MM)) + st = time.time() + max_pulses_left = int(1.2 * STEPPER_PULSES_PER_MM * max( + TABLE_SIZE_X_MM, TABLE_SIZE_Y_MM, TABLE_SIZE_Z_MM)) + try: + while max_pulses_left > 0: + if (STEP_PIN_MASK_X & pins) != 0 and gpio.read(ENDSTOP_PIN_X) == 0: + pins &= ~STEP_PIN_MASK_X + dma.clear() + dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) + if (STEP_PIN_MASK_Y & pins) != 0 and gpio.read(ENDSTOP_PIN_Y) == 0: + pins &= ~STEP_PIN_MASK_Y + dma.clear() + dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) + if (STEP_PIN_MASK_Z & pins) != 0 and gpio.read(ENDSTOP_PIN_Z) == 0: + pins &= ~STEP_PIN_MASK_Z + dma.clear() + dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) + if pins == 0: + break + dma.run(False) + # limit velocity at ~10% of top velocity + time.sleep((1 / 0.10) / (STEPPER_MAX_VELOCITY_MM_PER_MIN + / 60 * STEPPER_PULSES_PER_MM)) + max_pulses_left -= 1 + if st is not None: + if time.time() - st > 2: + logging.critical("Calibration still in progress. Check if " + "machine is moving.\nPress Ctrl+C to " + "cancel calibration and proceed as is.") + st = None + if pins != 0: + logging.critical("Calibration has failed. You may proceed, but be " + "careful.") + except KeyboardInterrupt: + logging.critical("Calibration has canceled by user. Be careful.") def spindle_control(percent):