Subroutines can be used to modularize programs, making them more efficient in terms of structure. The goal is not to put all instructions into one program, but to transfer specific flows, calculations, or processes into separate programs.
A number of advantages arise from the use of subroutines:
As the program length is shortened, the main program structure is clearer and easier to read.
Subroutines can be developed independently: time consumption can be shared, minimizing sources of errors.
Subroutines can be applied repeatedly.
In principle, there are two different types of subroutines:
Global subroutine
A global subroutine is an independent robot program that can be called from another robot program. Programs can be branched according to specific requirements, i.e. a program can be used as a main program in one application and as a subroutine in another.
Local Subroutines
A local subroutine is a program integrated into a main program, that is, the instructions are contained in the same SRC file. The point coordinates of the subroutine are stored in the same DAT file.
Each program starts with a DEF line and ends with an END line. If you call a subroutine from the main program, the subroutine will normally run from DEF to END. After reaching the END line, the program pointer jumps back to the program that issued the calling instruction (the main program).
In order to exit the subroutine early (that is, before the END line), you can program a RETURN instruction in the subroutine. When the program reads this line, the subroutine will be terminated early.
Steps to call a subroutine:
To be able to program a subroutine call, the "Expert" user group must have been selected. The syntax for a subroutine call is: Name ( )
1. Select Configuration > User Group from the main menu. The current user groups will be displayed.
2. If you want to switch to another user group: Press Login…. Select the user group Expert.
3. Enter the password kuka and confirm with Login.
4. Use Open to load the desired main program into the editor.
INI
PTP HOME Vel= 100% DEFAULT
PTP HOME Vel= 100% DEFAULT
5. Position the cursor in the desired row.
6. Enter the subroutine name and brackets, for example: myprog ( ).
INI
PTP HOME Vel= 100% DEFAULT
myprog()
PTP HOME Vel= 100% DEFAULT
7. Close the editor with the close icon and save the changes.
A KRL file contains up to 255 local subroutines.
The maximum nesting depth of subroutines is 20
The local subroutine is located after the main program and is distinguished by DEF and END.
Local subroutines can be called repeatedly
The point coordinates are saved in the corresponding DAT list and can be called by all files
When the local subroutine is executed, the program jumps back to the next instruction after the calling subroutine
A subroutine is a program that is linked from the main program. After processing the subroutine, the main program continues running on the line immediately following the subroutine call.
Local subroutines are contained in the same SRC file as the main program. They can be defined as global using the keyword GLOBAL.
A global subroutine is a program that is linked from another program and contains its own SRC file.
To call a subroutine, give it a name in the main program followed by parentheses.
In the following example, the subroutine my_subprog is called:
my_subprogram()
Calling Function
A function is a subroutine that returns a value to the main program. A function has a data type.
The call of a function is similar to that of a subroutine: The name of the function is specified in the main program, enclosed in parentheses. However, a function call can never exist on its own, but must always be assigned a value to a variable of the same data type.
Example called from the main program:
REALVAR = REALFUNCON()
INTVAR = 5 * INTFUNCTION() + 1
The use of subroutines can make the main program structured, and the structuring of the program makes the program clearly structured.
A subroutine cannot call itself.
Reviewing Editor: Li Qian
Previous article:Gluing equipment principle and KUKA robot control analysis + MAKRO
Next article:Vision Smart Manufacturing won the Photovoltaic Industry Light Energy Cup Most Influential "Smart Manufacturing" Enterprise Award
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Please help me find out which movie the characters in the attached picture are from. Thank you.
- Renovation of old items + transformation of discarded charging heads into bathroom lighting
- How should I draw the various layers of the Allegro pad pins?
- MSP430 variant 3-wire SPI bus implementation (for DS1302 clock chip)
- EEWORLD University Hall----Overview of Operational Amplifier Technology
- Design of multifunctional air quality detection system based on Gizwits IoT platform
- TMS320C6678 development routine manual study 1
- AD 20.0.12 x64
- LOTO Practice [Dry Goods] 4 Unexpected Interference of Infrared Sensors osc802
- A5 RTL8188EU Guide