Hello Guest it is April 16, 2024, 11:45:59 AM

Author Topic: Variables  (Read 4298 times)

0 Members and 1 Guest are viewing this topic.

Offline lew

*
  •  74 74
    • View Profile
Variables
« on: March 01, 2007, 05:12:52 PM »
I'll post this here since I didn't get a reply on the Gcode section.
Any help would be appreciated.
Thanks in advance.
LEW

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 Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Variables
« Reply #1 on: March 01, 2007, 08:44:23 PM »
Lew, does this help? It is a quote from one of the G-code Gurus. I'm not sure if this is what you were asking for. You could have your main program call up sub programs. Then change the value in the sub program. There is probably a better way, I just don't know how. Some of the code Gurus probably will though.

Quote
O0001 (MAIN PROGRAM)
G00 X0 Y0 Z0
M98 P2 L5
M30

O0002 (SUB PROGRAM)
G01 X1. A??? F10.
X0 A???
M99

Try this

Graham.

Brett
« Last Edit: March 01, 2007, 08:47:53 PM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Graham Waterworth

*
  • *
  •  2,671 2,671
  • Yorkshire Dales, England
    • View Profile
Re: Variables
« Reply #2 on: March 02, 2007, 02:59:14 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

Offline lew

*
  •  74 74
    • View Profile
Re: Variables
« Reply #3 on: March 02, 2007, 10:58:12 AM »
Hi Graham. Thanks for the reply.
I'm reading that in using the # symbol the program is expecting the value set for this parameter to be an integer.
In fact, when I set a parameter using the # symbol and give it a value that is a decimal it causes an error in the program when I load it into Mach 3. The error reads "bad number value" in line(whatever line the  value is in).
So, I'm still wondering how I can represent a decimal by using a variable.
LEW

Offline lew

*
  •  74 74
    • View Profile
Re: Variables
« Reply #4 on: March 02, 2007, 11:17:20 AM »
Ok, all bets are off.
Just made some changes to an old program and found that in fact using a decimal and representing it with the # symbol DOES work. Actually I'm using the variable to provide an offset. Goes something like this.

#1=-.03

g0 x[2.0+#1] y1.5

I had to change the [ from ( .
Using ( seems to not work and may have been causing the error.
Anyway, this"[" does work and so does using # to represent a decimal.
Thanks all for your replies and help.
I'm off to make some more chips. And, convert some more old programs.
LEW