Tool Change G Code and Z Touch Plate

-I thought i would hop on here and share my experiences with tool changes and the g code necessary to get the job done. When i first started with the machine i did not use a Z touch plate. Like most people i just moved the Z axis until it touched the top of the surface. This worked fine until i was engraving on ABS Sheet with a V bit. I literally could not tell where the top of the surface was because the bit was so sharp and the material was so soft. I had inconsistent depth so the look of the engraving varied quite a bit from piece to piece. So i researched using a touch plate. I had a pretty hard time getting a clarified reference on how to hook it up. I did eventually find the info needed and got it working. I have attached a picture of the connections that have to be made for the touch plate. After i started using it i really don’t understand why everyone doesn’t use it. You hook one wire to the mill bit and one wire to a plate, in my case a feeler gauge. Home the z axis and viola consistent depth every time. Super easy.

-Using the touch plate allowed me to explore typical tool change procedures. I originally ran the machine without an LCD. This presents a problem with tool changes because of the M0 code used to pause the program. This can normally only be resumed by clicking the knob on an LCD. There is no code available to restart after a plain M0 code. Although after more research i did find that a timer can be set to the M0 code. For example M0 S20 will pause the program for 20 seconds and return back to where it left off. I was able to write some simple g code that used this feature to do these tool changes successfully without an LCD. Here is the g code used without an LCD and comments to explain what each code does. I have attached the plain g code for anyone to use. Ill explain how to apply it in a bit.

M0 S10 (Pause for 10 Seconds. This is to signal you to turn the spindle off)
G0 X0.0000 Y0.0000 F2100 (Go to Zero on the X and Y Axis at a feed rate of 2100)
M18 Z (Disable Z Stepper Motor. This is disabled so you can manually move the Z axis up to get the new bit in)
M0 S120 (Pause For 120 seconds. This is when the tool change happens. This time can be shortened or lengthened. In my opinion it is much better to leave it extra long or the code will start to home the z before you have your touch plate ready.)
G28 Z (Home Z Axis to touch plate)
G1 Z2 F150 (Raise Z axis 2mm at a feed rate of 150 in order to remove your touch plate)
M0 S20 (Pause for 20 seconds. This is to signal you to turn the spindle on)
G1 Z-0.4 F150 (This sets the negative offset of the thickness of your touch plate. In my case, i use a .4mm feeler gauge. This would be changed to the thickness of your touch plate. Make sure and leave it negative.)
G92 Z0 (This now sets the Z axis to zero at the offset above, meaning the top of your work piece)
G0 Z5.0000 F480 (This pulls the z axis back up off the work piece at a feed rate of 480)
G0 X0.0000 Y0.0000 Z0.0000 F2100 (Go to zero on all axis. Probably not necessary but i like to do it)
G0 Z5.0000 F480 ( Pull the Z axis back up off the work piece at a feed rate of 480)

(The code will now continue where it left off)

 

-After a while i got an LCD. Again i highly recommend the LCD and don’t see any reason everyone shouldn’t use one. While using just the computer, i had issues with my usb connections going out on me and killing a job. After getting the LCD i have had zero problems. Since i could now resume a job after a plain M0 code i re-wrote the g code to suit. Here is the g code with comments that i now use with the LCD.

M0 (Pause code until resume is clicked on the LCD. This reminds you to turn off the spindle)
G0 X0.0000 Y0.0000 F2100 (Move to zero on X and Y)
M18 Z (Disable Z Stepper Motor. This is disabled so you can manually move the Z axis up to get the new bit in)
M0 (Pause code until resume is clicked on the LCD. This is for you to get your touch plate set up)
G28 Z (Home Z axis to touch plate)
G1 Z2 F150 (Raise Z axis 2mm at a feedrate of 150 in order to remove your touch plate)
M0 (Pause code until resume is clicked on the LCD.This is to un hook the touch plate and turn the spindle on)
G1 Z-0.4 F150 (This sets the negative offset of the thickness of your touch plate. In my case, i use a .4mm feeler guage. This would be changed to the thickness of your touch plate. Make sure and leave it negative.)
G92 Z0 (This now sets the Z axis to zero at the offset above, meaning the top of your workpiece)
G0 Z5.0000 F480 (This pulls the z axis back up off the workpiece at a feedrate of 480)
G0 X0.0000 Y0.0000 Z0.0000 F2100 (Go to zero on all axis. Probably not necessary but i like to do it)
G0 Z5.0000 F480 ( Pull the Z axis back up off the workpiece at a feedrate of 480)

(The code will now continue where it left off)

 

-Now how to apply it. If you want it to run for every tool change, of every job you create in Estlcam, go to to setup-cnc programs-text-tool change. Delete all the info in the box and paste either the “with LCD code” or the “without LCD code” and save the settings. If you want to use it only for some tool changes on some jobs, you have to edit the g code generated by Estlcam manually. I have uploaded a really poor quality video to demonstrate the without LCD code. (Not sure why the video looks wavy all the time. That only happened after upload.) I have also added my start program g code. You apply it by going setup-cnc programs-texts-program start in Estlcam. Hope this helps someone out, i really enjoy being able to use the tool change function without having to configure new g code for every tool change.

 

Thanks,

Andy

 

Tool-Change-With-LCD.txt (153 Bytes)

Start-code.txt (80 Bytes)

Tool-Change-Without-LCD-revision.txt (166 Bytes)

22 Likes

So clear and informative I am going to be linking this one a lot. Thank you so much for taking the time to type this one out!

So now you should give the new dual endstop firmware a test run and give us some feedback. This will (should) allow you to just run each piece independently no need for pauses and resumes. Different days, after a complete power cycle, home and go. If you always use the same touch plate you can set a Z offset in the firmware as well so a regular g28 will work.

If you get a chance to try it out let me know what you think and which way is easier.

Ryan, thats one of the next things on my list. I can definitely see the advantages of it.

Andy, thanks for the great wrap-up.

Just reminded me of something I has seen in the Marlin gcode M0 / M1 commands : you can add an additional message to show on the display, which you could add to “clarify” the reason for the pause

 

(Also M117 can change the LCD display message)

You can also split the gcode up into different files for different tools. As long as the motors stay engaged between files.

Is that the right video? It wasn’t a tool change.

Edit: my mistake. The link starts the video almost at the end.

Excellent description and guide to tool changes, many thanks Andy.

That was very informative Andy, thanks mate. I will play with it a bit today hopefully. I have already saved it in Estlcam.

Just one more newbie question: Tool changes are recognised automatically when you use more than one tool for a job, is that correct? Meaning, I don’t have to tell Estlcam I need a tool change??

Yes that is correct…any time you have more than one kind of tool chosen, it puts this section of code in the gcode…using the preview feature In estlcam you can see what order the tool changes are. Sometimes you need to set the machining order (instead of just automatic) to get everything in order properly.

Yep, got it thanks

Thank you so much for this write up Andy! I’ve been searching and cannot figure out how to wire a touch plate to a Rambo MINI can you provide some insight on how to do this?

Two wires to the Zmin port. One to negative, the other to “S” Signal. Alligator clip and a thin flat plate on the other ends. You are just making a manual/crude switch.

I have the z-touch set up on RAMPS and use a PC rather than an LCD. How do I account for the thickness of the touchplate? Is it something I need to do in Marlin’s firmware, or can I do it through Repetier?

If you look at Andy’s code will will see this:

[attachment file=“Z Touch Plate.png”]

The G1 Z-0.4 F150 brings the bit back down to the surface.

The G92 Z0 then set the Z0 to the height of the surface.

You can use that scrip in Repetier-Host in the Manual Control tab:

Click in the the Manual Control tab:

[attachment file=“Manual Control Tab.png”]

Then right click on one of the scrip bottoms.

[attachment file=59208]

You will get the Printer Settings box and enter you scrip.

[attachment file=“Script 1.png”]

Now you can run the script any time you need to.

 

Manual-Control-Tab.png

4 Likes

Todd’s post is probably how most do it. You can also add the offset in your firmware. Just depends where you are most comfortable. If you keep your gcode files for a long time it is best to use the firmware method in case the offset changes at some point. Both accomplish the exact same thing otherwise.

1 Like

Thanks. G0 X0.0000 Y0.0000 Z0.0000 F2100 tells it to go to X0 Y0 and Z0 and not to home all 3 axis’s does it? Also do I put the Gcode in Repetier or Estlcam?

The G0 tells the controller to move the head to X0 Y0 Z0, it is not homing.

I would put the Gcode in Repetier.

So I put the code i like you showed in your previous post and when I need to make a tool change I hit the 1? Do you do all your cuts in one file or have a file for carve on your project and when it’s done enter the gcode, change the tool, and cut with a regular bit?

I do each tool as a separate file.

Doing it this way gives me a stopping point if the project is long and do not have the time to do it all at one time.

After doing the tool change I run the scrip, then start cutting the next file.

You need to have the dual end stops when you stop between files.

What about clamps? I noticed that some old guy coding says he uses clamps for his tool change.