Welcome! Log In Create A New Profile


Setting up tool change in gcodetools?

Posted by Ohmarinus 
Setting up tool change in gcodetools?
July 07, 2019 05:26AM
Has anyone done a tool changer in (for example) a pen plotter before?

What I am wondering about, I can now successfully make a tool change from 1 to 2 and vice versa but adding a third tool complicates things. The tool can only be at one place at a given time. The tools are held on by magnets and are literally pulled away from the holding carriage by moving the gantry in the X-direction.

When we get to 3 tools the game changes. Now with only 2 tools I can assume the tool changes for both tools are just reversed gcodes for each other, eg: drop tool #1 in bay, move to #2 and pick it up and vice versa. However, when we get to three tools, how does my software do the reverse code? It needs to move from tool #3 for example and go to #1. I can only supply one line of custom gcode for the tool change and use one variable for each tool. So when I do it in succession, I can simply always say: drop tool 1 and move to tool 2, and then, drop tool 2 and move to tool 3. But what if I want the program to be able to pickup random tools? Sometimes I don't want to use tool #2, how would I handle the gcode moving from #1 to #3 and especially, how would I handle for example it putting back in #3 and then picking up #2?

How is this normally handled? Does it normally only move sequentially from 1 > 2 > 3 or does it use some kind of formula-stored variable to know what tool is in the head and where it should be dropped back in again? I have once seen a tool-changer wheel, this would of course make the idea way easier since it always docks in the same spot and only moves the wheel to the next index of the next tool.

The gcode for the pen change is this one, where tool["tool change gcode"] is the Y-axis location of the tool bay. I have a few tool bays spaced 100mm apart and the Y-axis is homed from the max endstop so tool #1 is located at for example 230mm and tool #2 is located at 130mm and tool #3 at 30mm:

M280 P0 S40 ; pen up for tool change
G1 X0 ; carriage into safe zone for tool change to happen
G1 Y230 ; move carriage to center of last TOOL
G1 X-25 ; move the carriage into the tool bay
M280 P0 S70 ; lower pen into tool bay
G1 X0 ; pull carriage back into safe zone for the tool to disconnect
G1 Y" + tool["tool change gcode"] + " ; move carriage to center of next TOOL
G1 X-25 ; move the carriage into the tool bay
M280 P0 S40 ; move pen mount up to lift up the next tool and continue print
G1 X30

If needed I can update with a video of how the tool changer works. It's far from perfect, but it's the first time I'm doing this and purposely haven't looked at the ideas of other people yet because I wanted to create an authentic and possibly inefficient system to master the concept first under my own terms. After this I'll iterate on this design since this 'LotusXY' pen plotter is only a proof of concept. I have large linear rails waiting for a good time.

I hope someone has some good advice, it's been very quiet over at the gcodetools forum and I know some of you have been doing this as well.

Here is some footage of the machine I'm working on, with a little portrait of myself looking very old hahaha:

Edited 2 time(s). Last edit at 07/07/2019 05:32AM by Ohmarinus.

Re: Setting up tool change in gcodetools?
July 07, 2019 07:05AM
... I've done this years ago for a pen-plotter with "snap-in/out" for 10 pens. In the pen holders an the tool-head were micro-switches to detect, if a pen was present.

Did the changing with same code, but different coordinates for every pen station - first step is "homing", then moving to the given pen station and "release" or "get" the pen (two macros per pen -- "release pen[nn]" and "get pen[nn]").

All I've need more, was starting with a "clean" or predefined setup (e.g. "no pen" or "pen [1]" in head) and from then on handle the pens as needed ...

*** EDIT ***

... remembered, that I've seen the 10x-penholder recently -- here, with one of the tool-heads:

Edited 1 time(s). Last edit at 07/07/2019 07:13AM by VDX.

Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: Setting up tool change in gcodetools?
July 07, 2019 07:46AM
Indeed, I believe the solution for me would be to convert the gcodetools plugin so that it allows a before and after tool change gcode rule. Right now it only allows one toolchange script.

I'm trying to do this purely with gcode, can it be there is a way to do this in Marlin? Meanwhile I'll try to figure out if I can add to the gcodetools file and have it so that the script manages a variable that remember which tool goes where.

Here is some footage of the most recent dry run:

Edited 6 time(s). Last edit at 07/09/2019 05:02AM by Ohmarinus.

open | download - Screen Shot 2019-07-09 at 00.53.56.png (134.5 KB)
open | download - Screen Shot 2019-07-09 at 00.48.17.png (81.7 KB)
open | download - gcodetools.py (264.8 KB)
open | download - gcodetools_tools_library.inx (2.4 KB)
Re: Setting up tool change in gcodetools?
July 09, 2019 05:02AM
Almost gotten it to run now, sadly it now injects a toolchange before and after each PATH... How the hell.. Okay, so I fixed almost everything I could find in the gcodetools.py but this one is crazy..

See the code here, I think this causes the issue together with the layer detection:

I have attached the gcodetools.py file here:

And the tools file here (needed to make the script run):

Somehow it should generate a tool change for each layer and not for each path. This causes every path to have a toolchange and makes the print take a VERY long time and it's become a tedious proces.

Would there be anyone who knows how to find out a fix for this? The gcodetools forum is dead.. Or would I be better off just switching to Fusion360 to generate my pen plotter files?... sad smiley I can't seem to find a reliable way to generate pen plotter files, how is everyone doing this? I see so many examples online but I can only find out Inkscape is being used yet I see so many pen changers out there.. I'm confused.

Edited 3 time(s). Last edit at 07/09/2019 05:04AM by Ohmarinus.

Re: Setting up tool change in gcodetools?
July 10, 2019 06:16AM
'Ladies and gentlemen' with the help of Stackoverflow for two comments on my scripts, I have managed to fix almost every bug there was in the gcodetools.py extension for inkscape. It now has fully functional tool changes with custom toolchange gcode for each tool. If anyone is interested, I might publish the upgraded extension in a new thread but I have to learn how to properly do it without breaking any copyright stuff.

Can anyone tell me how I can publish the fixed script with an included tutorial without qualifying myself for a lawsuit? I am very new to this kind of stuff.

The original data can be found in here:

Ai, it seems the gcodetools script really sucks in terms of creating data from curves. It breaks up the curves in very heavy to process lines. I have now switched back to the gcodeplot extension in Inkscape because that one generates much nicer lines. No hiccups and smooth sailing. So sadly, I still haven't found a nice extension or piece of software that both generates nice clean gcode that also allows tool changes..

Edited 2 time(s). Last edit at 07/13/2019 01:10PM by Ohmarinus.

Re: Setting up tool change in gcodetools?
February 06, 2020 10:53PM
Hi! Curious if you could post the link to your stack overflow solution that you referenced above. I would like to fix this layer/path issue with tool changes.
Re: Setting up tool change in gcodetools?
February 29, 2020 09:49PM
I know this is an old thread but in case anyone wants the tool change g-code to only be inserted on layer changes versus each path, just open the file gcodetools.py in the inkscape extensions folder and add the following line after line 3937:

self.last_used_tool = tool

So lines 3936 - 3938 should look like this:

		if tool != self.last_used_tool :
			g += ( "(Change tool to %s)\n" % re.sub("\"'\(\)\\\\"," ",tool["name"]) ) + tool["tool change gcode"] + "\n"
			self.last_used_tool = tool

Now when you add a tool to each layer the generated g-code will have your tool change g-code before each layer begins.
Sorry, only registered users may post in this forum.

Click here to login