Eli5: How do CNC machines convert digital images into real objects through mechanical movement?


So an electric motor converts electricity into mechanical movement.. But how is Code and digital data converted into mechanical movement ?

In: 2

The code. G Code, is a set of instructions on how much a servo motor will move an axis. The GCode will have specific codes for the type of movement, and can interpolate multiple axis at the same time, X,Y,Z,A,B,C would be 5 Axis and is used on complex surfaces.
GCode is generated by describing movement on a digital surface, running that movement through a post processor suitable for the machine you are using.

You have an x-axis, a y-axis, and a z-axis.

Every time you walk up to a CNC, you have to manually move it to a spot and then tell it *this spot, this one right here – consider this ZERO for all 3 axes.*

You can then tell a CNC, at the terminal, to plunge to a depth of .5” on the z-Axis. The motor has a sensor on it so it knows it has moved 1/2” downward from where you told it zero was.

And then from a point at 0,0 on the x,y you can move to 12,0. Which means you’ve just cut a 12” long straight horizontal line .5” deep from left to right.

If you tell it then to go to 12,12, you’ve cut another 12” straight line up. Go to 12,0, then, back to 0,0 and you have a 12” square cut out of 1/2” material.

Note that each axis has its own motor and each motor has its own sensor.

I can answer CNC questions all day, so if this didn’t explain it properly, or you have more questions, Lemme know!

The code is specifically designed to translate letters and numbers into movement.

`G90 G54 G43 H7 G0 Z1.0;` does the following:

Machine mode: absolute (as opposed to incremental)

Work offset: G54 (most modern machines support multiple work offsets so you can have multiple parts in the machine if you want)

Enable tool length offset

Tool length offset #7

Rapid move to one inch above the part

As you can see, this is largely nothing more than chaining together the commands you want. The machine controller reads each block in turn and knows to execute a specific action.

In very general terms:

You give CNC machine the digital description of a shape. This describes the geometry of the surface in very strict terms. If you had the skill to memorize and visualize the coordinates of 15 million points in Euclidean space, you would be able to also imagine, draw, or carve roughly the same shape from just looking at a list of 35 million numbers.

Once the CNC machine has this shape as a description, you set up your raw material on the machine’s working surface very specifically (it has a “center point” or a “zero point” where counting of dimensions starts from).

Then you set up the machine with the settings of the carving bit it uses. Different bits have different dimensions, and the machine needs to account for that.

From there on, it’s just a matter of the machine moving its carving bit into very specific locations and along very specific paths that trace the surface of the shape with the edge of the carving volume of a the bit.

Overall, you can try the following exercise at home:

1) Get a spherical lollipop, like a chupa-chups. This will be your carving bit.

2) Get a complex shape you’ll want to replicate.

3) Put that shape on a tabletop, then hold your lollipop by the stick and put the round thing on the shape. Start tracing that shape in parallel lines from one end to another. You can see that the lollipop never enters inside the solid matter of the shape, only tracing its curvature. This is exactly what a CNC machine does, but:

* instead of the shape you have the literal description of the shape
* instead of the lollipop you have deadly-sharp carving bit that takes off any material it enters
* instead of the empty space around the shape, you have solid raw material of your choice (wood, plastic, metal)

And the CNC machine, from that 35 million numbers, calculates how much to move the bit so that it does not enter inside the solid matter of the shape but just barely touch the surface.

Like others have said, the code represents the movements of the tool and other settings. So a line of code will say to move the tool from one location from another. Sensors keep track of how much the motors turn (I can go into this if you want) so the cnc machine knows where the tool currently is. It combines this with the knowledge of where it wants the motor to be to create an error for the motor (how much the position is off by). This is then fed through what’s called a controller that does math to determine how much electricity to apply to the motor to get it to move to the correct spot.