Hello Guest it is April 25, 2024, 05:11:43 PM

Author Topic: Variables  (Read 3744 times)

0 Members and 1 Guest are viewing this topic.

Offline lew

*
  •  74 74
    • View Profile
Variables
« on: March 01, 2007, 08:42:45 AM »
Hi:
I recently got Mach3 running. Finding that I need to tweak old programs from AhHa system.
Have a question on variable programming. In the AhHa system I could use a variable name to represent numbers.
i.e. %down=-2.312
I would then call this variable in several places in the Gcode file.
i.e. G01 Z%down
It made it easy to change the Z value without having to find it in the lines of Gcode.
I usually place the variable at the top of the program.
Now, the question. Can I use a variable to represent a decimal number in Mach3?
I know about the pound character (#) but it can only represent an integer. Not a decimal.
Thanks
Lew

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Variables
« Reply #1 on: March 02, 2007, 03:41:41 AM »
Hi Lew,

you can do it like this :-

O0001

#1=-9.95 (z depth)
#2= -10.95 (width)

G21 G40 G00 G90 G17

G00 X0 Y0 Z25.
S1000 M3
Z1.
G01 Z#1 F50.
G01 X#2
Y#2
X0
Y0
G00 Z1.
Z1.
G01 Z#2
ETC.....

M30

You can do in line calculations too.

X[[#2*2]+#1]


Graham.

Without engineers the world stops
Re: Variables
« Reply #2 on: April 29, 2014, 04:49:06 PM »
Graham, are there rules about the order of in line calculations or whether a variable can be used more than once in a line?

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Variables
« Reply #3 on: May 07, 2014, 06:42:35 AM »
Mach3 uses standard maths rules anything in [] is evaluated first as is *, only thing is the whole function must be enclosed in [] brackets.  #100=-1 is not allowed so you have to do #100=[1*-1], dont ask why it just one of those things.

Without engineers the world stops