Creating a G-Code VMC Runtime Calculator with Python

Creating a G-Code VMC Runtime Calculator with Python

A few months ago, I set out to create a simple tool in Python that would allow the user to paste G-code for a Vertical Machining Center (VMC) and provide the user with line-by-line insight of the runtime of the machine at various stages of the program. It took some time to achieve this, but using some OOP and Python's pandas library, I was able to achieve my goal.

The calculator I created allows the user to paste the G-code in a provided .txt file, called snippet.txt. The guidelines of the program require that:

  • The G-code is generated for a VMC (Vertical Machining Center) with at least 3 axes.
  • The file snippet.txt is where the desired G-code should be pasted. Python reads and parses this as a usual .txt file, not an .nc file.
  • There are no optional stops or program stops in snippet.txt; the tool runs continuously for all of snippet.txt.
  • The feed rate for the portion of G-code pasted into snippet.txt is unchanging for the entire portion.
  • The active tool used by the VMC is the same tool for the entirety of snippet.txt; no tool changes are allowed.
  • There are no optional stops or program stops in snippet.txt; the tool runs continuously for all of snippet.txt.

Once the user completes the prompts given by the program, the appropriate data from snippet.txt is extracted, calculations are made based on the user's input, and the resulting data is nicely organized into a .csv file which the user can access using a spreadsheet application such as Microsoft Excel or Google Sheets. The resulting workbook provides the user with information on the runtime of the machine as the machine progresses through the G-code line-by-line.

As many CNC machines in manufacturing today are either older, simply lack this feature of runtime tracking, or the data on machining runtime was lost for some reason, this calculator provides the user with approximations for runtimes using 3-dimensional Euclidean norms, and constant velocity formulas.

A repository for this program has been posted to GitHub. Access it here: https://github.com/chasereiter43/G-Code-VMC-Runtime-Calculator-via-Excel

To view or add a comment, sign in

More articles by Chase Reiter

Others also viewed

Explore content categories