Merge branch 'master' into rpi3_experiment

This commit is contained in:
Nikolay Khabarov
2017-05-14 16:43:34 +03:00
2 changed files with 38 additions and 19 deletions
+3
View File
@@ -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. 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 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 environment due to the lack of real time GPIO control. Even kernel based
+17 -1
View File
@@ -51,7 +51,11 @@ def init():
pins = STEP_PIN_MASK_X | STEP_PIN_MASK_Y | STEP_PIN_MASK_Z pins = STEP_PIN_MASK_X | STEP_PIN_MASK_Y | STEP_PIN_MASK_Z
dma.clear() dma.clear()
dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US) dma.add_pulse(pins, STEPPER_PULSE_LINGTH_US)
while True: 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: if (STEP_PIN_MASK_X & pins) != 0 and gpio.read(ENDSTOP_PIN_X) == 0:
pins &= ~STEP_PIN_MASK_X pins &= ~STEP_PIN_MASK_X
dma.clear() dma.clear()
@@ -70,6 +74,18 @@ def init():
# limit velocity at ~10% of top velocity # limit velocity at ~10% of top velocity
time.sleep((1 / 0.10) / (STEPPER_MAX_VELOCITY_MM_PER_MIN time.sleep((1 / 0.10) / (STEPPER_MAX_VELOCITY_MM_PER_MIN
/ 60 * STEPPER_PULSES_PER_MM)) / 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): def spindle_control(percent):