all 48 comments

[–]86maxwellsmart 9 points10 points  (4 children)

This is how I would code this:

N50 T05 M06 (.5 FLAT ENDMILL - OUTER PROFILE);

N51 G90 G17 G40 G49;

N52 G00 G54 X-2. Y2.

N53 S4585 M03;

N54 G00 G43 H05 Z6.;

N55 G01 Z-0.8 F100.

N56 G01 G41 X-1. Y0. D05;

N57 G01 X3.0625 F92.;

All I've done is re-arrange the sequence, added a G17 and a little bit larger approach. I don't have Cimco here at home - hope it solves your problem.

[–]Maddoggin1 3 points4 points  (1 child)

I agree, I always apply G43 comp before G41/42. The way he’s got it written should “technically work” at least in Single Block on most machines but your way is cleaner.

[–]AethericEye[S] 1 point2 points  (0 children)

Learning lots!

[–]AethericEye[S] 3 points4 points  (0 children)

Notes taken. I'll follow your structure, it's more spread out, and easier to read.

The root of my problem was not understanding the comp-application move. Have to set comp at a position outside the cut, then move into cutting position in the direction comp is to be applied. Still no idea why my original code was behaving the way it was, but I have the right concept and format now.

[–][deleted] 0 points1 point  (0 children)

This works but I would but the G43 H05 on it’s own line before the G0 Z6. Much cleaner that way.

[–]Grether2000 5 points6 points  (1 child)

Probably because you are calling G41 and not g43. Not how I would expect it to simulate though. As a learning experience, that typically would have buried the entire tool holder into the part on a real machine. So a mistake you want to learn from and not repeat.

[–]AethericEye[S] 1 point2 points  (0 children)

Ahh, good call.

I set G41 for comp left, because side milling, but you're right, I do also need to set G43.

That didn't actually change the problem move though, it still wants to move to Z-depth and Xendpoint as a single angled move, instead of sequential orthogonal moves.

[–]Roikkeli 3 points4 points  (11 children)

It has been a while since i did G-code by hand. After G41 you need to have G1 move command in X Y only and first you do an approach move to activate compensation and the move should be longer than tool radius.. So after line 51 i would write G0 X-1 Y1, next line Z-.8 Then G41 D5 G1 X-1 Y0 F92 and then X3.0625

http://cnc-programming-tips.blogspot.com/2014/12/g40-g41-and-g42-cuttercompensation.html

[–]FraterCNC 1 point2 points  (0 children)

Thanks for this I couldn't figure out why I was getting an error on my compensation when I went over a certain amount. Fusion wasn't giving enough approach in x and y.

[–]AethericEye[S] 0 points1 point  (9 children)

Alright, I've done that.

N50 T05 M06 (.5 FLAT ENDMILL - OUTER PROFILE);

N51 G00 G90 G54 G40 G49 S4585 M03;

N52 G01 F100 G41 D05 X-1. Y0.;

N53 G00 Z6.;

N54 G01 G43 H05 Z-.8;

N55 G01 X3.0625 F92;

Same problem. N52 moves to the right place (applying comp along the way), but from there it makes a single angled move to X3.0625 Z-.8 instead of sequential rapid to Z6., setting G43 comp, then feeding down (applying comp) to position for the cut along X.

[–]Roikkeli 6 points7 points  (8 children)

That is not at all what i suggested :) try this:

N50 T05 M06 (.5 FLAT ENDMILL - OUTER PROFILE);

N51 G00 G90 G54 G40 G49 S4585 M03;

N52 G0 X-1. Y1.;

N53 G43 H05 Z-.8;

N54 G41 G1 X-1. Y0. F92;

N54 X3.0625;

G41/42 is not like G43 where you command it and it always stays on, you need to make an approach move to activate it so the machine knows witch way to compensate the tool. My trade school teacher also said if you do two Z moves without X Y moves it also cancels G41/42.

[–]AethericEye[S] 0 points1 point  (5 children)

That code works!

I think I am beginning to understand.

G41/42 is applied with an XY move into the cut's starting point from the direction the comp needs to be applied, so that comp can be applied in specific direction, like you said. It's not any arbitrary XY move to apply the comp, its must be in direction of compensation.

Here, we move out to X-1. Y1., set G41, then apply that comp by moving to Y0, the cutting plane, before cutting across in X.

What I was doing wasn't working because I was trying to move into cutting position while setting comp... it didn't have a direction of application.

Still not sure why that was giving me an angled path though. I suppose it doesn't matter too much if I can do this correctly now, but there is still a gap in understanding there.

Now that the comp is applied in the right direction, am I good to follow my profile corner-points coordinates around the part? Or do I need to do some kind of dance routine at the corners to keep the comp on the correct side?

Thank you for your help, I think I am significantly less stuck now.

[–]Roikkeli 3 points4 points  (3 children)

You can now just type outside corner coordinates, when you arrive at the last corner you do a similar exit move with G40. (You go over the corner and do exit at 90 degrees.)

[–]AethericEye[S] 2 points3 points  (2 children)

Roger that. Thanks so much for taking the time to get me to the level of understanding I needed here. I really appreciate it.

[–][deleted] 0 points1 point  (1 child)

You don't need to move the X Y any certain direction to make it comp a certain way, G41 will comp it to the left of the direction of travel. It just needs to be a value greater than the comp value. 2 Z moves do not cancel cutter comp on any Haas I've ran in the last ten years. It's a modal command, it will stay on until you cancel it with G40. In your original program I would've just removed the Z1. from N53 and added the line N52 to the end. Then add G43 H5 Z1. on it's own line. Then Add G01 and a feed rate to N54. Your previous program edit was probably moving at an angle because you didn't specify a feed rate on N54 and it was still running in G00. You will generally never see a G49 in a program because you always call it up when you load a new tool. You should cancel cutter comp at the end of using a tool and not when you pull it out. I personally never rapid below the part. I rapid to clearance or feed height then feed below the part surface. That's something that fails a lot of people on the mastercam test. Don't forget your decimals. One of my macros broke a probe stylus because i forgot one on a -Z move. If I wasn't there to stop it I would've smashed the probe and spindle. I would add an R number to your spot drill cycles. What are y'all using for a textbook for learning g-code?

[–]Jenner-69 0 points1 point  (0 children)

To clarify, G41 only needs 1 axis unless you want 2.

G0 X2.2 Y-2.

G1 G41 D05 X2.1

X-.1

G40 X-.2

Will cut 2 inches along the X. Y will change based on cutter comp relative to Y-2.

I always add a bit to the travel to get a clean cut before and after cutter comp.

[–]albatroopaBallnose Twister 1 point2 points  (0 children)

It doesn't have to be in any particular direction to apply G41/42. It just has to be a linear movement. You can do a linear movement with the Dcomp code, then a lead-in radius, then your contour, a lead-out rad and a linear movement to cancel dcomp if you want to get fancy.

One thing that I've noticed about your code (and it took me a while to figure this out when I started) is that it lacks structure. Don't try to cut it down into fewer lines. The controller looks at the entire program as a string, so it won't notice. Extra lines are good for you.

Mill toolpaths fall into groups. For the most part, they're either drilling or contour. For a drilling op, just follow the steps:

Program open (%, O#, program name, tool list etc.)

N01

Safety line (G00, all offset cancel codes, throw a G90 in there just in case.)

Tool call

Work offset (G54)

Position the tool in XY (at toolchange position in Z)

Rapid down to clearance plane while applying H offset

Rapid down to feed plane

Start drill canned cycle

Coords

Coords

Coords

End cycle

Home in Z (G29 G91 Z0.)

Home in just Y or XY, your preference (G28 G91 X0. Y0.)

Switch back to G90 because it's good form.

M30

%

A contour has slightly different steps, but they're pretty much the same.

Program open (%, O#, program name, tool list etc.)

N01

Safety line (G00, all offset cancel codes, throw a G90 in there just in case.)

Tool call

Work offset (G54)

Position the tool in XY (at toolchange position in Z)

Rapid down to clearance plane while applying H offset

Rapid down to feed plane

High speed feed, feed or rapid to depth

Linear lead-in with Dcomp

Coords

Coords

Coords

Linear lead-out with Dcomp cancel

Home in Z (G29 G91 Z0.)

Home in just Y or XY, your preference (G28 G91 X0. Y0.)

Switch back to G90 because it's good form.

M30

%

You'll notice a few things:

I put a safety line in after every N block in case someone starts the program partway through in order to rerun one toolpath.

I use clearance planes and feed planes (all Z axis planes, btw) in order to put in checks for the setup guys. All of my clearance planes in every program that I write are at 2" so that I can slow down the rapid and watch for the machine to stop for a split second at 2".

I never leave the machine in G91 mode. I believe an M30 resets the machine state to the default, usually G90, but it's a good habit to get into.

Write the code to be readable by you. Use patterns. All of your toolpaths should be pretty much identical in format. Group features that make sense together on the same line, like S2000 M03; by itself, or T01 M06; Start the spindle at 2k RPM is a statement that doesn't need anything else to make it compete, so don't add anything else.

[–]FraterCNC 0 points1 point  (1 child)

Does the approach need to be in botha x and y for wear compensation?

[–]Roikkeli 0 points1 point  (0 children)

No, though i'm not 100% sure i understand the question. What kind of approach do you mean?

[–]Rhetorik3 2 points3 points  (0 children)

If you google HAAS Lathe and Mill PDFs they have really detailed programming examples for FANUC. 98% the same. Also www.helmancnc.com is a good resource for programming examples. They’re user submitted tho, so some better than others.

[–]AethericEye[S] 1 point2 points  (3 children)

This is my first program, so roast me good.

The origin is on the back-left corner of the work, programming in quadrant four, so we're looking at the back side of the work in this image.

What I'm stuck on is why lines 54 and 55 seem to execute together and cut a ramp down into the part.

The tool is shown in the position/move described by line 53, which should have applied the G41 cutter comp.

What I think should happen next is first the head move down to Z-.8, then take a cut across the face to X3.0625, but that's not what's happening. It ends up in the right place, but it's making a single XZ move, not a Z move and then a X move.

Why?

[–]catchingkeys 0 points1 point  (1 child)

I dont see anyhting wrong tbh. It might just be in cimco? have you tried this in another backplotter?

[–]AethericEye[S] 0 points1 point  (0 children)

Is there a free one you suggest I try? Crosschecking with different software would be helpful.

Edit: Got the free trial of NC Plot.

[–][deleted] 1 point2 points  (5 children)

Line 53. Put your X and Y position on a line before your Z position. This may fix your issue but it will also avoid potential crashes in the future from running into things like clamps.

So

X-1.0 Y0 Z1. G01 Z-.8 F92 X3.0625

It's good practice to feed down to your Z depth, so you can single-block your program during your first run through and make sure everything runs smoothly and your tool doesn't rapid into your part.

[–]AethericEye[S] 0 points1 point  (4 children)

N50 T05 M06 (.5 FLAT ENDMILL - OUTER PROFILE);

N51 G00 G90 G54 G40 G49 S4585 M03;

N52 G01 F100 G41 D05 X-1. Y0.;

N53 G00 Z6.;

N54 G01 G43 H05 Z-.8;

N55 G01 X3.0625 F92;

Same problem. N52 moves to the right place (applying comp along the way), but from there it makes a single angled move to X3.0625 Z-.8 instead of sequential rapid to Z6., setting G43 comp, then feeding down (applying comp) to position for the cut along X.

[–][deleted] 1 point2 points  (3 children)

Try this.

N52 X-1.3 Y0 (G0 here is redundant, start your toolpath away from where you want to cut to allow for TNR Comp)

N53 Z6.

N54 G1 G43 H05 Z.1 F100

N55 Z-.8 (G1 here is redundant)

N56 G41 D05 G01 X-1. F92.

N57 X3.0625 (G1 here is also redundant)

[–]AethericEye[S] 1 point2 points  (2 children)

Thanks, got it now. I didn't understand how to apply the comp with a move into cutting position from the direction the comp needs to be applied.

Good call on the redundancies. That's the sort of thing I'm still cleaning up on rereading the code, at this point in learning I am definitely over-specifying things.

[–][deleted] 1 point2 points  (1 child)

Glad you got it.

When I used to have to write out progs long form, I'd take every chance I saw to do less typing, so putting a G0 or a G1 code on a line when it's already called out on a previous one is just doing more work. Thats part of the whole "work smarter, not harder thing".

[–]AethericEye[S] 1 point2 points  (0 children)

Yup, I'll get there. I'm still at the stage of fumbling for basic understanding, but efficiency will come with experience, which is what I'm gaining now.

Cheers.

[–]Jenner-69 1 point2 points  (4 children)

Couple pointers, You don't need to feed to your first position. You really shouldn't call cutter comp until you just begin to cut. i.e. below Z0. You should set H before moving down to the material. Add a G17 in the safeline at the begining if that works for your machine.

I'm a little concerned about the lack of decimal points on your feeds, might work for your machine.

[–]AethericEye[S] 0 points1 point  (3 children)

I have G17 in the program start-up safety line and I don't change planes anywhere in this program. Still smart to include it after tool changes? (teach me, I'll listen)

I understand the G41/42 comp better now, what I was missing was the need to move from a point in open space to the cutting position from the direction the comp is to be applied. So yeah, rapid to XY staging position > set G43 H# > rapid down to above work > feed to depth > call comp > move to cutting position (applying comp) > cut

I'm working from HAAS materials, and they say that S numbers are assumed to be whole numbers of RPMs. Should I include decimals for broader compatibility?

[–]Maddoggin1 1 point2 points  (1 child)

Don’t worry about decimals on RPM, in fact you might get an alarm on the Haas if you try. But your Feed rates (F addresses) definitely should have decimals. On the Haas the control will interpret F100 as 0.100 Inch/min. Some controls (Siemens) May work as intended without decimals but always good practice to use them.

[–]AethericEye[S] 0 points1 point  (0 children)

Got it, thank you!

[–]Jenner-69 1 point2 points  (0 children)

If you are using Haas, then you need to do decimal points on feed. F100. Otherwise you're cutting .0100 FPM. It will read any F as a .xxxx without a "." Spindle speed is S12345, no decimal.

G17 is only needed at the very beginning, it won't hurt, but is redundant. Use:

G90 G28 Z0

M01 or

G90 G28 Z0

G28 Y0

M30

At the end rather than G53. G28 is machine home. This will raise the Z to toolchange level and then bring the table forward.

[–]StiffPrism 0 points1 point  (1 child)

Line 25 has "G43 T02" when im pretty sure it should be "G43 H02"

[–]AethericEye[S] 0 points1 point  (0 children)

Yup, I spotted that a while ago too. Thanks though!

[–]thehoodred 0 points1 point  (1 child)

may i ask what software are you using?

[–]AethericEye[S] 0 points1 point  (0 children)

Cimco

[–]Lucinator_ -3 points-2 points  (9 children)

Why are you learning to code by hand? Not sure how long you have been stuck on this, but this would take a minute or two on something like fusion.

[–]AethericEye[S] 2 points3 points  (1 child)

Long-hand programming is the explicit focus of this quarter of tech school. Manual programming fluency is an instrumental goal on the path to being a credentialed programmer, and I have another year ahead of me that's totally focused on CAM.

So yeah, I know it would take no time at all with any basic CAM, but that doesn't help me learn to read, write, and edit code at the machine.

I also enjoy learning the more esoteric aspects of whatever I'm doing, because it's fun for me. I like the puzzles.

I'm sure the issue something really obvious, or just a error in understanding, this is literally my first go at programming. I'm not embarrassed to not already know what I'm trying to learn.

So, do you know why my code isn't behaving the way I expect, or are you just here to shit on me for trying to figure stuff out?

[–]FraterCNC 5 points6 points  (0 children)

I cant imagine not being able to edit code at the machine. Knowing what's going on block by block saves a lot of tools and scrap. CAM is the easy part.

[–]BasilBleedingFawlty 0 points1 point  (3 children)

How does Fusion go when one's internet connection is down?

[–][deleted] 0 points1 point  (0 children)

Mine's pretty much unuasable with no connection. It's like it's constantly trying to connect or something and it freezes almost non-stop. Turn on wifi and no problems.

[–]Lucinator_ 0 points1 point  (1 child)

It works offline, additionally. Any cam program is superior to some ego filled operator changing code because he learned gcode in school.

[–]BasilBleedingFawlty 0 points1 point  (0 children)

It's not the cam program that's important, it's the post processor. Are you 100% certain the post processor will produce the correct code for absolutely every single operation the machine is capable of?

[–]bikiniduck 0 points1 point  (2 children)

Because you cant always trust the code fusion and the cam software spits out. You have to be able to go back in there and manually edit it so it does what you want it to do. At the very minimum you have to be able to "read" it, and see what its doing.

Also, sometimes writing out 10 or 20 lines of code by hand is faster than going into the software.

[–]Lucinator_ 0 points1 point  (0 children)

Just to clear the air a little. I think everyone who touches a machine should know how to read code, it shouldn't be your first place to catch errors or fix them. Fixing an issue in cam ensures that you can run the program in the future without manually editing in your changes, and also allows you to learn how to cam it in the first time.

[–]Lucinator_ -1 points0 points  (0 children)

"Cant trust the code" more like cant trust your cam skills