# G-code assistance



## jlsmithseven (Feb 22, 2017)

Is this a good place to ask for G-code assistance? We are required to write our own G-code and I just got my first assignment. Can anyone here check it over for me or where would be a good place to get help?


----------



## Bill Gruby (Feb 22, 2017)

I am moving this to the CNC forum. They will give you the help you need,
"Billy G"


----------



## Wreck™Wreck (Feb 22, 2017)

Post the basic requirements and someone may help, the code encompasses a wide array of commands.


----------



## Boswell (Feb 22, 2017)

I am sure if you post what you have along with a description of what you are trying to do you can get some feedback.


----------



## T Bredehoft (Feb 22, 2017)

I'll be watching this, it's been 17 years, but I used to G-code on the fly, punching in programs standing at the pendant.


----------



## JimDawson (Feb 23, 2017)

We'll be happy to help you learn how to do it.


----------



## Bill Gruby (Feb 24, 2017)

Where did he go ????? Hasn't been here since Wednesday.


----------



## jlsmithseven (Feb 25, 2017)

A 6" vise is overkill for a RF45 style mill. A 4" is more appropiate for that size mill & IMO 5" max. I have a 5" GMT vise on my PM45 & it's slightly too big. Not enough Y axis travel to make use of the 5" full capacity. Better to save your money rather than getting something too big & most importantly the weight. I take my vise of the table quite often, a 6" is still light enough for me to be carried by hand but I'm glad I have a 5". I also have a 4" vise as well. I prefer the 5" though.

But those GMT 6" Premium vises are pretty nice. I'd love to have one but don't need one on my current mill. But if you plan on upgrading to a full size knee mill in the future than the 6" will be perfect.


Here's what the 5" looks like on my mill.




I couldn't even complete this cut without my bellows & DRO scale getting in the way. Not enough Y travel & the 5" vise is not even maxed out.




Here's what a 6" vise looks like on another PM45 (gt40's)
View attachment 253544


----------



## JimDawson (Feb 25, 2017)

jlsmithseven said:


> Anyways my biggest issue is just moving it up and down and making sure it touches. Like I have z1.0 at the start, then -1.0 but how do I know how far it goes down, etc? Can someone explain that. Thanks guys you are all awesome here!



You have to tell the machine where part (paper) zero is relative to the tool height.  So the first thing you have to do is tell the machine how long the tool is.  This is normally done on the machine by bringing the tool down until it just touches the work, then you enter that value into the tool table.   In this case, you have a tool height offset of 1.0  (N30 G00 Z1.0 G43 H01) so we can assume that when the tool is just touching the part, the height is 1.0 absolute.  To put a bit of pressure on the tool, then it would be 1.0 - 0.002 0r 0.998 absolute.  The DRO on the machine should be reading -0.002 at this point.

I hope this makes sense.

We'll work on the lifting and dropping the tool a bit later, that's the easy part after the tool zero is working.


----------



## jlsmithseven (Feb 25, 2017)

OK, so. The N30 line says Z1.0. That means that the machine is now 1 inch above the absolute coordinate I sent it to ( The bottom left of my J which is the start point where I want to touch down.) Correct? What is the next line N35 code doing then when I say Z .1. Does that move it back up .100 thousandths? Sorry I was just kind of copying code from our manual and trying to integrate it. Thank you for clarifying the tool offset a bit better, I'm kind of getting it but I'm still not completely there.

Could you possibly start at line N20 and work down from there and help me know what it's doing? I understand everything above that. Thanks!


----------



## JimDawson (Feb 25, 2017)

Can you just copy and paste the code into the text window, it will make things a lot easier.


----------



## jlsmithseven (Feb 25, 2017)

O7777

(Justin Smith)
(NameTag)
(Origin 0,0)
(Tool - Sharpie)
(Paper 8.5" x 11")

N5 G17 G20 G40 G80 G90

N10 M1

N15 M06 T1

N20 M03 S90

N25 G00 X1.0 Y2.0 G54 E1

N30 G00 Z1.0 G43 H01

N35 G00 Z.1

N40 G01 Z-.002 F3.0

N45 G03 X3.0 Y2.0 I1.0 J0.0

N50 G01 Y6.0

N55 X1.75

N60 X4.25

N65 G00 X4.75 Y6.0 G54 E1

N70 G01 Z-.002 F3.0

N75 Y-6.0

N80 X6.5

N85 G00 X7.25 Y2.0 G54 E1

N86 G01 Z-.002 F3.0

N90 G03 X9.5 Y2.0 I1.0 J0.0

N95 G03 X8.25 Y3.5 I-1.0 J1.5

N100 G02 X7.25 Y4.75 I-1.0 J1.25

N105 G02 X10 Y4.75 I1.25 J0.0

N110 G00 Z1.0

N115 M05

N120 G28

N125 M30

(all done, enjoy your broken sharpie)


----------



## JimDawson (Feb 25, 2017)

This should help explain what is going on, I added some code (xxxxxxxxx) to show the tool lifts

N5 G17 G20 G40 G80 G90

N10 M1

N15 M06 T1

N20 M03 S90

N25 G00 X1.0 Y2.0 G54 E1
Rapid X,Y to position, apply offset E1 (probably 0)

N30 G00 Z1.0 G43 H01
This line should not move the tool, but rather should apply the tool height offset to the DRO.

N35 G00 Z.1
Rapid Z down to 0.100 above part

N40 G01 Z-.002 F3.0
Move at plunge speed to -0.002

N45 G03 X3.0 Y2.0 I1.0 J0.0
Arc move CCW with an incremental radius of 1.0, end arc at X,Y position.  Arc starts at position in N25

N50 G01 Y6.0
Move to Y

(N51 G00 Z0.100)
Lift tool

N55 X1.75
Move to X

(N56 G01 Z-G.002)
Tool down

N60 X4.25
Move to X

(N61 G00 Z0.100)
Lift tool, end of ''J''

N65 G00 X4.75 Y6.0 G54 E1
Move to start of ''L'', top

N70 G01 Z-.002 F3.0
Tool Down

The code below here needs some attention, you are showing incremental moves, but you are in absolute mode (G90)

N75 Y-6.0

N80 X6.5

N85 G00 X7.25 Y2.0 G54 E1

N86 G01 Z-.002 F3.0

N90 G03 X9.5 Y2.0 I1.0 J0.0

N95 G03 X8.25 Y3.5 I-1.0 J1.5

N100 G02 X7.25 Y4.75 I-1.0 J1.25

N105 G02 X10 Y4.75 I1.25 J0.0

N110 G00 Z1.0

N115 M05

N120 G28

N125 M30

(all done, enjoy your broken sharpie)


----------



## jlsmithseven (Feb 25, 2017)

Thanks for the awesome clarification. Do you mind if I rework some of this tomorrow? It's late now but I want to attempt to re-do it based on your fixes. I really appreciate it!


----------



## JimDawson (Feb 25, 2017)

Any time you want.    G code and the process is easy to learn, prior to 2014 I couldn't even spell G code   You can teach an old dog new tricks.  You'll do fine.


----------



## jlsmithseven (Feb 26, 2017)

O7777

(JUSTIN SMITH)
(NAMETAG)
(ORIGIN 0,0)
(TOOL - SHARPIE)
(PAPER 8.5" X 11")

N5 G17 G20 G40 G80 G90

N10 M1

N15 M06 T1

N20 M03 S90

N25 G00 X1.0 Y2.0 G54 E1

N30 G00 Z1.0 G43 H01

N35 G00 Z.1

N40 G01 Z-.002 F3.0

N45 G03 X3.0 Y2.0 I1.0 J0.0

N50 G01 Y6.0

N51 G00 Z.100

N55 X1.75

N56 G01 Z-.002

N60 X4.25

N61 G00 Z.100

N65 G00 X4.75 Y6.0 G54 E1

N70 G01 Z-.002 F3.0

N75 Y.75

N80 X6.5

N81 G00 Z.100

N85 G00 X7.25 Y2.0 G54 E1

N86 G01 Z-.002 F3.0

N90 G03 X9.5 Y2.0 I1.13 J0.0

N95 G03 X8.25 Y3.5 R1.25

N100 G02 X7.25 Y4.75 R1.25

N105 G02 X9.5 Y4.75 I1.13 J0.0

N110 G00 Z1.0

N115 M05

N120 G28

N125 M30

(ALL DONE)


----------



## JimDawson (Feb 26, 2017)

Yup, a typo

I made a couple of changes below

N110 G00 Z1.0

N115 M05
Stop spindle

(N117 G49)
Cancel tool height offset

N120 G28
Go X,Y,Z home.  This could be replaced by some other code, maybe to move the table to a convenient location for a part change or measuring.

N125 M30
End program and rewind.  Rewind is old code for paper tape machines, where you actually had to rewind the tape, today it just jumps to the top of the program.


----------



## jlsmithseven (Feb 26, 2017)

sorry i thought I added that last lines to mine. i edited it and put mine in there. we don't need to put the G49 in I don't think because we haven't really learned that. he gave us a paper that shows us how to shutdown, but I will add it if need be. anyways, thank you so much for helping! everything i fixed looks good now? like the y-6.0 was incremental so i changed that to .075 i think that was right.


----------



## JimDawson (Feb 26, 2017)

I tried to run the code on my computer, but there is something wrong.  It doesn't like the code.  I'll figure it out and let you know.


----------



## jlsmithseven (Feb 26, 2017)

Well it's for a really old Fadal CNC. Keep that in mind. Also what software are you using to test it?


----------



## JimDawson (Feb 26, 2017)

Here is one problem, the arcs in the ''S'' are not correct.  But the ''J'' and ''L'' look good


----------



## jlsmithseven (Feb 26, 2017)

yeah i just downloaded a free program and i saw the same thing. it was fine up until my second arc movement, which i kind of figured was off. let me try to fix it on my own first.


----------



## jlsmithseven (Feb 26, 2017)

i EDITED my code up there. i used that free software and it let me see what i was doing wrong. learned a lot through you and this software. thank you so much!


----------



## JimDawson (Feb 26, 2017)

For testing I'm using a combination of CamBam, Mach3, and my own CNC software.

The screenshot is from CamBam, I just imported the nc file

Mach3 just throws errors.

My CNC software will digest any post processor format, but still doesn't display the toolpath correctly.  I need to look at a couple of settings.  The recompiled G-code looked OK.


----------



## JimDawson (Feb 26, 2017)

Please post your new code

EDIT:

I found my problem, your post pointed out a bug in my software.  It doesn't like the leading ''0'' in the G commands.  ''G01'' it doesn't like, but it does like ''G1''.  I need to fix that, it should digest either format.


----------



## jlsmithseven (Feb 26, 2017)

O7777

(JUSTIN SMITH)
(NAMETAG)
(ORIGIN 0,0)
(TOOL - SHARPIE)
(PAPER 8.5" X 11")

N5 G17 G20 G40 G80 G90

N10 M1

N15 M06 T1

N20 M03 S90

N25 G00 X1.0 Y2.0 G54 E1

N30 G00 Z1.0 G43 H01

N35 G00 Z.1

N40 G01 Z-.002 F3.0

N45 G03 X3.0 Y2.0 I1.0 J0.0

N50 G01 Y6.0

N51 G00 Z.100

N55 X1.75

N56 G01 Z-.002

N60 X4.25

N61 G00 Z.100

N65 G00 X4.75 Y6.0 G54 E1

N70 G01 Z-.002 F3.0

N75 Y.75

N80 X6.5

N81 G00 Z.100

N85 G00 X7.25 Y2.0 G54 E1

N86 G01 Z-.002 F3.0

N90 G03 X9.5 Y2.0 I1.13 J0.0

N95 G03 X8.25 Y3.5 R1.25

N100 G02 X7.25 Y4.75 R1.25

N105 G02 X9.5 Y4.75 I1.13 J0.0

N110 G00 Z1.0

N115 M05

N120 G28

N125 M30

(ALL DONE)


----------



## jlsmithseven (Feb 26, 2017)

oh ok.


----------



## T Bredehoft (Feb 27, 2017)

This all started what's left of my mind going. Somewhere......
One night I came to work, was told that 'tomorrow was open house' they wanted something like a key fob to pass out. The gave me a D print of the Company logo and a stack of 2 by 3 1/2 Lucite pieces. It took the whole shift, but when I left (with instructions) anyone could put a blank piece "right there' in the  vice and push 'that' button and it would turn out a company logo on the Lucite. This must have been 30  years ago. 
I found one of the pieces in an old tool box. The originals had a 3/16 hole in a lower corner for a ball chain. 




This is about 4X, the small lines are .020 wide. 
The company produces compressors for the natural gas industry, up to about 9,000 hp. The logo is a connecting rod. The name came from a motorcycle the owner once owned.


----------



## jlsmithseven (Mar 1, 2017)

That's funny because we just gave away connecting rod key chains at a stand we had for our college. Ironic.


----------

