584,863 active members*
4,959 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Reset program zero at current position using Macro B
Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2014
    Posts
    7

    Reset program zero at current position using Macro B

    Hi everyone

    I'm learning and messing about with Macro B, and when I run this program on a Fanuc control Series oi-mf I get this error PS0115 Variable no. out of range
    See the error on this line.


    When I typed that line into mdi on a Fanuc 18i control, it worked.

    Please forgive the programming text as it helps me program as I'm just started learning, and I know there are many clever guys on here.

    Are the variables different with that control and if so where could I get them as there is no manual on site

    I know the DPRNT is probably wrong but not bothered at that for the moment.

    I really appreciate any help you can provide.


    %
    :7581
    POPEN
    DPRNT [MACO7581 ]
    (18/12/2020)
    (MACRO B BORE MILLING)
    G0 G40 G80 G90
    G17 G21
    G28 G91 Z0.0
    M1
    T9
    M6
    DPRNT [MACT9 ]
    G0 G17 G90 G55 S8000 M03
    DPRNT [MACS8000.0 ]
    (=================)
    (ABSOLUTE HOLE POSITION 2 OFF)
    G0 G90 G55
    X0.0 Y0.0
    #155=0
    (=================)
    (RESET PROGRAM ZERO AT CURRENT POSITION)
    #1=#4214
    #1=#1-53
    #1=20 *#1
    #1=#1+5201 Error on this line
    # [#1]=#5021
    # [#1+1]=#5022
    N150
    (MACHINE HOLE START)
    M198 P7582 (MAIN TWO BORES)
    (MACHINE HOLE END)
    (PROBE HOLE START)
    M198 P7583
    (PROBE HOLE END)
    IF [#138GE30.01 ]GOTO2
    IF [#138LE29.98 ]GOTO3
    IF [#138LE30.01 ]GOTO4
    (IF [#138GE29.98 ]GOTO4)
    (ARGUMENT)
    N2#3000=3 (OVER SIZE HOLE)
    GOTO50
    N4#3000=3 (SIZE HOLE)
    #155=#155+1
    #12009=0
    GOTO700
    N3#3000=4 (UNDER SIZE HOLE)
    GOTO150
    N700
    #155=#155+1
    G0 G91 Y200.0
    (RESET PROGRAM ZERO AT CURRENT POSITION)
    #1=#4214
    #1=#1-53
    #1=20 *#1
    #1=#1+5201
    # [#1]=#5021
    # [#1+1]=#5022
    WHILE [#155 LE 2]DO1
    GOTO150
    END1
    DPRNT [MACM30 O7581 ]
    PCLOS
    N50
    M30
    %

  2. #2

    Re: Reset program zero at current position using Macro B

    Please don't take this as discouragement to learning Macro B. It's a great thing to learn. Wish I'd given it more time over the years. But many times I see it being used to do things that are done much simpler in basic G code ways.

    Continue on with your quest, and sorry I can't help you with your current problem, other then suggesting that at some point, study up on G52. (Local Coordinate System) Whether it completely matches what you're after is beyond me, but from your thread title, I think they're close enough for study.

  3. #3
    Join Date
    Feb 2014
    Posts
    7

    Re: Reset program zero at current position using Macro B

    Thanks for your comment, but I think you have misunderstood. I could easily program it in G code using either G52 or G10 or G91 G10 if it was for production and to get the job done.

    This is an after-hours project for me to see if I can do it and automate the machine, so you don't have to change the tool radius, the variables will take care of it. I know there a Renishaw cycle that does this, but this is just for fun and to see if I can do it.

    I've just found out the variables are different on this control #5021-#5027 is now #100051-#100057.

    So I'm getting there then il have to rechallenge myself as I want to get good at Macro B

  4. #4

    Re: Reset program zero at current position using Macro B

    I know a lot of machine programmers who shy away from the exact thing that you are doing. What they don't understand is the power and freedom it gives you. You now have the power to know if the machine is heading for a crash before it even happens. I was visiting a shop where they wouldn't allow the programmer to program in macro because they didn't understand it. Meanwhile the operators continue to crash the machines. I always enjoyed working with him because he was the smartest man in that shop. It was a pity that they never realized it. You are learning a lost art because so many people rely on CAM & CAD programs to create their programs. When things go wrong they are at a lost because they don't understand how the code works. Keep learning, you are becoming very valuable.

  5. #5
    Join Date
    Feb 2014
    Posts
    7

    Re: Reset program zero at current position using Macro B

    Hey thanks, Drdos for the encouragement
    I'm a cad/cam engineer by day, but I can see the value in being good at Macro B like you pointed out. Macros are so powerful; I have one for the operators to bore jaws on a lathe all they have to do is alter the variables at the top of the program to get sizes they want
    It keeps the noise away from me so I can do my job

  6. #6
    Join Date
    Jun 2015
    Posts
    4131

    Re: Reset program zero at current position using Macro B

    hello i just looked a bit over this thread

    set program zero at current position
    on an okuma mill/lathe, considering the axis at a random position, i can set the zero by selecting and executing a custom program

    i don't know fanuc, but, to do the same, you need to know the available system variables, and, if they can deliver ( on their own, or combined into a formula )

    cad/cam engineer
    being an engineer doesn't require to master using cad/cam, but at least seing ( ahead ) if the machine&software can deliver a custom solution + many others

    by day
    okey, and by night ?

    all they have to do is alter the variables at the top of the program to get sizes they want
    it works, but it can be speeded up ... using an application, you input data through the gui ( which is way faster then editing the program at the machine, because, many cnc interfaces 'just' work, thus they are just one step ahead from not-working ), program zero, interferences and specs are autocalculated, then the program is loaded into the cnc

    after you create&run a few macros, i guess the next step is no longer what the macro is doing, but shortening the custom programing duration / kindly
    Ladyhawke - My Delirium, https://www.youtube.com/watch?v=X_bFO1SNRZg

  7. #7

    Re: Reset program zero at current position using Macro B

    Have you tried to insert some G53 in between the lines and try to singelblock the program, i know that my machine (0MC) can have some problems, that it executes multiple calculations before it has solved the calculations before so the outcome can be totally wrong. What i understand if it reaches a G53 it needs to bee finished with what it doing before it keeps going in the program.
    I am not sure this is the problem but it can be worth a try

  8. #8
    Join Date
    Feb 2014
    Posts
    7

    Re: Reset program zero at current position using Macro B

    Hi Deadlykitten,

    I don't understand what you mean in your post, as I wanted help with variables which I have now found out.
    ???

  9. #9
    Join Date
    Apr 2006
    Posts
    111

    Reset program zero at current position using Macro B

    Quote Originally Posted by Rmc78 View Post
    Hi everyone

    I'm learning and messing about with Macro B, and when I run this program on a Fanuc control Series oi-mf I get this error PS0115 Variable no. out of range
    See the error on this line.


    When I typed that line into mdi on a Fanuc 18i control, it worked.

    Please forgive the programming text as it helps me program as I'm just started learning, and I know there are many clever guys on here.

    Are the variables different with that control and if so where could I get them as there is no manual on site

    I know the DPRNT is probably wrong but not bothered at that for the moment.

    I really appreciate any help you can provide.


    %
    :7581
    POPEN
    DPRNT [MACO7581 ]
    (18/12/2020)
    (MACRO B BORE MILLING)
    G0 G40 G80 G90
    G17 G21
    G28 G91 Z0.0
    M1
    T9
    M6
    DPRNT [MACT9 ]
    G0 G17 G90 G55 S8000 M03
    DPRNT [MACS8000.0 ]
    (=================)
    (ABSOLUTE HOLE POSITION 2 OFF)
    G0 G90 G55
    X0.0 Y0.0
    #155=0
    (=================)
    (RESET PROGRAM ZERO AT CURRENT POSITION)
    #1=#4214
    #1=#1-53
    #1=20 *#1
    #1=#1+5201 Error on this line
    # [#1]=#5021
    # [#1+1]=#5022
    N150
    (MACHINE HOLE START)
    M198 P7582 (MAIN TWO BORES)
    (MACHINE HOLE END)
    (PROBE HOLE START)
    M198 P7583
    (PROBE HOLE END)
    IF [#138GE30.01 ]GOTO2
    IF [#138LE29.98 ]GOTO3
    IF [#138LE30.01 ]GOTO4
    (IF [#138GE29.98 ]GOTO4)
    (ARGUMENT)
    N2#3000=3 (OVER SIZE HOLE)
    GOTO50
    N4#3000=3 (SIZE HOLE)
    #155=#155+1
    #12009=0
    GOTO700
    N3#3000=4 (UNDER SIZE HOLE)
    GOTO150
    N700
    #155=#155+1
    G0 G91 Y200.0
    (RESET PROGRAM ZERO AT CURRENT POSITION)
    #1=#4214
    #1=#1-53
    #1=20 *#1
    #1=#1+5201
    # [#1]=#5021
    # [#1+1]=#5022
    WHILE [#155 LE 2]DO1
    GOTO150
    END1
    DPRNT [MACM30 O7581 ]
    PCLOS
    N50
    M30
    %
    Edit #1=#4014

    You copy macro from other machine. So if you want to run on your machine you must edit macro


    Sent from my iPhone using Tapatalk

Similar Threads

  1. Replies: 1
    Last Post: 06-02-2020, 01:46 PM
  2. Reset home position on VCS 430A
    By RMW in forum Mazak, Mitsubishi, Mazatrol
    Replies: 1
    Last Post: 08-08-2018, 06:56 PM
  3. Replies: 0
    Last Post: 10-30-2016, 10:30 PM
  4. Reading Current Position in C program?
    By LJsmith in forum Dynomotion/Kflop/Kanalog
    Replies: 5
    Last Post: 01-03-2013, 08:37 AM
  5. Absolute position getting reset
    By L. Sakthivel in forum Fanuc
    Replies: 2
    Last Post: 03-06-2011, 06:54 AM

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
  •