Is It Possible To Create Peck Cycles With Macros?

Опубликовано: 20 Март 2026
на канале: Practical Machinist
2,661
62

We all use peck drilling cycles, but is it possible to write our own longhand peck cycles using macros?
This week, Marc from ‪@GCodeTutor‬ dives deep into writing macro programs.
Marc starts by defining the variables that we will use, as we will be recalling them later within the program.

The next stage is to set up our work environment with a safety line, tool call, and move our drill into the initial position. Once this stage is completed, we can move on to the hard part—the macro program section.

For the peck drill macro to work, we are going to use a WHILE loop. This section will keep repeating until the final depth is achieved.

Then, the final part of our program moves the tool home, turns off the coolant and spindle, and ends the program in a safe way.

This example program is a thought experiment; it has not been tested on a machine and should not be copy-pasted into your machine with the expectation that it will work. As each machine is slightly different, you should never copy the code you find online.

Did this blow your mind? You can learn how to think in macros with Marc’s CNC courses over at GCodeTutor.com.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you want any more information about these codes or other G-code information, head to
Website: https://gcodetutor.com/
Instagram:   / gcodetutor  
Facebook:   / gcodetutor  
Twitter:   / gcodetutor  
YouTube: @GCodeTutor
Pinterest: https://www.pinterest.co.uk/gcodetuto...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Practical Machinist is the largest and most engaged #metalworking community across the web. With more than 200,000 registered members and 400,000+ social media followers, Practical Machinist is the easiest way to learn new techniques, get answers quickly, and discuss common challenges with your peers. Visit Practical Machinist today to join the community and start connecting with your peers.


Become a Practical Machinist member (https://www.practicalmachinist.com/)
Like us on Facebook (  / practicalmachinist  )
Follow us on Instagram (  / practicalmachinist  )
Follow us on Twitter (  / prac_machinist  )
Follow us on TikTok (  / practicalmachinist  )
Connect with us on LinkedIn (  / practical-machinist  )

#machining #metalwoking #gcode