Hello Guest it is March 28, 2024, 05:13:42 AM

Author Topic: Variables - revisited  (Read 3711 times)

0 Members and 1 Guest are viewing this topic.

Offline lew

*
  •  74 74
    • View Profile
Variables - revisited
« 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
Re: Variables - revisited
« Reply #1 on: March 28, 2007, 06:20:39 AM »
You have to do it like this

#1=1.312   ;FIRST HALF CIRCLE RADIUS
#2=-1.312      ;SECOND HALF CIRCLE RADIUS

Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Variables - revisited
« Reply #2 on: March 28, 2007, 09:49:36 AM »
Or if you only want to change 1 variable :

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

Graham.
Without engineers the world stops
Re: Variables - revisited
« Reply #3 on: March 29, 2007, 08:53:00 AM »
Thank you Graham, You can tell I never use G code like that :)
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline lew

*
  •  74 74
    • View Profile
Re: Variables - revisited
« Reply #4 on: March 30, 2007, 07:01:58 PM »
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

Offline lew

*
  •  74 74
    • View Profile
Re: Variables - revisited
« Reply #5 on: March 30, 2007, 07:05:41 PM »
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
Re: Variables - revisited
« Reply #6 on: March 30, 2007, 07:40:45 PM »
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
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com