Hello Guest it is October 22, 2019, 01:16:04 PM

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

0 Members and 1 Guest are viewing this topic.

#### Coolant Slinger

• 12
##### #variable use in Mach3
« 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.)
#102 = 20.0(FULL CIRCLE 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
%

#### Ya-Nvr-No

• 988
##### Re: #variable use in Mach3
« Reply #1 on: June 02, 2012, 09:25:45 PM »
%
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.)
#102 = 20.0(FULL CIRCLE 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
%

#### BR549

• 6,902
##### Re: #variable use in Mach3
« Reply #2 on: June 02, 2012, 09:44:34 PM »
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

#### Coolant Slinger

• 12
##### Re: #variable use in Mach3
« Reply #3 on: June 03, 2012, 09:05:10 AM »
Thanks guys I'll give it a try. I was used to fanuc style programming. But that tip shed some light on the subject.

#### sting

• 2
##### Re: #variable use in Mach3
« Reply #4 on: March 29, 2013, 01:16:05 PM »
Hi,

what about if statement in mach3, is it possible to use it? what will be the format of it?
sting

#### BR549

• 6,902
##### Re: #variable use in Mach3
« Reply #5 on: March 29, 2013, 01:20:00 PM »
There is NO conditional in Mach3 gcode.

(;-) TP

#### titchener

• 90
##### Re: #variable use in Mach3
« Reply #6 on: March 30, 2013, 08:34:54 PM »
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]]]

#### HimyKabibble

• 1,687
##### Re: #variable use in Mach3
« Reply #7 on: March 30, 2013, 08:59:07 PM »
Also:

#1 = [0 - #2]
#1 = [#2 * -1]

Regards,
Ray L.
Regards,
Ray L.

#### BR549

• 6,902
##### Re: #variable use in Mach3
« Reply #8 on: March 30, 2013, 09:06:29 PM »
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
« Last Edit: March 30, 2013, 09:22:20 PM by BR549 »

#### BR549

• 6,902
##### Re: #variable use in Mach3
« Reply #9 on: March 30, 2013, 09:24:21 PM »