Hello Guest it is April 18, 2024, 05:43:41 AM

Author Topic: how to repeat subroutine without adding it mulitple times in gcode  (Read 7952 times)

0 Members and 1 Guest are viewing this topic.

Offline DMF

*
  •  17 17
    • View Profile
I am trying to drill a series of holes using a movement of X and Z together to get a hole that is other than 90 degrees from the XY plane. I have selected the holes and have added a subroutine (M98) after each hole's XY coordinate in the gcode. This drills the holes as needed. The XY location of the holes will change and I do not want to edit all these lines of gcode each time the XY of a group of holes changes. How do I get my subroutine to function like the canned drill cycles G81-G89 where the gcode of G81 appears only once ahead of the list of XY locations of the holes to be drilled?
Can I create a 'G81-G89' gcode that I can select from within BobCad or Mach3?
If the answers are in the forum somewhere please direct me to them.
DMF
Re: how to repeat subroutine without adding it mulitple times in gcode
« Reply #1 on: March 19, 2013, 12:30:37 PM »
Hi DMF,

code the macro to X an Y Zero positon ( X0 Y0 )

In the main code try this

example

G52 X20 Y0
M98 O1234
G52 X40 Y0
M98 O1234
....
....
when you're done then
G52X0Y0
M30

Alex

Offline DMF

*
  •  17 17
    • View Profile
Re: how to repeat subroutine without adding it mulitple times in gcode
« Reply #2 on: March 19, 2013, 12:50:16 PM »
It appears you are still entering the subroute call mulitple times into the main gcode program. I've included some of my gcode so you can see where I'm at. I've also included the subroutine.

A portion of the gcode (I started with a canned drill cycle to give me a way to select the holes).
The goal is to enter a code one time near the beginning of the gcode similar to how a G81 would appear to get the subroutine to be called for each set of XY.

N01 G20 G40 G49 G54 G80 G90 G91.1
;N02 G53 Z0.

(JOB 1  HOLE  RANDOM POINT PATTERN)
(FEATURE DRILL HOLE)

N21 T2 M6   (Tool 2, Tool Change)
N22 S1802 M03  (Spindle speed, rotate spindle)
N23 G00 G90 G54 X-31.5849 Y8.3424  A-10 (Rapid positioning, Absolute Positioning, Work Piece Coord Sys, Rotate A -10 degrees);N24 G43 H2 Z.1   (Tool Length comp,  ,Coolant On)
N24 G0 X-31.5849 Y8.3424   (Go to first hole)
N25 M98 (hole10done.tap)
N26 G0 X-28.1169 Y7.0991
N27 M98 (hole10done.tap)
N28 G0 X-27.5498 Y11.8541
N29 M98 (hole10done.tap)
N30 G0 X-22.7075 Y8.8004
N31 M98 (hole10done.tap)
N32 G0 X-20.8535 Y13.6426
N33 M98 (hole10done.tap)

The subroutine...
G0 Z.2
G01 Z.1
G91
G1 X.07052 Z-.35
G1 X-.07052 Z.35
G90
G1 Z.2 F30
 
M99

DMF
Re: how to repeat subroutine without adding it mulitple times in gcode
« Reply #3 on: March 19, 2013, 03:39:07 PM »
ah OK,

I think only the canned  cycles work like that.  ???

There is a (crazy) way to use the canned cycle for that.  ;D

Swap the Y and Z axis and then code something like this.

g69g17
g68a0b0r11.38
g54 g0 X-31.5849 Z8.3424 y0.35 f10
g18
g81y-0.35r0.35
X-28.1169 Z7.0991
X-27.5498 Z11.8541
X-22.7075 Z8.8004
X-20.8535 Z13.6426
g80
G17
g69
m30
%


The coordinates must be X and Z rather then X and Y.

One thing is probably to ask the people at bobCad for a suitable postprocessor for your needs.


Alex





Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: how to repeat subroutine without adding it mulitple times in gcode
« Reply #4 on: March 19, 2013, 05:36:45 PM »
Are you by chance trying to drill holes with a 90deg adaptor on the Z using your VERTICAL machine as a horizontal machine??

(;-) TP