G-Code Generation

Mathmatical|Software|CAM

Image Image Image Image Image Image Image Image

DIY G-code generator

Engineering

This project was completed for a class (ME 290D) at Berkeley but I'm happy with my work and so I'm sharing it here. The premise was to develop some code to turn a Z-map into g-code. A Z-map is an array of height values and a given spacing. Imagine a chess board where each line intersection has a toothpick sticking out of it. The height of the toothpick is stored in the Z-map and the tile width is given and constant.
Long story short, an Inverse Tool Offset surface (ITO) shown is made by sweeping the tool cutter diameter (shown in blue) across the surface and then the tallest point above each grid intersection is chosen to make the ITO surface (shown in purple).
Once the ITO surface is generated, my code creates a parallel finishing pass by going in steps forward until the end, and then moving to the side to start a new row. The forward steps are determined by the curvature of the topography ahead, and the side step distance is determined by the maximum curvature throughout the forward run.
With the points chosen for G-code, a simple script runs through each point and outputs X, Z, and Y points to move the ball endmill!

What I did

  • Mathematical Modelling
  • Matlab Coding
  • G-Code Generation