Essential principles - CNC theory
Home » Knowledge Base » SmartBench Knowledge Base » Essential principles » CNC theory
An introduction to datums, G-code, and post-processing. All the bits that mean SmartBench knows what you want it to do.
What are datums used for?
Datums are used to quickly position jobs on SmartBench.
When would I need to position a job?
Before you start a job on SmartBench, you will probably need to tell SmartBench where to start. This is usually because:
you may need to start cutting in a new area of the material, or
you are working with a new piece of material which may be in a new place.
What is a datum?
A datum is just the zero position of an axis. By setting the datums for the axes in both the job file, and on SmartBench, we create a common reference point. This means we can control where SmartBench does its work.
Where do I need to define datums?
In the job file: when creating our job file in CAD we need to define where the datums are for each of the 3 axes in that job, relative to the design. When the job file has been exported, these datums cannot be changed.
On SmartBench: we also need to define SmartBench’s datums – these can be changed between jobs easily.
When I’ve defined the job file datums and SmartBench datums, what happens next?
When the job file is loaded, SmartBench positions the job so that the job file datums match SmartBench’s datums. This means we can see where SmartBench will start cutting the job.
What would an example of setting datums look like?
Let’s imagine we want to design and cut out a simple, rectangular slab. The slab will have an X, Y and Z axis.
As we design this slab in CAD, we need to say where the datums will be, relative to our slab. We can position these anywhere we like. We will start with the X & Y axes.
Example: XY datum at bottom left
XY datums in CAD
In the CAD environment we create our job file (here we are using Vectric). We are setting the X and Y datums to be bottom and left.
Looking down on our rectangular slab model, this would position the X and Y datums like this:
Note that the X and Y datums (zero positions for the axes) are at the bottom left corner of the material.
XY datums on SmartBench
If we cut this on SmartBench now, where would SmartBench start cutting? To answer this we need to know what SmartBench considers to be X and Y axes, and where SmartBench’s XY datum is.
The X and Y axes on Smartbench are shown below:
SmartBench uses this symbol to define the XY datum:
In this example, SmartBench’s XY datum is near the home position, which is shown below. Also shown in red, is the area our slab would be cut in if we used SmartBench with its XY datum in its current position. Note how the job file datums and SmartBenchs datums are matched and the slab area extends away from the datum (positioned bottom left) as defined from the CAD environment in the previous section.
By moving the tool to a new position in the X and Y axes we can reset the position of the XY datum on SmartBench, and in doing so change area the slab will be cut:
By predefining the XY datum of the job in the CAD environment, and then moving the XY datum in Smartbench, we are in full control of the XY position at which SmartBench will start cutting the job.
Example: Z datum at the top of the material
Z datum in CAD
In the CAD environment (here we are using Vectric) we are setting the Z datum to be at the top of the material surface.
Looking at the side of our rectangular slab model, this would position the Z datum like this:
Note that the Z datum (zero position for the axis) is on the top surface of the material.
Z datum on SmartBench
If we cut this on SmartBench now, where would SmartBench start cutting? To answer this we need to know what SmartBench considers to be the Z axis, and where the Z datum is.
The Z axis and datum on Smartbench is illustrated in the control screen below:
SmartBench uses the line where the yellow and red zones meet as the definition of the Z datum.
The yellow zone represents the working envelope above Z zero (typically clearance moves). The red zone represents the working envelope below Z zero (typically cutting moves). |
By moving the tool to a new position in the Z axis we can reset the position of the Z datum on SmartBench, and in doing so change depth at which the slab will be cut:
By predefining the Z datum of the job in the CAD environment, and then moving the Z datum in Smartbench, we are in full control of the depth at which SmartBench will start cutting the job.
Will the datums be saved?
Job file datums
Once job files have been exported from CAD, the job file datums cannot be changed and will be saved with the file.
SmartBench datums
SmartBench datums will be saved every time they are set. They will persist even between power cycles.
Understanding G-codes
G-code is what SmartBench reads in order to bring a CAD/CAM model to life.
It is a set of instructions that tells CNC machines where to move, how fast to move and what path to follow. Each separate line or block contains a machining instruction.
G-code is shorthand for “geometric” code, and you might notice that many of the words or individual codes of this machine language also begin with the letter G. |
Functions of G-codes
The table below shows some frequently used G-codes along with their functions:
G-code | Function |
G00 | Rapid move (typically x mm/min) |
G01 | Linear move at given feed rate |
G20 | Length unit in inches |
G21 | Length unit in millimeters |
G90 | Distance mode to absolute coordinate |
G91 | Distance mode incremental, relative to current position |
Structure of G-code
G-code programming is structured in a systematic way for efficient manufacturing. A typical structure of a G-code program has the following:
A: Preparatory functions
This is where the machine sets up the starting tool, unit of measurement, plane, etc of a workpiece.
B: Dimension words
This is where the machine understands your stock dimension and a profile that needs to be cut, along with information such as spindle speed and feed rate.
C: Miscellaneous or machine function
This is where the machine functions are executed. For example: extraction on or off, spindle on or off.
In a human language the above G-code would direct a CNC machine as follows:
Load the starting tool (T1).
Plane for machining is XY (G17).
Set program length unit in millimeters (G21).
Set distance mode to absolute coordinate (G90).
Turn the spindle on (M3) at 1000 rpm (S1000.0).
Start the workflow at a given feed (G1) in the Z-axis (Z-0.300) at feed rate 100mm/min (F100.0).
Rapidly raise the spindle (G0) in the Z-axis (Z7.500) .
Stop the spindle (M5).
How is G-code produced?
The process for turning a design into G-code usually looks like this:
First, the 3D model is generated in CAD software.
The 3D CAD model is then imported into the CAM software, and the machining operations (toolpaths) are defined, e.g, roughing, finishing, drilling etc.
The post-processor (which will normally be part of your CAM software) converts the machine operations to G-code.
Sample G-code example
This section will show you how G-code is generated from a simple 3D model.
CAD model generation
The model is a 100x100x50 mm wooden block, which was modelled on Solidworks (CAD software).
CAM generation
The model is imported into CAM software (Vectric in this example), and the toolpaths are generated.
The colour coding is as follows:
The blue line shows the cut profile (100x100x50 mm), and is used to represent the coordinates in the X and Y axis.
The green line shows where the tool retracts and engages with the workpiece (Z-axis).
The red line indicates the safety height above the workpiece.
D: Stock
E: Profile to be cut
Click here to learn more about Vectric.
G-code generation (post-processing)
The CAM toolpaths are converted into G-code, via a post-processor.
G-code example
This is the G-code for this cut:
Preparatory functions |
T1 G17 G21 G90 |
Setting the dimensions |
G0Z18.500 G0X0.000Y0.000 S1000M3 G0X0.000Y-25.000Z7.500 |
Cutting the profile (square) |
G1Z1.100F100.0 G1X28.800F800.0 G1Z2.450 G3X25.000Y-21.200I-3.800J0.000 G1Z1.100 G1Y28.800 G1Z2.450 G3X21.200Y25.000I0.000J-3.800 G1Z1.100 G1X-28.800 G1Z2.450 G3X-25.000Y21.200I3.800J0.000 G1Z1.100 G1Y-28.800 G1Z2.450 G3X-21.200Y-25.000I0.000J3.800 G1Z1.100 G1X0.000 G1Z-0.300 G1X28.800 G1Z2.450 G3X25.000Y-21.200I-3.800J0.000 G1Z-0.300 G1Y28.800 G1Z2.450 G3X21.200Y25.000I0.000J-3.800 G1Z-0.300 G1X-28.800 G1Z2.450 G3X-25.000Y21.200I3.800J0.000 G1Z-0.300 G1Y-28.800 G1Z2.450 G3X-21.200Y-25.000I0.000J3.800 G1Z-0.300 G1X0.000 G0Z7.500 |
End of the job |
M5 G0Z18.500 G0X0.000Y0.000 M2 |
SmartBench
The G-code is then simply transferred to SmartBench, ready for manufacture.
Click here to learn more about how to transfer your G-code file to SmartBench.
What does post-processing do?
Post-processing reads the toolpaths you have generated in your CAD/CAM software, and saves them into job files which SmartBench can understand.
Before post-processing, you should check that your toolpath parameters are within the bounds of what SmartBench can do.
Your CAD/CAM software will ask which post-processor to use when saving the file. For your SmartBench, always choose: Grbl (metric). |
Post-processing converts the toolpaths into G-code, which is readable by SmartBench. |
When does post-processing happen?
Let us look at the whole CNC cycle, so that we can see how post-processing fits in to the end of the CAD/CAM workflow:
Pen and paper: all the best ideas are sketched out on a piece of paper first 🙂
CAD environment: the part design is drawn up in the computer.
CAM environment: the machining operations are then defined, which then allows the software to automatically generate the toolpaths.
Post-processor: these toolpaths are converted into a job file, using SmartBench’s specifications, which we can then send to SmartBench.
Depending on your software, your CAM files may be converted into multiple job files by your post-processor. This might happen if your job requires a tool change to manufacture the part. |
CAD stands for Computer-Aided Design. CAM stands for Computer-Aided Manufacture. CNC stands for Computerised Numerical Control. |
Toolpath parameters for SmartBench
Before post-processing your toolpaths for SmartBench, you need to make sure the parameters are with the specified range.
Programming feed rate or spindle speed too high or low might not work with your machine, or may cause it to run in a way you do not expect. |
Loading a job size bigger than the machine bed will halt the machining operation. |
Number of axes | 3-axis |
Spindle orientation | Vertical |
Max sheet cut size (mm) | 2500 x 1250 |
Max depth of material (mm) | 152 |
Spindle speed range (rpm) | 5,000 – 25,000 rpm |
Max feed rate range in X,Y axis (mm/min) | 6000 |
Max feed rate range in Z axis (mm/min) | 2000 |
Post-processor type | Grbl (metric) |
Different post-processors are needed for different CNC machines
Different CNC machines use different real-time processors to coordinate movement, and each of these will expect G-code instructions to be in a particular format.
This is why you need to select the right post-processor for your CNC machine when you save the toolpaths to a job file.
Using a job file that has been made for a different machine may cause your job to be carried out in a way you don’t expect, and could potentially damage your workpiece.
Your CAD/CAM software will ask which post-processor to use when saving the file. For your SmartBench, always choose: Grbl (metric). |