View Single Post
  #23   Report Post  
Posted to rec.crafts.metalworking
Ignoramus1469 Ignoramus1469 is offline
external usenet poster
 
Posts: 12
Default IGGY - Pocket Drilling

On 2010-09-11, Jon Elson wrote:
Ignoramus4779 wrote:


Did He give any explanation? I am writing them right and left and am
very happy.

My program was a bit different, instead of passing parameters to the
subroutine, I was
offsetting the work coordinate system each time before calling the
subroutine.
So, I would do :
G01 X1.2345 Y3.456
O100 call
G01 X3.456 Y4.567
O100 call
.....
and the subroutine had :

O100 sub
N01 G55
N02 G92 X0 Y0
N03 G01 F45.0 X0.0725 Y0.0725
N04 Z0.01
.....

The first problem I had was an unspecified Z offset was changing without
my specifying it. I was
assuming that if I didn't specify a Z offset in the G92 that the Z
offset would not be changed.

The fix for that was to use G10 L20, and to specify
all axes in the command. This all got discussed on the EMC developer's
list on 5/14/2010.
Up to this point, I think the entire problem was my fault in not
understanding how G92 works.

But, then, I ran into the "run from line" problem, where I could not
restart the program in the
middle. It wasn't until 5/17 that John Kasunich made the immortal "it
is evil. don't do it"
statement, but he actually said that Run from line was evil, not
subroutines! Sorry for my
mis-remembering exactly what he said.

Anyway, I don't think there was ever a concrete explanation of what was
wrong, or if there
was any fix. The program is still up on pastebin, at
http://pastebin.com/embed_js.php?i=QyjpZUD9
If you want, you can try it out. It defines a subroutine, then moves to
the first slot corner
and calls the subroutine, moves, calls it again, etc. The subroutine
shifts the G55 coordinate
system with G10 L20 P2, then changes to the G55 system and machines a
slot, then goes
back to G54 and returns. At the end of 24 slots, it does some different
cutouts with linear program steps. If you interrupt the run after the
first subroutine, and then try to run from
line, it will skip the 24 subroutine slots and perform the last cutouts
perfectly. You can try this in air
and watch the Axis preview to follow what it is doing. It didn't do
anything wild, it just skipped over
a huge part of the job.


Jon


Jon, the way I write subroutines involves several things that help
me.

1. I write named subroutines and save them to files corresponding to
their names.
2. I use named variables in the subroutine.
3. I use offsets and named arguments

Ohelloworld sub
#x0 = #1 (X offset)
#y0 = #2 (Y offset)
#safez = #3 (Safe Z)
#l = #4 (length of the cross)
#depth = #5 (depth of cutting)

... perform operation ...
Ohelloworld endsub
M2 (M2 required at end of subroutine files)


THen to call it I just say in my main code or other subs

Ohelloworld call [1] [2] [0.03] [0.4] [-0.05]

It works really well for me and the resulting code is VERY EASY TO
READ. It is also easy to change.

I also have subroutines where I pass other subroutines into them. I
use one to perform a multipass deep cut based on a shape performed by
the parameter subroutine. This is how I made a complex shape cutoff on
my spindle adapter.

It was as easy as pie. Here's a sub that performs a deep cut defined
by a subroutine number that I pass in as a number:

Odeepanycut sub
#behavior = #1 (Subroutine to do whatever is needed)
#safez = #2 (Safe Z)
#depth = #3 (Depth to go, usually negative)
#zstep = #4 (Z Step, positive)
#frate = #5 (Feedrate)

#z = #safez

Owhile while[1]
#old_z = #z

Oif if [ #z - #zstep LE #depth ]
#z = #depth
#isfinal = 1
Oif else
#z = [#z - #zstep]
#isfinal = 0
Oif endif

O[#behavior] call [#safez] [#old_z] [#z] [#frate] [#isfinal] [#6] [#7] [#8] [#9] [#10] [#11] [#12] [#13] [#14]

Oif if [ #z LE #depth ]
Owhile break
Oif endif
Owhile endwhile
Odeepanycut endsub


and then to cutt of that shape I would use a sub like this


O101 sub
#safez = #1
#old_z = #2
#z = #3
#frate = #4
#isfinal = #5

#direction = #6
#xc = #7
#width = #8
#milld = #9
#lip = #10

F#frate


#radius = [[#width-#lip]/2]

#yc = [#width/2]

G0 Z#safez
G4 P0
G0 X#xc Y[#width+#milld/2]

G40

G0 Z#z

Oif if [ #direction LT 0 ]
G42.1 D#milld
#circle_code = 3
Oif else
G41.1 D#milld
#circle_code = 2
Oif endif

G#circle_code X[#xc + #direction*#radius ] Y[#width - #radius] R[#radius]
G1 X[#xc + #direction*#radius + #direction*#lip]
G1 Y[#radius]
G1 X[#xc + #direction* #radius ]
G#circle_code X#xc Y0 R[#radius]

G0 Z#safez
G4 P0

G40


O101 endsub


Odeepanycut call [101] [#safez] [-#thickness] [#milld/3] [#frate] [-1] [#router_hole_xc] [#width] [#milld] [#lip]
Odeepanycut call [101] [#safez] [-#thickness] [#milld/3] [#frate] [+1] [#quill_hole_xc] [#width] [#milld] [#lip]

This cuts left and right semicircular shapes with lips etc, on both
sides. -1 and +1 define their orientation.

i