587,997 active members*
1,738 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 22
  1. #1
    Join Date
    May 2012
    Posts
    0

    math functions in G-code program

    Can anyone help explain why this program doesn't work?
    It is a simple grid pattern program G79 for fanuc 0p.
    the problem seems to be number #103 and #104. when I substitute other numbers, say 20. for I and 2 for K it works. I think part of the problem is #104 has a decimal which is not allowed for hit count. I was hoping the absolute function might drop the decimal point and the FIX would round down to a real number.
    Any help would be greatly appreciated!

    O0560(HEAD JAMB)
    (T3 = .265X.500 OBROUND)
    #101=7(WALL THICKNESS)
    #102=42(OPENING WIDTH)
    #103=[#102+2]
    #104=[ABS[FIX[#101/2.75]]]
    G20
    G90
    G65P9700A38.5B10.0
    M75X65.Y51.
    G31T3X1.25Y2.375
    G79I#103P1J2.75K#104
    X1.25Y[[#101+7.0625]-4.688]
    X[#102+2.25]
    G28
    G92X65.Y51.
    M99

    this is for a Strippit turret with fanuc op controls

  2. #2
    Join Date
    Jun 2011
    Posts
    68
    Try seperating it out;

    #104=FIX[#101/2.75]
    #104=ROUND[#104]
    #104=ABS[#104]

  3. #3
    Join Date
    May 2012
    Posts
    0
    Thanks.
    So this program does work on other machines. The program is not the problem, my machine is not storing my macro variable values. after I run my program and I check they are stored as null (zero). So now I think I need to figure out why my machine is not storing them? is it a parameter....

  4. #4
    Join Date
    May 2004
    Posts
    4519
    Quote Originally Posted by CANDC View Post
    Thanks.
    So this program does work on other machines. The program is not the problem, my machine is not storing my macro variable values. after I run my program and I check they are stored as null (zero). So now I think I need to figure out why my machine is not storing them? is it a parameter....
    Does your machine even have macro capabilities enabled? Yeah, best start checking parameters.

  5. #5
    Join Date
    May 2012
    Posts
    0
    Quote Originally Posted by txcncman View Post
    Does your machine even have macro capabilities enabled? Yeah, best start checking parameters.
    If I understand your question correctly, yes the Fanuc op controller is capable of running macro programs. All the 9000 programs are essentially macros. as far as my parameter settings being correct as to allow this I'm not sure. I have to crack open the manual, unless someone is familiar with these controllers.
    For some reason not to many people seem to program turrets like this.

  6. #6
    Join Date
    Aug 2011
    Posts
    2517
    do you really need to use 2.75?
    If you use another number that divides into 7 more evenly you can do this kind of calc and it'll be a 4 digit number without decimal....

    7/4=1.75*1000=1750
    in a calculation the number is really 1750.0 but without a decimal the Fanuc control interprets it as 1750 which should work with words where a decimal point is not allowed like your K

    alternatively 7/2.8=2.5*1000=2500

    however if storing numbers into macro variables is forcing the decimal point regardless of the calculation you are out of luck and nothing will work.

    I have not tried it on a Fanuc control but I wonder whether direct maths would work......

    G79 etc etc K[7/2.8*1000]

    this type of direct calc is accepted on Okuma User Task 2.... e.g. G00 X[10.0 + 0.001]
    yes I know its a different beast and yes I know Okuma is not adhering to other more widespread 'standard' control systems

  7. #7
    Join Date
    May 2004
    Posts
    4519
    Quote Originally Posted by CANDC View Post
    If I understand your question correctly, yes the Fanuc op controller is capable of running macro programs. All the 9000 programs are essentially macros. as far as my parameter settings being correct as to allow this I'm not sure. I have to crack open the manual, unless someone is familiar with these controllers.
    For some reason not to many people seem to program turrets like this.
    Just my opinion, but many people incorrectly refer to sub-programs as macros. Macro B (or A or C) is a specific programming language. While a sub-program, such as a O9*** can contain the Macro B (or A or C) language, it would not have to. Main programs can contain one of the Macro language statements. That does not make it a sub-program.

  8. #8
    Join Date
    May 2012
    Posts
    0
    Quote Originally Posted by fordav11 View Post
    do you really need to use 2.75?
    If you use another number that divides into 7 more evenly you can do this kind of calc and it'll be a 4 digit number without decimal....

    7/4=1.75*1000=1750
    in a calculation the number is really 1750.0 but without a decimal the Fanuc control interprets it as 1750 which should work with words where a decimal point is not allowed like your K

    alternatively 7/2.8=2.5*1000=2500

    however if storing numbers into macro variables is forcing the decimal point regardless of the calculation you are out of luck and nothing will work.

    I have not tried it on a Fanuc control but I wonder whether direct maths would work......

    G79 etc etc K[7/2.8*1000]

    this type of direct calc is accepted on Okuma User Task 2.... e.g. G00 X[10.0 + 0.001]
    yes I know its a different beast and yes I know Okuma is not adhering to other more widespread 'standard' control systems
    Thanks, but yes I have to use 2.75 to get the pattern I need.

  9. #9
    Join Date
    May 2012
    Posts
    0
    Quote Originally Posted by txcncman View Post
    Just my opinion, but many people incorrectly refer to sub-programs as macros. Macro B (or A or C) is a specific programming language. While a sub-program, such as a O9*** can contain the Macro B (or A or C) language, it would not have to. Main programs can contain one of the Macro language statements. That does not make it a sub-program.
    Yes, I probably mixed up my terminology. My machine uses Macro B language. But my problem is not the program as I originally thought it was. It seems to be the fact that my machine is not storing any values for the variables I am using. I read that #100 to #149 are the common variables that I should use. The P9700 program that I call in my program is to move the auto clamps into their locations. I noticed that that program uses #104 as well, I thought this might be changing my value. But there is still nothing stored for #101 or #102 or #103. I have not located any parameter that effects this yet.

  10. #10
    Join Date
    Aug 2011
    Posts
    2517
    did you try using #500 onwards? you can use any variable that is unused even global variables.
    but what you are doing is incredibly simple. macro is usually used to simply programming of a complex task.
    what you are doing is overkill. if there's no easily found solution just program it normally and move on.

  11. #11
    Join Date
    Aug 2011
    Posts
    2517
    btw, just tested today, a direct calc like 'G00 X[10.0 + 0.001]' works on Fanuc controls

  12. #12
    Join Date
    May 2012
    Posts
    0
    Thanks for the ideas everyone, It seems to be the G31 and T3 commands. Either one of these commands clears out the stored variables.
    G31 and T3 before the variables works, but if located after the variables it does not.
    The program below works perfectly.

    O0560(HEAD JAMB)
    (T3 = .265X.500 OBROUND)
    G20
    G90
    G31T3
    G65P9700A38.5B10.0
    M75X65.Y51.
    #101=7(WALL THICKNESS)
    #102=42(OPENING WIDTH)
    #103=[#102+2]
    #104=[FIX[#101/2.75]]
    X1.25Y2.375
    G79I#103P1J2.75K#104
    X1.25Y[[#101+7.0625]-4.688]
    X[#102+2.25]
    G28
    G92X65.Y51.
    M99

  13. #13
    Join Date
    Jan 2005
    Posts
    304
    The 100 series variables are usually cleared at end of program and by reset. Do you see them DURING the running of the program? Use "Single block" and check while program is active. You should use the 500 series to stay after the program is completed, or change the parameters.

  14. #14
    Join Date
    Jan 2007
    Posts
    599

    G31

    Hi all,

    sorry to bring this post back to life, but since you all know something about strippits I'd thought I'd ask!

    Working on a 1000xp/20 retrofit and would really like to know what G31 is actually good for...

  15. #15
    Join Date
    Feb 2006
    Posts
    1792
    G31 is the skip signal on Fanuc which is used for probing.

  16. #16
    Join Date
    Dec 2003
    Posts
    24220
    Quote Originally Posted by sinha_nsit View Post
    G31 is the skip signal on Fanuc which is used for probing.
    On some Fanuc P(unch) systems, G33 is skip.
    Not sure what G31 is on a punch?
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  17. #17
    Join Date
    Jan 2007
    Posts
    599
    Quote Originally Posted by sinha_nsit View Post
    G31 is the skip signal on Fanuc which is used for probing.
    A Strippit cnc Punch that does probing, i'd like to see it.... nope sorry thats is definitely not it, the strippit book that i have with the machine says it calls p9010 for simultaneous x,y and t movement...

  18. #18
    Join Date
    Jan 2007
    Posts
    599
    Quote Originally Posted by Al_The_Man View Post
    On some Fanuc P(unch) systems, G33 is skip.
    Not sure what G31 is on a punch?
    Al.
    Hi Al,

    I think i've seen you post some things here and there about camsoft, i might need some advice in the future. I'm using camsoft to replace a mac control on strippit 1000xp20

  19. #19
    Join Date
    Dec 2003
    Posts
    24220
    Quote Originally Posted by xjdubber View Post
    A Strippit cnc Punch that does probing, i'd like to see it.... nope sorry thats is definitely not it, the strippit book that i have with the machine says it calls p9010 for simultaneous x,y and t movement...
    I have no idea why you would need a probe on a punch either, but some of the Fanuc P punch operator manuals show G33 as skip??
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  20. #20
    Join Date
    Jan 2007
    Posts
    599
    Quote Originally Posted by Al_The_Man View Post
    I have no idea why you would need a probe on a punch either, but some of the Fanuc P punch operator manuals show G33 as skip??
    Al.
    I`m probably making a mistake thinking that strippit would have had the gcodes the same for fanuc operated and macintosh operated machines..... could be that on fanuc operated machines g31 is used as m35 is on macintosh machines. which is a work clamp search routine very similiar to probing.

Page 1 of 2 12

Similar Threads

  1. Mazatrol Program into a G Code Program
    By fuzzman in forum Mazak, Mitsubishi, Mazatrol
    Replies: 15
    Last Post: 09-25-2012, 04:27 PM
  2. NA code in Okuma program
    By emsee in forum Okuma
    Replies: 2
    Last Post: 08-16-2011, 01:57 AM
  3. fanuc program code vs. Haas code
    By sixty8frbrd in forum Fanuc
    Replies: 6
    Last Post: 03-11-2011, 04:05 AM
  4. G-Code, what is sub program... ++
    By Vegabond in forum G-Code Programing
    Replies: 4
    Last Post: 01-22-2011, 07:02 AM
  5. How to add G41/G42 and D code to program??
    By tomekeuro85 in forum GibbsCAM
    Replies: 7
    Last Post: 04-18-2008, 05:04 PM

Tags for this Thread

Posting Permissions

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