586,133 active members*
3,928 visitors online*
Register for free
Login
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Posts
    23

    Equation format in g-code

    Here are a few lines from a macro I'm trying to write, but I'm not sure of the correct formatting/syntax for doing equations in g-code. Can someone help me out? I'm trying to simulate it on "Torcomp CNCez Pro" for a Hass controller.

    N100 #4 = [COS[#1]]* [#18 + [#7 / 2]] + [#24] (FIND X POS)
    N110 #6 = [SIN[#1]] * [#18 + [#7 / 2]] + [#26 - [#7/2]] (FIND Z POS)
    ...
    N150 G02 I-[#4 - #24] F#9
    ...
    N170 IF [#6 NE #26] GOTO100
    N180 G00 Z[#26 + #18 + #11]

    Thanks for the help.
    -Chris

  2. #2
    Join Date
    Mar 2005
    Posts
    1498
    070706-1145 EST USA

    Jester966:

    Define your variables and the intent of the program.

    I do not see anything in your N100 loop to modify #6 or #26. Therefore, you are in a continuous loop (infinite) or you pass thru the loop once.

    .

  3. #3
    Join Date
    Dec 2004
    Posts
    524

    Never Compare EQ When Using Floating Point

    I assume that the areas indicated by "..." include modification of #6 or #26.

    In general, it is unwise to compare for EQ because of roundoff error. Instead, compare LE, LT, GE, or GT, depending on what you need.

    It appears that #7 represents the diameter of a cutter, and #18 represents the radius of a circle. Then #1 represents an angle.

    I see no problems with your formatting.

    Ken
    Kenneth Lerman
    55 Main Street
    Newtown, CT 06470

  4. #4
    Join Date
    Jul 2006
    Posts
    23
    lerman, you're right on all of your assumptions. Thanks for the EQ tip, I'll change it.

    I used the Hass programming manual to try to get the format correct, but had no luck. Could the problem be with the simulator's interpretation, rather than the code? I guess I'll try to simulate it on the control itself and see if it works.

    Thanks for the help.

    -Chris

  5. #5
    Join Date
    Mar 2006
    Posts
    61

    Hass Variables

    I always use variables #100 onward as good practice some of the lower variables can change depending what other stuff you are doing ie if you are doing G65 calls in the same programe which use #1 #2 etc


    Stu.

  6. #6
    Join Date
    Mar 2005
    Posts
    1498
    070709-0810 EST USA

    Stu M3:

    I believe the use of the word "MACRO" was used in place of a more correct term "subroutine".

    Thus, I expect that Jester966 wants to pass parameters into a subroutine from a G65 call. He has shown segments of that subroutine. So #1 maps from A in the subroutine calling line, #18 from R, #7 from D, #24 from X, and #26 from Z. #4 and #6 are probably local to the subroutine and a don't care on return from the subroutine.

    However, if another G65 subroutine (second subroutine) is called from this first subroutine and any of the local variables are used in the second subroutine, then on return to the first subroutine the local variables as viewed in the first subroutine will remain unchanged from their values before the call to the second subroutine. I suspect this is because the local variables are actually stored on a stack.

    See my post #2 at http://www.cnczone.com/forums/showthread.php?t=32630 for some information on local variables in a HAAS machine.

    .

Similar Threads

  1. having problems with ngc format
    By servoencoder in forum LinuxCNC (formerly EMC2)
    Replies: 11
    Last Post: 04-22-2009, 11:39 PM
  2. 4Axis Format G-code Example
    By louis14 in forum G-Code Programing
    Replies: 0
    Last Post: 07-27-2006, 05:15 AM
  3. dwg to IGES or pro-e format?
    By XXF in forum Autodesk
    Replies: 8
    Last Post: 04-24-2006, 09:08 AM
  4. Format 1
    By MegaMoog in forum Fadal
    Replies: 6
    Last Post: 04-07-2006, 12:08 AM
  5. Using CRC in Format 2
    By Mese in forum Fadal
    Replies: 10
    Last Post: 03-29-2006, 02:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •