Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Fastest1 on October 16, 2009, 08:57:38 AM

Title: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 08:57:38 AM
I have a small aluminum L shaped piece. Imagine a capital L.
The longest side is 8.75"
The bottom is 4.25"
The inside cut of the upright is 7.5"
The upper side of the bottom is 2.75"
I would only like to cut the X sides 7.5" length in incremements of say .005 (it is a Sherline, I need to be cautious)
I would also like to cut the Y sides 2.75" the same amount til a 1/4" is removed, 50 passes?
Can both sides be cut in 1 pass? I do this thru the MDI with a calculator, its tedious and there has got to be a better way. I have never written anything but single lines.
So if I started the part cutting on x0 y0 with the z side milling only
Surface of part is z-3 as z home is at top of mill column.
Part is 1/2" thick
%
G00 X0 Y0 Z-2.95
G01 Z-3.30 F5
G17 X7.5 Y2.8 ? How do I get incrememntal cuts M98? P? L50? I would love to see a few steps done automatically. Thanks
Nobody has any advice?
Title: Re: Gcode questions pt2
Post by: ftomazz on October 16, 2009, 01:30:07 PM
This is what I would do:
Do the relevant part of the code as one passage only. Try the passage. This will be your subprogram after you tested it.
Use incremental mode to lower the Z axis at each passage.
Call your sub program the number of times needed to accomplish all the depth that you want (Your program will only be calls to your subprogram)

That is all.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 02:25:02 PM
Thank you, I am sure that would be the same if it was x or y as the moving axis? I have never used a subprogram or am I sure how to set 1 up. I typically input into the MDI exactly what coorcinate I want to go to and it cuts that plane. I then subtract given amount and repeat. I have used a g code for probing but that is it really.
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 16, 2009, 02:49:03 PM
Thank you, I am sure that would be the same if it was x or y as the moving axis? I have never used a subprogram or am I sure how to set 1 up. I typically input into the MDI exactly what coorcinate I want to go to and it cuts that plane. I then subtract given amount and repeat. I have used a g code for probing but that is it really.

Something like this:

G90 (Set absolute mode)
G0 Z0.000
G98 P0001 L50 (Call subroutine O0001 50 times)
G0 Z1 (Pull Z clear)
M30 (Done)
O0001
G91 (Set incremental mode)
G1 Z-0.005 F5 (Step down 0.005 in Z)
G90 (Set absolute mode)
(Put G1 moves to cut your profile here)
G99 (Return)
M30

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 05:05:36 PM
ftomazz & Ray again thank you. I am seeing more of the pattern in the suggestion you made. However I would rather have my incremental in both x & y axis and not z. If I am side milling only to finish the interior edge I would prefer not to step.
Wouldnt it be more like ?
%
G90
G0 X0.000
G98 P001 L50
G0 X1
M30
00001
G91
G1 X0.005
G90
G1 Y0 Y7
G99
M30
%
Wouldnt that be moving my cuts on the x axis incrementally by .005 while cutting down the Y side? From Y0 to Y7?
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 10:09:01 PM
Ok this is what I entered
G90
G0 Z0.000
G98 P0001 L50
G0 Z-2
O0001
G91 (Set incremental mode)
G17 X0.005 F25 (Step down 0.005 in Z)
G90
G1 X1
G17 X7
G99 (Return)
M30


It ran in the right direction, spindle stayed where I wanted it (or at least I put it where I wanted for this test) though I dont understand why it only made 1 pass? I am trying to cut along the x travel X0 thru X7 stepping .005 into the piece each pass. It didnt cycle at all.
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 16, 2009, 10:17:42 PM
You don't want G17s in there.  Those should be G1s.  Also, all your moves are in X.  Where are the Y moves?

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 10:42:32 PM
That is part of where I am confused. I wanted the cuts to happen along x but adding to Y. Such as the first cut starting at Y0 & X0 cutting to X7 returning to X0 then stepping over to Y.005 cutting from X0 to X7 and so on. Dont mind if it cut both ways until the finish pass. Btw the feedrate would have been fast for my sherline but who could wait to see what it was going to do? Thanks again Ray, your not going to be awake til I understand are you ? LOL
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 16, 2009, 10:55:09 PM
OK, try this:

G90
G0 X0 Y0
G0 Z0.000
G0 Z-2
M98 P0001 L50
M30
O0001
G91 (Set incremental mode)
G1 Y0.005 F25 (Step over +0.005 in Y)
G90 (Set absolute mode)
G1 X7 F50  (Cut from X0 to X7)
G0 X0 (Return to X0)
M99 (Return)
M30

 I gave you a bum steer.  The G98/G99 should've been M98/M99.

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 10:56:33 PM
You ask about Y cuts, I was settling for repetition on any axis. If I could cut both From X0 to X7 say .005 a pass and then Y0 to Y2.5 at the same rate .005 that would be great but as you can see I dont really have an idea how to implement it. I would think there has to be a final destination though 50 passes @.005 indicates 1/4".  
 
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 10:57:30 PM
I thought I had seen that m code before. Btw thanks for being awake!
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 11:04:39 PM
That looks alot better, thank you. How could I implement the same cut being done along Y during each pass the same cut amount of .005 ?
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 16, 2009, 11:05:54 PM
Even though I am just cutting air as of the moment it sure is easier than MDI!
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 16, 2009, 11:47:07 PM
You ask about Y cuts, I was settling for repetition on any axis. If I could cut both From X0 to X7 say .005 a pass and then Y0 to Y2.5 at the same rate .005 that would be great but as you can see I dont really have an idea how to implement it. I would think there has to be a final destination though 50 passes @.005 indicates 1/4".  
 

You're going about this in a rather unconventional way.  The more "normal" way to do it is to step down in Z, cutting the entire profile in each pass, then do one final, full-depth pass to put the final finish on.  So, for example, to cut a 2" square, 1/4" deep, centered on X0, Y0, using a 1/4" endmill, with a 0.010" finishing pass:

M3 (Spindle On CW)
M7 (Coolant On)
#100 = 0.000 (Register for current Z depth)
G0 Z1 (Move to safe height)
G0 X-1.135 Y1.135 (Move to start position)
M98 P0001 L25 (Do roughing passes down to full depth)
(Do finish pass, taking off 0.010")
G1 X-1.125 Y1.125 F5  (Move to start position for finish pass)
G1 X1.125 F5  (Cut top edge of square)
G1 Y-1.125 F5  (Cut right edge of square)
G1 X-1.125 F5  (Cut bottom edge of square)
G1 Y1.125 F5  (Cut left edge of square)
G0 Z1 (Retract to safe height)
M9 (Coolant Off)
M5 (Spindle Off)
M30 (Program End)
(Roughing Subprogram)
O0001 (Do one pass of roughing cut)
G0 Z#100 (Rapid to depth of last cut)
#100 = #100 + 0.010 (Step down in Z)
G1 Z#100 F5 (Feed move to new depth)
G1 X1.135 F10  (Cut top edge of square)
G1 Y-1.135 F10  (Cut right edge of square)
G1 X-1.135 F10  (Cut bottom edge of square)
G1 Y1.135 F10  (Cut left edge of square)
M99 (Return)
M30

The above code *should* work, but for some reason stalls on the #100 = #100 + 0.010, but should give you the idea of how it's more typically done.  Really, though, except for very simple parts, writing G-code by hand is pretty painful.  You should look into some CAM software.  I can highly recommend SheetCAM.

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 17, 2009, 02:18:21 AM
Wiow what you showed me helped immensely. I could see some form of pattern that I could maniplate the figures enough to tinker. Too bad I didnt read your post as I was playing. I was just going to come back and ask about linking x and y moves as I see you did in your last post. Btw I just thought I should side mill cause I dont now any better. The way for the best results is to step down and then finish pass? Anyway I took your suggestion and changed it based on what I thought. It worked fair. At least directionally it was accurate.
G90
G0 X0 Y0
G0 Z0.000
G0 Z-4.85
M98 P0001 L25
M30
O0001
G91 (Set incremental mode)
G1 X0.005 F7 (Step over +0.005)
G90 (Set absolute mode)
G1 Y0 F5  (Cut from Y0 to Y-3)
G1 Y-3 (Return to Y0)
M99 (Return)
M30
It was getting closer to what I wanted at this point however what decides when the tool advances ideeper into the part? I am going to look at your last code and vary it some tonight. It should be much easier since I am the coolant and spindle! LOL Again THANK YOU. It made my night just to do what you taught me. Of course now I have to figure why there is a little bit of chatter in the corner when it meets at X&Y  though that might go away stepping down and or cutting a fluid 2 sides each pass. Also on the above Gcode if I followed the G1 Y-3 with an F3 would the tool advance in another .005? So many questions now.
Title: Re: Gcode questions pt2
Post by: BluePinnacle on October 17, 2009, 06:29:29 PM
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 17, 2009, 06:39:23 PM
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)

Now you know why I use CAM, rather than writing my G-code by hand....  :-)

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 18, 2009, 12:08:31 AM
 
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)

Blue, Thank You also ! It took me a while to figure out what brackets and where they were. I figured out something and it worked pretty well. Could be better and will be but I was very satisfied. It took over a month to see motion in my machine after building the driver board (Btw with no experience there either, just ask the Hobby CNC forum LOL)I ended up using 2 different codes that all i can see different are the feedrates but the results seemed different. I do want to cut the other direction on a finish pass if I run this code again but otherwise it was fine.

M3
G0 Z1
G0 X0 Y0
M98 P0001 L86
G1 X0 Y-1.4480 F5
G1 Z0 F5
G1 X7.4155 F5
G1 Y-4.537 F5
M30
O0001
G0 Z#100 F5
#100=[#100+.005]
G1 Z#100 F5
G1 X0 Y-1.453 F5
G1 X7.4405 F5
G1 Y-4.537 F5
M99
M30
%
&
%
M3
G0 Z1
G0 X0 Y0
M98 P0001 L86
G1 X0 Y-1.4480 F16
G1 Z0 F16
G1 X7.4155 F16
G1 Y-4.537 F16
M30
O0001
G0 Z#100 F16
#100=[#100-.005]
G1 Z#100 F16
G1 X0 Y-1.453 F16
G1 X7.4405 F16
G1 Y-4.537 F16
M99
M30
%

I was constantly seeing ways of improving it in flight.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 18, 2009, 12:11:39 AM
On another note Ray recommended stepping down in Z instead of the side milling approach I was using. Much better and faster and I am sure cutter wear is minimized to a degree. I never really thought about it but I guess pushing down on the end mill is much more rigid if the proper feedrate is used or a conservative 1 anyway.
Title: Re: Gcode questions pt2
Post by: Fastest1 on October 18, 2009, 12:26:52 AM
 I just measured the part We all just made at my house, and I had intended it to be 1.20" wide on both x & y axis' it is 1.2065! on both planes. Looks like there is room for a finish pass or 2 maybe presenting the work to the tool from the other direction.
Title: Re: Gcode questions pt2
Post by: alenz on October 19, 2009, 02:11:49 AM
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)
Thank you! I wonder how many others besides me puzzled over this one? I vaguely remember years ago dabbling in GW-BASIC and the # declared a double-precision variable, a $ was a string etc.  But arithmetic operations used parentheses not square brackets.
So just out of curiosity, where does the square bracket come from?
al
Title: Re: Gcode questions pt2
Post by: BluePinnacle on October 19, 2009, 03:49:43 PM
no idea where it comes from. It just makes Mach calcualte the value of what's in the brackets before it does anything with it. Brackets can be nested for more complex functions, of course.

G40 G21 G15

G0 X0 Y10 Z10

M3 M8

#1= 1.5
#2= 2.5

G0 Z1.0

G0 Y[#1]
M98 P1 L20

G0 Z10
M30

O1
G03 X0 Y[#1] Z[#1*[#2*0.01]] I0 J0 F500
#1= [#1+0.2]
#2= [#2*1.2]
M99
%

This is a complete nonsense program that doesn't make anything useful, but it does at least show a little of what can be done with comparatively simple parametrics. If you know the maths behind a particular shape, you can get Mach to do all the work. It can also form the basis of an internal (or at least alternate) offsetting system for ball-ended tools, radiused tools and other strange shapes. Just get it to re-calculate where it needs to be again and again. Effectively what you're doing is the same that a CAM program would do, except you miss out the messy bit in the middle where you generate 4 or 5 megs of ugly code. I'm quite evangelical about hand-coding, as you've found out it becomes very easy after a while to start fine-tuning it, and you rapidly get to understand exactly what's going on.  :)
Title: Re: Gcode questions pt2
Post by: HimyKabibble on October 19, 2009, 03:55:36 PM
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)
Thank you! I wonder how many others besides me puzzled over this one? I vaguely remember years ago dabbling in GW-BASIC and the # declared a double-precision variable, a $ was a string etc.  But arithmetic operations used parentheses not square brackets.
So just out of curiosity, where does the square bracket come from?
al


My guess is parameters and doing arithmetic operations on them, came along after the first version of G-code was created.  Parens could not be used, since they were already allocated to enclosing comments.  So, square brackets were used instead.  I'm sure G-code, like most languages, evolved over time, rather than being all planned out in advance, which always leads to such minor syntactical oddities.

Regards,
Ray L.
Title: Re: Gcode questions pt2
Post by: alenz on October 19, 2009, 04:10:23 PM
Thanks fellows for the feedback. Makes sense.
al