Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: lew on March 27, 2007, 08:46:45 PM
-
Hi All:
I've now got a handle on using variables in a G code program. However, I'm still puzzled on how I can use a variable to represent a negative number.
Why does this not work?
#1=1.312 ;FIRST HALF CIRCLE RADIUS
#2=-#1 ;SECOND HALF CIRCLE RADIUS
G90
G0 X-1.5 Y0.0
M04
G0 Z-1.0
G01 X-1.312 F2
G2 X#1 Y0.0 R#1 F2
G2 X#2 Y0.0 R#1 F2
G0 Z0.0
M05
G0 X0.0 Y0.0
M30
When Mach reads #2 it gives an error something like "No digits found where real number should be".
I've tried it by giving #2 a value of -1.312 and it works fine.
Thanks in advance.
LEW
-
You have to do it like this
#1=1.312 ;FIRST HALF CIRCLE RADIUS
#2=-1.312 ;SECOND HALF CIRCLE RADIUS
-
Or if you only want to change 1 variable :
#1=1.5
#2=[#1-[#1*2]]
Graham.
-
Thank you Graham, You can tell I never use G code like that :)
-
Thank you, Brian and Graham for your replies.
Sorry for asking so many questions about variables. I come from an Ahha system which I still use and have "grown up" on. The Mach. system is somewhat different programming-wise. I need to get used to the differences.
Variables are one of the differences that I need to understand because I use them in quite a few programs. I've found that it simplifies things for future use when I desire to make changes. Actually, I've become comfortable writing code for the Ahha using variables and have a few "canned" programs for drilling and simple pocket routines where all I have to do is change a few variables at the beginning of the program and I can start cutting chips quickly.
Just trying to get to this level with Mach.
I have found one thing of interest that seems awkward with the Mach system. Perhaps you can shed some light. In Ahha a circle could be coded on one line using x,y,i,j. In Mach. if I understand it correclty, a circle has to be programmed as two semi circles. Any reason for this?
I guess you can see where the variables would come in handy.
By the way, Graham, I appreciate your example on how to use one variable and have it change the negative side as well. I'll be using that right along.
Thanks
LEW
-
Just a side note:
I have found that this will work also -
#1=1.5
#2=[0-#1]
Found that out right after posting the previous message.
Out for now.
LEW
-
LEW,
You can do IJK circles but if you do R's you must do them in no more then 180 sections
Hope that helps
Brian