Hello Guest it is October 16, 2019, 11:47:15 PM

Author Topic: #variable use in Mach3  (Read 18658 times)

0 Members and 1 Guest are viewing this topic.

Re: #variable use in Mach3
« Reply #10 on: March 31, 2013, 11:19:32 AM »
hi,
could you put a sample program

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: #variable use in Mach3
« Reply #11 on: March 31, 2013, 12:18:27 PM »
Like I said above MACH3 does NOT have conditional Gcode. Some people have just found ways around that problem in their OWN way.

So there really is NO "documented" way to do it.

(;-) TP
Re: #variable use in Mach3
« Reply #12 on: March 31, 2013, 05:24:49 PM »
Below is G code program that makes heavy use of parameters.

It doesn't use any "conditionals" but see my previous example in this thread in how to use the subroutine loop argument to conditionally execute code.

(Filename: SpotAndDrillAndTap.tap)
(Spots and then Drills a pecked hole at the current X, Y location and then taps to the specified depth)
(Assumes 120 degree spot drill, Z must be set at zero on workpiece top)
(If desired drill depth can be compensated for tip length)

G20 (Units: Inches)
G40 G90 G94

(Set Editable Parameters)
#1=0.2      (Set Spot and Drill Diameter)
#2=0.3      (Set Drill Depth)
#20=0.34   (Set Tap Depth)
#22=40.0   (Set Thread Pitch in Turns Per Inch)
#3=1.0      (Set to 1.0 to add tip length comp, 0.0 not to)
#4=0.1      (Set Peck Increment)
#5=0.1      (Set Retract Height)
#6=1400      (Set Drill RPM)
#21=160      (Set Tap RPM)
#7=1.0       (Set Drill Feed Rate)
#8=0.125   (Set Rapid Height)

(Internal Parameters)
#10=[[#1/-1] * 0.3]        (Spot Drilling Depth)
#11=[[#2/-1] - #3 * #1 * 0.3]   (Final Drilling Depth)
#103=0.91         (Underfeed, 0.91 -> 9 %)
#104=[#103 * 1.0/#22]      (feed rate adjusted for under feed)

S#6 F#7      (Set RPM, Feed Rate)

T11 M06 G43 H11 (118 degree Spot Drill D = Diam x .300)

(Make any required X,Y move)
(G0 Z#8)
(G0 X0 Y0)

G0 Z0.02   (Rapid to just above workpiece)
M3 M8       (Spindle On, Coolant On)
G1 Z#10      (Spot Drill)
G0 Z#8      (Raise to Rapid Height)
M5 M9       (Spindle, Coolant Off)

T111 M06 G43 H111 (Final Drill in Jacobs Chuck)

M3 M8          (Spindle On, Coolant On)
G83 Z#11 Q#4 R#5   (Peck Drill)
G0 Z#8         (Raise to Rapid Height)
M5 M9          (Spindle, Coolant off)

T200 M06 G43 H200 (Tap in Floating Holder)

M98 P1025 L1 (Call Tap subroutine)

M30          (Program End)

O1025 (Subroutine to Tap)
G95 F#104      (Set to ipr mode and set feed rate)
M3 S#21 M8      (Start Spindle and coolant)
G1 Z[#103 * #20/-1]   (Tap down to compensated depth)
M5         (Stop Spindle)
M4         (Start Spindle in Reverse)
G1 Z#8         (Raise spindle at feed rate to rapid height)
M5 M9         (Turn off spindle and coolant)
G94         (Go back to ipm mode)
M99          (Subroutine Return)