Tool Change G Code and Z Touch Plate

New Home Forum Mostly Printed CNC – MPCNC Advice – MPCNC Tool Change G Code and Z Touch Plate

This topic contains 28 replies, has 13 voices, and was last updated by  Ryan 4 months, 2 weeks ago.

Viewing 29 posts - 1 through 29 (of 29 total)
  • Author
    Posts
  • #44416

    Andy M.
    Participant

    -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

     

    #44423

    Ryan
    Keymaster

    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.

    #44428

    Andy M.
    Participant

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

    #44439

    thesfreader
    Participant

    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)

    #44450

    Jeffeb3
    Participant

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

    #44451

    Jeffeb3
    Participant

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

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

    #44738

    Robert Kyle
    Participant

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

    #46429

    John
    Participant

    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??

    #46430

    Andy M.
    Participant

    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.

    #46438

    John
    Participant

    Yep, got it thanks

    #59181

    Justin
    Participant

    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?

    #59197

    Ryan
    Keymaster

    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.

    #59203

    unit416
    Participant

    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?

    #59204

    Todd Hansen
    Participant

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

    Z-Touch-Plate

    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:

    Manual-Control-Tab

    Then right click on one of the scrip bottoms.

    MC1

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

    Script-1

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

     

    3 users thanked author for this post.
    #59206

    Ryan
    Keymaster

    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 user thanked author for this post.
    #59238

    Justin
    Participant

    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?

    #59247

    Todd Hansen
    Participant

    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? 

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

    I would put the Gcode in Repetier.

    #59249

    Justin
    Participant

    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?

    #59253

    Todd Hansen
    Participant

    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.

    #59259

    Justin
    Participant

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

    #59266

    Todd Hansen
    Participant

    I do not know about clamps. Send me the link and I will take a look.

    #59268

    Ryan
    Keymaster

    It achieves the same thing, that was before dual endstops and dual endstops should be more accurate.

    You are getting pretty deep, you really might just want to get more cutting time under your belt and the things you really need will start to present themselves. The only time you should ever need accurate Z control, and homing is tool changes or production with Jigs. Any other time and you should be doing a facing operation or not worrying about it. Who cares if your project is less than a millimeter off it the Z direction, It really really has never effected anything I have ever done.

    You can do soooo much without changes tools, at worst it just takes a bit more time cutting.

    Make some stuff, do some carves. We got along fine for years without it, have fun and put away the calipers for a little while.

    #59286

    Justin
    Participant

    Yeah you’re probably right.

    #85884

    Deek
    Participant

    Just tried it out, worked great.  Had to sit for an hour and watch for the pause, but had plenty of time to swap out and off it was running.

    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)

    Thank you sir!

     

     

    #90016

    mostlydave
    Participant

    So where should the wires attach to the full size Rambo 1.4 for the z probe?

    #90023

    Barry
    Participant

    So where should the wires attach to the full size Rambo 1.4 for the z probe?

    Z-min endstop port.

    1 user thanked author for this post.
    #90061

    mostlydave
    Participant

    So where should the wires attach to the full size Rambo 1.4 for the z probe?

    Z-min endstop port.

    Thanks!

    #104689

    Karl S
    Participant
    I wanted to modify this a bit and display some important notifications on the LCD that tells me what the next step is. I intend on adding Z offset in my FIRMWARE not in the GCODE. This way I can do Z auto homing from both SD card and LCD. I wrote the following but have questions.
    Question 1: If the machine stops at line 1, its still in the middle of the work piece right? Don’t I need to add some code to raise up before I move it to the X0Y0 position?
    Question 2: Because I’m programing Z offset in my firmware I don’t believe that line 10 is required. Is this true?
    Question 3: Line 11 is still required right? Even if I don’t need the offset line listed above, because it’s in the firmware, I still need to set the new position to zero correct?
    1=M0 Turn off Spindle (stop machine and display “Turn off Spindle”)
    2=G0 X0.0000 Y0.0000 F2100 (Move to zero on X and Y)
    3=M18 Z (Disable Z Stepper Motor. This is disabled so you can manually move the Z axis up to get the new bit in)
    4=M0 Tool <n> (Display “Tool XXXXX”, where XXXXX is the next tool im using)
    5=M0 Z Touch Plate (Display “Touch Plate”)
    6=G28 Z (Home Z axis to touch plate)
    7=G1 Z2 F150 (Raise Z axis 2mm at a feedrate of 150 in order to remove your touch plate)
    8=M0 Remove Touch Plate (Display “Remove Touch Plate”)
    9=M0 Turn on Spindle (Display “Turn on Spindle)
    10=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.)
    11=G92 Z0 (This now sets the Z axis to zero at the offset above, meaning the top of your workpiece)
    12=G0 Z5.0000 F480 (This pulls the z axis back up off the workpiece at a feedrate of 480)
    13=G0 X0.0000 Y0.0000 Z0.0000 F2100 (Go to zero on all axis. Probably not necessary but i like to do it)
    14=G0 Z5.0000 F480 ( Pull the Z axis back up off the workpiece at a feedrate of 480)
    Does this work?
    #104696

    Ryan
    Keymaster

    10-14 are not neeeded. G92 does not have to be Zero, just tell it where it is. You are moving it up and down 3-4 times. Touch the plate, move to a safe distance, tell it where it now is, start your job.

Viewing 29 posts - 1 through 29 (of 29 total)

You must be logged in to reply to this topic.