Hello Guest it is March 28, 2024, 03:51:36 PM

Author Topic: using variables  (Read 3601 times)

0 Members and 1 Guest are viewing this topic.

using variables
« on: May 19, 2012, 07:37:39 AM »
Hello all -- the  copy and paste below is  from an earlier topic on using variables

My question is whether use of vars is restricted to these numbers or can alpha characters be used?

regards

fred



You do it like this

To set a variable :-

#1=3 (use numbers #1 to #100  or #500 to #600)
#2=50
#3=[#1+#2]
#4=[0-10.5] (to set minus numbers)

To use that variable :-

G01 X[#4]
G02 X[#2] Y[#3] K[#1] F10. (etc.)

Graham
think of the trees-- use both sides of the computer paper
Re: using variables
« Reply #1 on: July 12, 2013, 06:48:53 PM »
This is an old thread, however it addresses what I am interested in.  Can these variables also be used to set the inputs for a canned cycle?  For instance can you have Q=#1 and use that to change the value of Q while a canned cycle is running?  I used to do this on a Fadal to change the depth of holes between hole moves, so some holes were the same size but shallower.

Gary H. Lucas
Re: using variables
« Reply #2 on: July 12, 2013, 08:57:43 PM »
In theory, you should be able to use a variable anywhere you'd normally use a literal number.  Given how idiosynchratic the Mach3 parser is at times, I have no idea if that is really true for Mach3, but I'd guess it is.

Regards,
Ray L.
Regards,
Ray L.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: using variables
« Reply #3 on: July 12, 2013, 09:35:32 PM »
Yes you can substitute a variable for the Q parameter.  I have not found anything weird in the #var  , the exception being it does NOT recognise a stated negative value such as -#100  , You have to convert the value to a _value by -1* or 0- before MAch3 will recognise it as such.

BUT the Q does not control hole depth it controls the peck distance.

In your case you would not see any advantage to using the #var you have to change the location values for each hole and when you do just specify a new Q value.

G83 X0 Y0 Z-1 Q.010 R.050 F10
X1 Q.020
X2 Q.030
etc,etc

(;-) TP
Re: using variables
« Reply #4 on: July 13, 2013, 09:02:00 AM »
Yes you can substitute a variable for the Q parameter.  I have not found anything weird in the #var  , the exception being it does NOT recognise a stated negative value such as -#100  , You have to convert the value to a _value by -1* or 0- before MAch3 will recognise it as such.

BUT the Q does not control hole depth it controls the peck distance.

In your case you would not see any advantage to using the #var you have to change the location values for each hole and when you do just specify a new Q value.

G83 X0 Y0 Z-1 Q.010 R.050 F10
X1 Q.020
X2 Q.030
etc,etc

(;-) TP

TP,
I was just using Q as an example, couldn't remember what it controlled. I used to program for a couple of Fadals and I had a variable I called Z Safe.  At the beginning of every program I'd set it to like 6" which would let the operator run the program in the air above the part, and clear all the clamps and such.  Once he had everything correct he just changed it to a safe but fast number.

I also used variables to pass data into sub routines. In your example the locations only get used one time. I would put all the hole locations in a sub routine.  Then I'd spot drill using a 90 degree point drill to a depth equal to the radius of the finished hole. Since the tip is slightly flat you get a nice chamfer. Then I'd drill it, calling the same sub routine with variables set outside the sub. Then I might drill it again, using the same sub, changing the variables again.

Which brings up another question. You mention using Q=0-1 to get a negative value. Does that imply that Mach also does some math functions in addition to add, subtract, and multiply? I once wrote a short 50 line program that cut a 15 degree tapered pocket 12" x 18" x 7" deep with corners rounded out to clear a square cornered insert using variables and some trig.  We tested it with a tiny ball mill on a small block of aluminum, then changed the variables and ran the big block. 200 passes to rough with a shell mill, 700 passes to finish with a ball mill!

I'm very rusty at this point and trying to get back up to speed with my home built machine.

Gary H. Lucas

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: using variables
« Reply #5 on: July 13, 2013, 10:12:12 AM »
HIYA Gary, Yes the #vars have full math functions, see the Mach3 manual for details.

To create a -#var  

If #100 equates to 10 BUT you need to move in a neg direction

X -#100

You Would

X= [-1*#100] or
X=[0-#100]

You can always use a neg number IF the "value" is already neg

#100 =-10      Works fine

SUBS, now that is not one of MAch3 strong points. IF kept simple and not deeply nested they work OK.

With your example with drilling holes the use of a #var for depth has not saved you any steps. You still have to declare the variable so you might a s well just use the real number. Actually it is LESS steps to just declare the value because you do not have to declare the #var value then apply it.

BUT as I always say IF it works for you then use it (;-).

(;-) TP
« Last Edit: July 13, 2013, 10:22:38 AM by BR549 »