Commit 1dde61ca authored by sumpfralle's avatar sumpfralle

fixed GCode generation for touch off when "safety height" is below the touch probe


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1012 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c933478e
......@@ -6134,73 +6134,6 @@ Choose a small value to minimize rapid moves up and down.</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="AbsoluteToolChangePositionBox">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Absolute touch off start position:</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosX">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">X</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosXValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosY">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Y</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosYValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosZ">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Z</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosZValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="TouchOffHeightLabel">
<property name="visible">True</property>
......@@ -6282,6 +6215,92 @@ Everyone else should use the option for M3/M5 (see above).</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="AbsoluteToolChangePositionBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="TouchOffAbsolutePositionWarning">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;span color="#FF0000"&gt;&lt;b&gt;WARNING:&lt;/b&gt; The initial touch off start location needs to be clearly &lt;u&gt;above&lt;/u&gt; the top of the material.&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox46">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Absolute touch off start position:</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosX">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosXValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosY">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosYValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="ToolChangePosZ">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">6</property>
<property name="adjustment">ToolChangePosZValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -118,13 +118,14 @@ class GCodeGenerator:
self.last_feedrate = 100
if touch_off_on_startup or touch_off_on_tool_change:
self.store_touch_off_position(touch_off_position)
self.touch_off_on_startup = touch_off_on_startup
self.touch_off_on_tool_change = touch_off_on_tool_change
self.touch_off_rapid_move = touch_off_rapid_move
self.touch_off_slow_move = touch_off_slow_move
self.touch_off_slow_feedrate = touch_off_slow_feedrate
self.touch_off_pause_execution = touch_off_pause_execution
if touch_off_on_startup:
self.run_touch_off(force_height=touch_off_height)
self.touch_off_height = touch_off_height
self._on_startup = True
def run_touch_off(self, new_tool_id=None, force_height=None):
# either "new_tool_id" or "force_height" should be specified
......@@ -148,16 +149,30 @@ class GCodeGenerator:
self.append("G28 (go up again)")
if not new_tool_id is None:
# compensate the length of the new tool
self.append("#1000=#5063 (store current tool length compensation)")
self.append("#100=#5063 (store current tool length compensation)")
self.append("T%d M6" % new_tool_id)
if self.touch_off_rapid_move > 0:
self.append("G0 Z-%f (go down rapidly)" % self.touch_off_rapid_move)
self.append("G38.2 Z-%f (do the touch off)" % self.touch_off_slow_move)
self.append("G28 (go up again)")
# compensate the tool length difference
self.append("G43.1 Z[#5063-#1000] (compensate the new tool length)")
self.append("G43.1 Z[#5063-#100] (compensate the new tool length)")
self.append("F%f (restore feed rate)" % self.last_feedrate)
self.append("G90 (disable incremental mode)")
# Move up to a safe height. This is either "safety height" or the touch
# off start location. The highest value of these two is used.
if self.touch_off_on_startup and not self.touch_off_height is None:
touch_off_safety_height = self.touch_off_height + \
self.touch_off_slow_move + self.touch_off_rapid_move
final_height = max(touch_off_safety_height, self.safety_height)
self.append("G0 Z%.3f" % final_height)
else:
# We assume, that the touch off start position is _above_ the
# top of the material. This is documented.
# A proper ("safer") implementation would compare "safety_height"
# with the touch off start location. But this requires "O"-Codes
# which are only usable for EMC2 (probably).
self.append("G53 G0 Z#5163 (go to touch off position: z)")
if self.touch_off_pause_execution:
self.append("(msg,Pausing after tool change)")
self.append("M0 (pause after touch off)")
......@@ -203,6 +218,7 @@ class GCodeGenerator:
def add_moves(self, moves, tool_id=None, comment=None):
if not comment is None:
self.add_comment(comment)
skip_safety_height_move = False
if not tool_id is None:
if self.last_tool_id == tool_id:
# nothing to be done
......@@ -210,11 +226,17 @@ class GCodeGenerator:
elif self.touch_off_on_tool_change and \
not (self.last_tool_id is None):
self.run_touch_off(new_tool_id=tool_id)
skip_safety_height_move = True
else:
self.append("T%d M6" % tool_id)
if self._on_startup and self.touch_off_on_startup:
self.run_touch_off(force_height=self.touch_off_height)
skip_safety_height_move = True
self._on_startup = False
self.last_tool_id = tool_id
# move straight up to safety height
self.add_move_to_safety()
if not skip_safety_height_move:
self.add_move_to_safety()
self.set_spindle_status(True)
for pos, rapid in moves:
self.add_move(pos, rapid=rapid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment