While I'm waiting for delivery of my cnc mill, its been recommended to me to learn g-code rather than just relying on conversational programming. Its all pretty bizarre to me, but after watching a bunch of videos have made my first try at it.
The project consists of a 5" x 5" x 0.5" piece of aluminum with four 0.5 holes drilled in it as a 3" square. This code is for the four center drill holes. X0 Y0 is the front left corner. Z0 is the top of the work piece.
This is presented as my work process rather than the way the actual code will be (has all my notes and expanations included so I can check whther it makes sense. Please let me know whether it will work.
% begin O00123 program number N5 G90 G20 G54 G28 G40 G80; Safe line G90 absolute positioning command G20 verify inch coordinate positioning G54 work offset positioning coordinate #1 G28 machine zero return thru reference point G40 cutter compensation cancel G41/G42/G141 G80 cancel canned cycle N10 T01; Load tool 1 (center drill) N15 G43 H01; Tool length compensation Tool 1 N20 S1000 M03; Set spindle speed 2000rpm Turn spindle on clockwise N25 G00 X-1.0 Y1.0; Fast movement to X,Y coordinates (first hole coordinates) N30 Z -1.0; Fast movement to Z coordinate N35 G01 Z 0.1; Slow movement to Z .1000 above workpiece N40 F20 Z-0.35 Z0.35; Drill start hole .25" deep and return N45 X-1.0 Y3.0; Coordinates for second hole N50 Z-0.35 Z0.35; Drill start hole .25" deep and return N55 X-3.0 Y3.0; Coordinates for third hole N60 Z-0.35 Z0.35; Drill start hole .25" deep and return N65 X-3.0 Y-3.0; Coordinates for fourth hole N70 Z-0.35 Z0.35; Drill start hole .25" deep and return N75 Z1.0 M05 Raise 1" above work spindle stop N80 G28 Machine zero return
% End
Thanks
Sorry. Formatting got all screwed up when I posted
Looks like you are rapid plunging the drill 0.5 inches into the table on your first Z move
N30 Z -1.0; Fast movement to Z coordinate
It also looks like you are mixing up G90 and what seems to be G91 (incremental) moves without setting a G91. Stick with the G90, and correct the G-code. Normally you will want to use G90 for all moves.
N50 Z-0.35 Z0.35; Drill start hole .25" deep and return
Ok, I think I got my head screwed back on straight. After checking out drilling codes as suggested I think I learned a few things. Whether I implemented them correctly I don't know!
Here is my revosed code:
% begin
O00123 program number
N5 G90 G20 G54 G28 G40 G80; Safe line
G90 absolute positioning command
G20 verify inch coordinate positioning
G54 work offset positioning coordinate #1
G28 machine zero return thru reference point
G40 cutter compensation cancel G41/G42/G141
G80 cancel canned cycle
N10 T01; Load tool 1 (center drill)
N15 G43 H01; Tool length compensation Tool 1
N20 S1000 M03; Set spindle speed 2000rpm Turn spindle on clockwise
N25 G00 X-1.0 Y1.0; Fast movement to X,Y coordinates (first hole coordinates)
N30 Z 1.0; Fast movement to Z coordinate
N35 G01 F20 Slow movement. Feed rate 20ipm
N40 G98 G81 R.01 Z-.25; Drill cycle, return to Z1.0
N45 X-1.0 Y4.0; Coordinates for second hole
N50 G98 G81 R.01 Z-.25; Drill cycle, return to Z1.0
N55 X-4.0 Y4.0; Coordinates for third hole
N60 G98 G81 R.01 Z-.25; Drill cycle, return to Z1.0
N65 X-4.0 Y1.0; Coordinates for fourth hole
N70 G98 G81 R.01 Z-.25; Drill cycle, return to Z1.0
N75 M05; Spindle stop
N80 G28 Machine zero return
% End
This is the drawing I'm working with. The code above only represents the first step.
This code snippet was generated with a Mach3 post in CamBam, but I don't know what you are using.
This is not the complete code, but just illustrates the use and format of G81. The dimensions are for the hole layout and position you described above, with the 3 inch hole pattern centered in the 5 inch square. 0,0 is at the bottom right as looking at it on the screen.
G0 Z1.0
M3 S1000
G0 X-1.0 Y1.0 (move to first hole)
G98 (start canned cycle(G81))
G81 X-1.0 Y1.0 Z-0.25 R0.1 F5.0
G81 Y4.0 Z-0.25
G81 X-4.0 Z-0.25
G81 Y1.0 Z-0.25
G80 (end canned cycle)
G0 Z1.0 (Retract to Z to safe position)
Let's use 2D Cartesian Coordinates to describe the location of the part There is no "front'' as looking at it on the screen Top, Bottom, Left, and Right are the easiest to use when working with a 2D drawing
Thanks Jim,
Much more simplified. I see that if an axis value doesn't change there is no need to state it again in following blocks. Is this always true or only in a canned cycle?
Based on your code, isn't 0,0 at the lower left? Spindle movement to the right is negative, correct?
I'm not using any program for what I have coded. Drawing was done in Fusion 360. Hardly know how to use it. Haven't tried the CAM yet.
Depending on the controller, the previous positions may not have to be repeated. It is true for any move, if the axis position doesn't change.
The tool moves in the negative direction as the tool is moving into the work. That physical direction could be to the right if the machine were laying on it's side At least I assume that we are working with a mill or a router here, rather than a horizontal machining center.
In Fusion or any solid modeling software, do not confuse the drawing layout with the CAM layout. In CAM you define the X, Y, and Z surfaces.
Hi, welcome to the starter's club........being a noob too I found starting with a simple work piece like 4 holes in a plate and modifying the code and re-writing it once the start lines were established made more sense to me than trying to create a complete complex.....relatively.....program that had too many values to get to grips with.
I also found that trying to write code without a machine to try it out on as I went along left me confused and not relating to what was happening........the Mach 3 screen with the on screen tool path made no sense to me before I got my mill.
I have a white board next to the mill and write a code sequence on it and run it as I go along.
If you get good with the simple code it gets better as you add to it.....any mistakes usually generate a warning from Mach 3 that it won't work, so you can backtrack to that point.
I also set up a dummy cutter using a 9mm diam wooden stick with a point to simulate a cutter and a block of wood in the vice to simulate the work piece.
I marked the wood block with a black marker and cross lines and then generated the code to run through a drilling sequence to hit the lines as if it was a drilling op.
Contrary and against advice to set the Z axis zero to the work piece top, I prefer to use a Z axis setting gauge to set the cutter tip to zero on the table top......the gauge gives me an exact 50mm above the table top.
I found too that it pays to know where your tool point is at any time, hence the preference to the table top Z axis zero point.........everything that is Z coded will be a + value.... FOR ALL TOOLS.
You also need to know EXACTLY the vice base thickness and the parallels that will be used to rest the job on........that is if you are using a vice......any old bits of steel strip will not do.
My vice base is 43mm thick and with a 20 mm parallel means I'm 63 mm above the table, but more specifically the bottom of the work piece on the parallel is 63mm.....that's all you need to know.......Z63 is the bottom of the job......Z43 is the top of the vice base......Z0 is the table top where you never need to go to.
Ian.
Thanks Ian,
I do think that once I have my mill it will make sense in a way that it can't right now. Its a challenge for my old brain to get familiar with a new language of sorts, but its quite exciting. I like the idea of having a white board at the mill. Great idea with the wood dummy tool and work piece. I was thinking I would just lower the knee some and let any new routine run in the air.
Well. I top you all.....2 years ago I didn't know what G code was and I'm now 78......been a manual machinist all my life and got the CNC bug, so it was a slight deviation from the norm for me.
One thing I did do and that was to browse many of the UTUBE tutorials with G code and setting up the mill from word go, then creating lots of notes on G code compiling.
I owe a huge debt to Mactec54 and many others for guiding me through the maze.
My mill is a Skyfire bench top model SVM-0, so it's a slightly different setup to the Bridgeport knee mill.
If you just move the cutter above the job you lose the experience of getting the Z axis commands right.......touching down onto the job with the wood point is a joy and it gives you confidence to mount a drill and do serious work.......milling is another challenge with tool offsets for various tool diams and lengths etc.....one big learning curve.
Ian. .
Close, but not quite. You still have your coordinate system a bit confused, and it can be confusing at first. Because you are working with a Bridgeport, think in terms of table movement. Your Y is correct, but X is inverted. Table moving to the right = -X, table moving to the left = +X. With 0,0 at the bottom left of the part, you are working in the +X, +Y quadrant. So all of your holes will be +X, +Y because the table is going to have to move to the left from 0 for the drill bit to be positioned over the hole.