Home CNC router as an alternative to a 3D printer, part three, software and G-code

    In this article, I would like to talk about the software necessary for the work, and at the same time give a small introduction on the g-code. Again, please forgive the layman, I can miss something, but be inaccurate in something. On the other hand, everything described in my articles is a purely personal experience, and it definitely works in close to office-garage-home conditions on simple Chinese CNC milling machines.

    Software for work can be divided according to the level of abstraction from bottom to top: firmware for engine drivers, “PU rack” or a software and hardware complex replacing it based on PC or MK, CAM - software that builds the tool path and converts it into a G-code, and CAD .

    The lowest-level software is motor driver firmware, which converts step and direction signals (step / dir) for stepper motors or speed / direction for servomotors into voltage and current values ​​supplied to the motor windings; we do not select or modify it, at least in the case under discussion.

    The next level is the “rack” - a hardware-software complex that converts lines of code into signals for drivers. Here it’s more interesting, at least at the stage of choosing a machine (or choosing components for self-construction), we can stop at both entry-level industrial racks (GSK, Washing, old Siemens and fanuki), and a combination of interface cards (from banal LPT and optocoupled Chinese red board up to MESA) with software - LinuxCNC, Mach3, NCStudio and others. Personally, I have a lot of positive experience with LinuxCNC and NCStudio; Despite the simplicity of both of them, they handle the ISO-7bit notation with a ready-made simple G-code with a bang. Industrial racks have an advantage in the flexibility of tuning drives and the ability to connect a large number of peripherals,

    A higher level is CAM (computer aided manufacture) program - software for creating trajectories that describe the passage of a tool in a workpiece. And here we have complete confusion and reeling. On the one hand, free or shareware CAM is not enough. Not to say there is no decent at all. Yes, there is a plugin for Inkscape, there are some unstable miracles of five years ago, there is trial fusion, there are plugins for CADs ... By the way, regarding very simple ones, we screwed G-CodeTools for Inkscape for a long time on the router, but we couldn’t achieve acceptable binder speeds operator-plugin. As a result, we bought CamBam + for $ 150 ridiculous by the standards of the market and enjoy it. And so - everything from cheap or free, or for very simple processing, or glitch on a glitch and glitch drives. We tried a bunch of everything in demos and broken versions, as a result, we negotiated with the toad and the findirector, and bought PowerMill - according to the reviews and emotions experienced in the process of sorting, perhaps the optimal tool for a small production. Later, wonderful SprutCAM comrades came to us, gave a demo, and we were horrified to find that we overpaid about 20 times - almost all of our needs were covered by the completely democratic SprutCAM Mach3. Of course, we bought it (like in reserve at a gift price), but then we found a couple of drawbacks, so we use exclusively PM. that overpaid about 20 times - almost all of our needs are covered by the completely democratic SprutCAM Mach3. Of course, we bought it (like in reserve at a gift price), but then we found a couple of drawbacks, so we use exclusively PM. that overpaid about 20 times - almost all of our needs are covered by the completely democratic SprutCAM Mach3. Of course, we bought it (like in reserve at a gift price), but then we found a couple of drawbacks, so we use exclusively PM.

    I almost forgot: an intermediate stage between the g-code and CAM is the postprocessor - once a separate program, and now the built-in module of any decent CAM. This is the very thing that converts the CAM path to the code of a particular machine. You only need to know about the postprocessor that it is, and that it has a description that is tied to a specific code notation perceived by the machine. Conventionally, some machines ask for line numbering, some - ";" at the end of each line, some generally accept commands in Russian letters, and so on. For the considered machines (home milling machines), regardless of whether MACH3, LinuxCNC or NCStudio, the standard fanuc0i 3axis post processor will go.

    Well, the highest level is CAD, it is already very far from the machine. Here the choice is almost endless, and even more free than in 3D printers, since the milling goes to the surface, and at the CAM input there may be not a solid model, but a boundary surface. Normal CAMs are almost omnivorous and with equal pleasure draw models from anything horrible - from 3DMAX to SolidWorks.

    G code


    Several times I began to write about g-code, but every time I cast it. On the one hand, the full g-code is ambiguous, at least in terms of cycles: even different series of machines of the same manufacturer can interpret g-codes in different ways, but in the main codes everything is clear. On the other hand, the modern CAM-system allows the operator to not know the g-code as a class at all, without having to twitch the mouse through the windows of the computer. But when one of our operators (good by the way, VO, experience and all that) did not cope with the task of "making a test program that runs the spindle up and down 1000 mm 1000 times", I realized that there should be at least a general understanding. Even if you do not write simple programs, then at least to disassemble and debug what the post processor wrote to us there.

    Firstly, it is worth knowing that g-code goes in frames, each line is a frame. The code

    G1 x10 y20

    will give a transition along the line connecting the current location and point x10y20, and the code

    G1 x10
    y20

    will give a transition along the polyline - first to the point (current position, x10), and then to the point x10y20.

    By the way, in the second example we can see the modality property: we can not write G1 at the beginning of the second line, because G1 is modal and the rack will understand the frame without code as duplicating code of the previous one. If we tried to go along an arc (G2 / G3) and also transferred the second part to the next line, the rack would interpret this line as a new G1 frame.

    So, the first group of codes that you should know are installation ones. This includes codes for setting the coordinate system, system of units, setting the correction of the length and radius of the tool. For a hobby hobbyist, it’s enough to know the security line from all this, which is placed at the beginning of each program:

    G17 G21 G40 G54 G80 G90

    And decoding: G17 (we work in the XY plane) G21 (units - millimeters) G40 (cancel compensation of the tool length) G49 (cancel compensation of the tool radius) G54 (work in the first coordinate system) G80 (cancel previously run constant cycles) G90 (work in absolute coordinate system). After such a horse dose of commands, any machine is cleansed of all possible sins left from previous treatments, and is ready to work on your project. Even if your machine does not know anything about correction, do not hesitate - against the background of the program body, these few bytes will not add much size to the program, the machine will simply ignore foreign codes, but everything will be fine.

    In general, perhaps, there is more to know and there is nothing to work on the machines under discussion.

    Unless G54 is a designation of work in the first coordinate system. The fact is that almost any rack by default supports a machine coordinate system (with zero on the end sensors, usually in the corner of the desktop), and up to 6 additional coordinate systems specified by the user. What for? When you work in CAM, you specify an arbitrary zero point - in the upper left near corner (this is more correct) or in the center of the workpiece, and the entire trajectory is described from this point. If the machine was able to work only in the machine SK, it would have to either put the workpiece at an angle of machine zero, or set the zero in a CAM at an unclear point, measured out relative to the actual location of the part. Why as many as 6 coordinate systems? Well, everything is also simple, although less commonly used: if the table allows you to set several blanks, it makes sense to combine processing: First go through all the workpieces with one mill, then change the mill and go through all again, well, etc. This is where different SKs come to the rescue: instead of splicing models in CAM, you can designate different SKs for workpieces and at the beginning of each processing write down in which SK we work.

    Theoretically, when manually writing a program, the G90 / G91 command can still help: choosing an absolute or relative coordinate system. Here, everything is also more or less simple: in the G90, the machine moves to the coordinates specified in the line, and in G91 - to the coordinates added to the current coordinates. So the machine standing at point X10Y10 on line G90 G1 x20 will go to point X20, and on line G91 G1 X20 - to point X30.

    The next group is movement codes. Everything is simple here, at least on the machines under discussion:

    G0 - idle movements are performed at the maximum speed set in the rack. It should be borne in mind that G0 does not always give linear movement, in some racks with the G0 X200 Y300 command when located at the point X0Y0, the working tool first goes 45 degrees to the point X200Y200, and then in a straight line to Y300. It makes sense to check how this happens on your machine, without knowing this subtlety you can accidentally crash into fasteners or a workpiece.

    G1 - linear interpolation. It is even simpler here, the machine always moves in a straight line between the current point and the point indicated in the code. The command assumes the syntax G1 X20Y30Z10 F1000, where F is the speed in units of the machine (more often millimeters per minute, but sometimes mm / s or something else exotic). Speed ​​is modal, i.e. if you specify the speed once, it will be valid for all subsequent lines G1 / G2 / G3, even if they are separated, for example, G0 or other codes.

    G2 / G3 - circular interpolation clockwise or counterclockwise. There are two possible definitions: when the machine is at point X0Y0, the G2 X10Y10R20 format will build an arc between the current point and the X10Y10 point with a radius of 20, the G2 format X35Y25 I20J-5 will build an arc between the current point and X35 Y25 centered at the point X (current point) + 20 Y (current point) -5.
    Theoretically, in advanced racks there are a lot of other interpolations - from sine to hyperbole, but in our machines and in the presence of CAM it is irrelevant.

    Well, a few more codes that are part of the ISO 7bit system, but are not g-codes. These are M03 (turning on the spindle) with argument S (rotation speed), M05 - stopping the spindle, M07 / 09 - giving and turning off the coolant, and M30 - ending the program.

    Fuh. It turned out to be somehow messy and prolonged, but it really can be useful. I say goodbye to this, in the next series I will write a little bit on materials for a home CNC milling cutter and describe the process of building processing in PowerMill.

    UPD other articles of the series:
    Home CNC milling cutter as an alternative to a 3D printer, part one - choosing a machine
    Home CNC milling cutter as an alternative to a 3D printer, part two, tools and accessories
    Home CNC milling cutter as an alternative to a 3D printer, part four. General processing concepts

    Also popular now: