How to use points in sub programs

  • Hi all,


    Having fun with my first FANUC robot, I think it's a 7.7VRC version from the backup (I had to install that virtual controller into Roboguide to be able to import the backup from the real robot).


    This said,


    INTRODUCTION (to give mode background you can skip it and go directly to the question at the bottom)

    The application I am doing is quite simple, it only must pick a piece from a pallet and then place it into a belt.


    My plan is:

    • Create a program for each part.
    • At the beginning of that program, I store the specific data in the working Registers (distance between parts on the pallet...).
    • I want to store the points needed to produce the parts into the main program.
      • I will have two pallets, each with its own User Frame.
      • I will have 2 points for each vacuum cup: one point to pick the first part in the pallet 1 and the other point to pick the first part in the pallet 2.
      • I will have 1 point for each vacuum cup to place the parts on a belt.
    • Then, my program should call a function (I know... another program) that would do all the common work, that program should use P[1], P[2]... defined in the main part program.


    Summarizing:

    • Prog1 has 6 points defined P[1],P[2]...P[6].
    • Prog1 initializes the work parameters for that model.
    • Prog1 calls ProgLogic that will have to move the robot to different positions P[1],P[2]... and offset positions from those points. (ProgLogic will do the same work always, only adapting the offsets...).
    • That should leave me with short part programs that define the work variables and the 6 important points (pick the first part with both vacuum clamps from the first pallet (P[1] and P[2]), pick the first part with both vacuum clamps from the second pallet (P[3] and P[4]) and placing the parts in the unloading belt with both vacuum cups (P[5] and P[6]).


    My problem currently is that when in ProgLogic I execute this line:


    Code
      : J P[1] 100% FINE;


    On the teachpendant I see:

    Code
    ProgLogic LINE 1 PAUSED
    
    INTP-106 (ProgLogic, 1) Continue request failed.
    
    MCTL-003 system is in error status.


    If I look at the error log I can see:

    Code
    INTP-311 (ProgLogic, 12) Uninit


    Clearly, I am doing something wrong.


    Could you share how you would do this?

    Is it something as easy as a semicolon or something like that? or is a more complicated thing and I can't separate the logic from the points? (how can I get more information about the error itself?)

    My initial idea is to avoid repeating code in each model to ease the future maintenance.


    QUESTION

    How can I use points declared in my selected program in a sub-program?

    Do I have to use PRs for that?

    I would prefer the point directly to be able to adjust the point while working (pause and adjust of course...).


    My idea is to create a program that initializes Registers I will use to work (like a recipe for each part model) and that stores the working points and then all the separation from the working points and the offsets to move through the different pallet positions should be automatically done in a separated logic program, all this to keep the future maintenance easier.

    How would you do that?


    Thank you in advance for your time and help!

  • AD
  • Points, P[x], are local variables to each program. P1 in your main program is not the same P1 in any sub program. So if you taught P1 in program A, and not in program B then it will fail as an uninitialized (untaught) position.


    PRs are global. I suggest you use local Ps that are taught in your sub program for pick and place and use a PR as an offset that can be set by your main.

  • Hello again HawkME,


    But then I will have to make a complete copy of my logics for all the programs.

    Would it work to assign the points into PR's before executing the logic and then using the PR's to make everything? Or given your experience this will become a maintenance problem?


    That way, my programs would be merely a recipe with parameters and the work itself would be done by the cell logic, which would be the same code for each program (calling a "function"/subprogram).


    ProgLogic handles (and it's always the same):

    • Going home automatically.
    • Choosing the pallet.
    • pick from the pallet
      • Retries and error messages in case of multiple consecutive fails.
      • Abort the pallet if it multiple retries in consecutive multiple positions.
    • Place at the unloading belt (in 3 distinct positions as soon as a sensor tells the belt is empty).
    • Restart

    It's not the biggest program in history, it's just I would like to avoid duplicating code.


    Of course, if someday the customer asks me to make a different thing, I could call ProgLogic2 instead of ProgLogic.

  • You can use all PRs as Hermann said which would be a good solution. Or use local points with a PR offset.


    :L P[1] x mm/s fine Offset PR[x];


    If you just have several different pick positions that aren't relative to each other, then PRs is probably the way to go.

    Usually when I have that situation I use a register as an index to indirectly address the PR. Like this:


    Say I want to use PR[5] this time.

    : R[1] = 5;

    :L PR[R[1]] x mm/s fine ;


    You can set the index register in you main program then just use the indirectly addressed PR method in your sub program. I would make sure your index value is in a safe range.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now