Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: Coolant Slinger on June 02, 2012, 08:26:53 PM
-
Does Mach 3 support #variable use in programming. The simulation toolpath in Mach doesn't seem to like it.
Here is an example below.
Thanks
%
O0001(MACRO PROGRAM TEST)
G20
G00 G17 G40 G49 G80 G90
M998
(1/4 4fl. endmill)
T2 M06 G43 H2
S1000 M03
G54 X2.0Y2.0
Z.1
(INTERPOLATE 2.0 DIA. HOLES)
#100 = 2.0(CIRCLE DIA.)
#101 = 10.0(LEADIN FEED)
#102 = 20.0(FULL CIRCLE FEED)
#103 = 40.0(LEADOUT FEED)
#104 = -.25(ABSOLUTE Z DEPTH)
#105 = 10.0(Z PLUNGE FEED)
M98 P0002
X-2.0Y-2.0
M98 P0002
M5
M998
M30
O0002(SUB INTERPOLATE CIRCLE)
(STARTS AT CENTER)
G1Z-[#104]F[#105]
G91
G3X0Y[#100/2]R[#100/4]F[#101]
X0Y-[#100]R[#100/2]F[#102]
X0Y[#100]R[#100/2]
X0Y-[#100/2][#100/4]F[#103]
G90
G0Z.1
M99
%
-
%
O0001(MACRO PROGRAM TEST)
G20
G00 G17 G40 G49 G80 G90
M998
(1/4 4fl. endmill)
T2 M06 G43 H2
S1000 M03
G54 X2.0Y2.0
Z.1
(INTERPOLATE 2.0 DIA. HOLES)
#100 = 2.0(CIRCLE DIA.)
#101 = 10.0(LEADIN FEED)
#102 = 20.0(FULL CIRCLE FEED)
#103 = 40.0(LEADOUT FEED)
#104 = -.25(ABSOLUTE Z DEPTH)
#105 = 10.0(Z PLUNGE FEED)
M98 P0002
X-2.0Y-2.0
M98 P0002
M5
M998
M30
O0002(SUB INTERPOLATE CIRCLE)
(STARTS AT CENTER)
G1 Z[#104*-1] F[#105]
G91
G3 X0 Y[#100/2] R[#100/4] F[#101]
X0 Y[#100*-1] R[#100/2] F[#102]
X0 Y[#100] R[#100/2]
X0 Y[#100*-1/2] R[#100/4] F[#103]
G90
G0Z.1
M99
%
-
YaNVR got you set up(;-)
With Mach3 you cannot use the - directional sign with a #var. You have to solve inside the brackets to make the #var negative.
AND Yes I know that ain't right BUT that is just the way it works in MAch3 .
(;-) TP
-
Thanks guys I'll give it a try. I was used to fanuc style programming. But that tip shed some light on the subject.
-
Hi,
what about if statement in mach3, is it possible to use it? what will be the format of it?
sting
-
There is NO conditional in Mach3 gcode.
(;-) TP
-
A few tips-
Regarding assigning parameters to negated values-
#1 = -#2 (Doesn't work)
#1 = [-#2] (Doesn't work)
#1 = [#2/-1] (Works)
Although there are no conditionals, to get conditional processing I often use L param in subroutine calls to conditionally execute code based on a variable being zero or non-zero. Its a hack but it works, see below.
This runs the subroutine one time if #106 is non-zero, doesn't run if #106 is zero.
M98 P1351 L[ROUND[[#106 + 0.00001]/[#106 + 0.00003]]]
-
Also:
#1 = [0 - #2]
#1 = [#2 * -1]
Regards,
Ray L.
-
Redirection from Gcode
M1000 R29 (R sets the Goto #)
o29 (o word somewhere in your code you need to GOTO)
M1000 Code
Code"M98 P" & Param1()
A little strange but it does work
Just a thought, (;-)TP
-
The M1000 code should read
Code"M98 P" & Param3() 'to use the R param
-
hi,
could you put a sample program
-
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
-
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)