mirror of
https://github.com/sinseman44/PyCNC.git
synced 2026-07-16 08:37:09 +00:00
deactivate round fonction when returning to home
This commit is contained in:
+18
-14
@@ -103,10 +103,11 @@ class GMachine(object):
|
|||||||
|
|
||||||
def __check_delta(self, delta):
|
def __check_delta(self, delta):
|
||||||
pos = self._position + delta
|
pos = self._position + delta
|
||||||
|
logging.debug("_check_delta : pos init = {} - delta = {} - pos = {}".format(self._position, delta, pos))
|
||||||
if not pos.is_in_aabb(Coordinates(0.0, 0.0, 0.0, 0.0),
|
if not pos.is_in_aabb(Coordinates(0.0, 0.0, 0.0, 0.0),
|
||||||
Coordinates(TABLE_SIZE_X_MM, TABLE_SIZE_Y_MM,
|
Coordinates(TABLE_SIZE_X_MM, TABLE_SIZE_Y_MM,
|
||||||
TABLE_SIZE_Z_MM, 0)):
|
TABLE_SIZE_Z_MM, 0)):
|
||||||
raise GMachineException("out of effective area")
|
raise GMachineException("[CHECK DELTA] out of effective area")
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
def __check_velocity(self, max_velocity):
|
def __check_velocity(self, max_velocity):
|
||||||
@@ -116,19 +117,17 @@ class GMachine(object):
|
|||||||
or max_velocity.e > MAX_VELOCITY_MM_PER_MIN_E:
|
or max_velocity.e > MAX_VELOCITY_MM_PER_MIN_E:
|
||||||
raise GMachineException("out of maximum speed")
|
raise GMachineException("out of maximum speed")
|
||||||
|
|
||||||
def _move_linear(self, delta, velocity):
|
def _move_linear(self, delta, velocity, safe_zero=False):
|
||||||
logging.info("[BEFORE] Moving linearly {}".format(delta))
|
if not safe_zero:
|
||||||
delta = delta.round(1.0 / STEPPER_PULSES_PER_MM_X,
|
delta = delta.round(1.0 / STEPPER_PULSES_PER_MM_X,
|
||||||
1.0 / STEPPER_PULSES_PER_MM_Y,
|
1.0 / STEPPER_PULSES_PER_MM_Y,
|
||||||
1.0 / STEPPER_PULSES_PER_MM_Z,
|
1.0 / STEPPER_PULSES_PER_MM_Z,
|
||||||
1.0 / STEPPER_PULSES_PER_MM_E)
|
1.0 / STEPPER_PULSES_PER_MM_E)
|
||||||
if delta.is_zero():
|
if delta.is_zero():
|
||||||
return
|
return
|
||||||
self.__check_delta(delta)
|
self.__check_delta(delta)
|
||||||
|
|
||||||
logging.info("Moving linearly {}".format(delta))
|
|
||||||
gen = PulseGeneratorLinear(delta, velocity)
|
gen = PulseGeneratorLinear(delta, velocity)
|
||||||
logging.debug("gen: {}".format(gen))
|
|
||||||
self.__check_velocity(gen.max_velocity())
|
self.__check_velocity(gen.max_velocity())
|
||||||
hal.move(gen)
|
hal.move(gen)
|
||||||
# save position
|
# save position
|
||||||
@@ -188,7 +187,7 @@ class GMachine(object):
|
|||||||
elif (pq == 3 and q == 4) or (pq == 4 and q == 3):
|
elif (pq == 3 and q == 4) or (pq == 4 and q == 3):
|
||||||
is_raise = (pb + rb - r < 0)
|
is_raise = (pb + rb - r < 0)
|
||||||
if is_raise:
|
if is_raise:
|
||||||
raise GMachineException("out of effective area")
|
raise GMachineException("[ADJUST CIRCLE] out of effective area")
|
||||||
pq = q
|
pq = q
|
||||||
return ea, eb
|
return ea, eb
|
||||||
|
|
||||||
@@ -257,19 +256,22 @@ class GMachine(object):
|
|||||||
:param y: boolean, move Y axis to zero
|
:param y: boolean, move Y axis to zero
|
||||||
:param z: boolean, move Z axis to zero
|
:param z: boolean, move Z axis to zero
|
||||||
"""
|
"""
|
||||||
|
logging.debug("[SAFE_ZERO] : X : {} - Y : {} - Z : {}".format(x,y,z))
|
||||||
if x and not y:
|
if x and not y:
|
||||||
self._move_linear(Coordinates(-self._position.x, 0, 0, 0),
|
self._move_linear(Coordinates(-self._position.x, 0, 0, 0),
|
||||||
MAX_VELOCITY_MM_PER_MIN_X)
|
MAX_VELOCITY_MM_PER_MIN_X, True)
|
||||||
elif y and not x:
|
elif y and not x:
|
||||||
self._move_linear(Coordinates(0, -self._position.y, 0, 0),
|
self._move_linear(Coordinates(0, -self._position.y, 0, 0),
|
||||||
MAX_VELOCITY_MM_PER_MIN_X)
|
MAX_VELOCITY_MM_PER_MIN_X, True)
|
||||||
elif x and y:
|
elif x and y:
|
||||||
d = Coordinates(-self._position.x, -self._position.y, 0, 0)
|
d = Coordinates(-self._position.x, -self._position.y, 0, 0)
|
||||||
|
logging.debug("[SAFE_ZERO] : d = {}".format(d))
|
||||||
self._move_linear(d, min(MAX_VELOCITY_MM_PER_MIN_X,
|
self._move_linear(d, min(MAX_VELOCITY_MM_PER_MIN_X,
|
||||||
MAX_VELOCITY_MM_PER_MIN_Y))
|
MAX_VELOCITY_MM_PER_MIN_Y),
|
||||||
|
True)
|
||||||
if z:
|
if z:
|
||||||
d = Coordinates(0, 0, -self._position.z, 0)
|
d = Coordinates(0, 0, -self._position.z, 0)
|
||||||
self._move_linear(d, MAX_VELOCITY_MM_PER_MIN_Z)
|
self._move_linear(d, MAX_VELOCITY_MM_PER_MIN_Z, True)
|
||||||
|
|
||||||
def position(self):
|
def position(self):
|
||||||
""" Return current machine position (after the latest command)
|
""" Return current machine position (after the latest command)
|
||||||
@@ -471,6 +473,8 @@ class GMachine(object):
|
|||||||
hal.join()
|
hal.join()
|
||||||
p = self.position()
|
p = self.position()
|
||||||
answer = "X:{} Y:{} Z:{} E:{}".format(p.x, p.y, p.z, p.e)
|
answer = "X:{} Y:{} Z:{} E:{}".format(p.x, p.y, p.z, p.e)
|
||||||
|
elif c == 'M117': # display a message
|
||||||
|
hal.set_message("TEST")
|
||||||
elif c == 'M300': # play sound normaly or control z axis
|
elif c == 'M300': # play sound normaly or control z axis
|
||||||
logging.debug("gcode = {}".format(gcode.get('S')))
|
logging.debug("gcode = {}".format(gcode.get('S')))
|
||||||
if gcode.get('S') == 30:
|
if gcode.get('S') == 30:
|
||||||
|
|||||||
@@ -137,3 +137,5 @@ if 'watchdog_feed' not in locals():
|
|||||||
raise NotImplementedError("hal.watchdog_feed() not implemented")
|
raise NotImplementedError("hal.watchdog_feed() not implemented")
|
||||||
if ENABLE_L293D and 'pen_control' not in locals():
|
if ENABLE_L293D and 'pen_control' not in locals():
|
||||||
raise NotImplementedError("hal.pen_control() not implemented")
|
raise NotImplementedError("hal.pen_control() not implemented")
|
||||||
|
if ENABLE_L293D and 'set_message' not in locals():
|
||||||
|
raise NotImplementedError("hal.set_message() not implemented")
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
G4 P150 (wait 150ms)
|
||||||
|
M300 S50
|
||||||
|
G4 P150 (wait 150ms)
|
||||||
|
G28
|
||||||
Reference in New Issue
Block a user