1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. ABB Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Main paradox -Calling Main from a Subroutine in RAPID – How Long Can It Run?

  • Mr.Robot
  • October 26, 2024 at 10:13 AM
  • Thread is Unresolved
  • Mr.Robot
    Reactions Received
    6
    Trophies
    3
    Posts
    65
    • October 26, 2024 at 10:13 AM
    • #1

    Hello everyone,

    I recently came across an interesting RAPID program where MAIN is called from a subroutine, which made me curious about how long this approach can run. In the usual structure, a robot completes a subroutine and returns to the routine that originally called it. But in this example, it seems like the subroutine rountine1 calls MAIN again, creating a sort of loop between the two routines. Here’s a simplified version of the code I saw:

    PROC Main()
      WaitTime 0.5;
      rountine1;
    ENDPROC

    PROC rountine1()
      WaitTime 0.5;
      Main;
    ENDPROC

    My main questions are:

    1. Is this a valid approach in RAPID? I wonder if continuously calling MAIN from rountine1 could lead to stack overflow or memory issues over time.
    2. Will the robot “remember” to start from MAIN after hours of running this loop? In other words, how does the robot manage memory and subroutine calls over an extended period?

    Would love to hear any insights or experiences on this topic! Thanks in advance.

  • Online
    Lemster68
    Reactions Received
    301
    Trophies
    9
    Posts
    2,489
    Blog Articles
    7
    • October 28, 2024 at 1:05 PM
    • #2

    It seems to me like this would be recursive and so it would reach a point at which it will cause a stack overflow. I would venture a guess that the programmer did not know what a RETURN instruction is for.

  • Online
    SkyeFire
    Reactions Received
    1,061
    Trophies
    12
    Posts
    9,461
    • October 28, 2024 at 9:54 PM
    • #3

    Wow, yeah, that's... bad programming. Unless there's some outside signal forcing an abort-to-main or something similar.

    It would be easy to duplicate this scenario and find out how deep the call stack goes. Just create two PROCs like that which contain nothing but the calls to each other. Add an Integer variable that gets incremented every call. Then run it, and see what the integer ends up as (obviously you'll need to ensure it's 0 before starting, and declare statically in the Module level variables).

  • hermann
    Reactions Received
    412
    Trophies
    9
    Posts
    2,628
    • October 29, 2024 at 6:51 AM
    • #4

    Be careful, older robots (like irc4..) iirc this can lead to strange errors. Sometimes you have to switch off/on the cabinet or restore backup. Haven't tried it on newer robots (ie IRC5).

  • bull_boxer454
    Reactions Received
    7
    Trophies
    2
    Posts
    14
    • October 29, 2024 at 6:06 PM
    • #5

    Worked on a program where an engineer set up recursive calling of main in an error handler of an IRC5 controller. It worked initially, but after around a dozen uses it would have an overflow error that just needed pptomain to be performed manually to clear. Solved this problem by using the ExitCycle command in the error handler instead. I wonder if the amount of commands in the program has a large effect on the number of times it can recursively call?

  • Online
    Lemster68
    Reactions Received
    301
    Trophies
    9
    Posts
    2,489
    Blog Articles
    7
    • October 29, 2024 at 7:17 PM
    • #6

    I think that the Rapid Kernel manual goes into detail about memory allocations.

  • Online
    SkyeFire
    Reactions Received
    1,061
    Trophies
    12
    Posts
    9,461
    • October 30, 2024 at 6:09 PM
    • #7
    Quote from bull_boxer454

    I wonder if the amount of commands in the program has a large effect on the number of times it can recursively call?

    I can't speak specifically to how ABB handles it. But in the general cases I'm aware of, the program size is generally irrelevant. It's the stack size that is the limiting factor, and that's generally hard-coded to a specific number of programs, regardless of program size.

    On KUKAbots, for example, the stack size these days is 15 IIRC. So the call stack can only be 15 programs deep. Doesn't matter if it's recursive A->B->A->B, or Program 1 calling Program 2 calling... down to 15. Any execution thread can only store "backtrack" information for X programs.

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • krc5
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • krc5
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • RAPID
  • main
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download