04_IRC5_ProgramStructure_RW6_M1015_en

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Program Structure

Goal

After this chapter you should be able to:


 Differentiate between program and system modules
 Use a suitable module to store different data and routines in order to implement a good program
structure
 Describe the difference between constant, persistent and variable data

July 1, 2024 Slide 2



Program Structure
Overview

– Modules – Textfiles for structuring Data and Routines


– Program – All loaded Program modules
– Data – Variables and constants
Task
– Routines – sets of instructions
– Instructions – Command for the controller, e.g., MoveJ…
System
Module
System
Module
Program
Program Program
Module Module
Data Data

Data Data
Routine Routine
• Data • Instructions
• instructions Routine Routine
• Data • Instructions
• instructions
Routine
• Data Routine
• Instructions
• Data
• Instructions

July 1, 2024 Slide 3



Program Structure
Modules

Overview Structuring Example 1


Modules are text files that may contain data and/or routines(sets of
instructions) MoveRoutines Tools
Modules are used to structure your program
Functions Workobjects
Different companies use different structuring methods
No limit how many modules can be used Data

Structuring Example 2

Article1_Specific MainProgram

Article2_Specific Communication

SystemData

July 1, 2024 Slide 4



Program Structure
Modules

System Module Program Module


Persists in memory when changing programs Unloads together with program
Used for routines and data that is not program specific, such as; Used for program specific routines and data, for example;
– Tools – Process routines
– Workobjects

Modules are textfiles to structure your code

July 1, 2024 Slide 5



Program Structure
Program

– Program=Loaded program modules


– Saving program saves all Program modules
– Unloading a program unloads all program modules
– Loading a program loads modules in .pgf-file

Saving/Loading a program does not affect system modules!

July 1, 2024 Slide 6



Program Structure
Data

Overview
– Data is information stored in memory, accessed by its name
– The data declaration declares the name of the data and the initial
value Data declaration

– Any reference to a data will refer to the data stored in memory


– Data can be predefined or user defined
– Data can be variable or constant
Data reference

July 1, 2024 Slide 7



Program Structure
Data

Predefined data User defined data


Some data are predefined in RAPID, some examples: The user can define data, some examples:
– Speeddata (V100, V500, V2000, etc.) – Robtargets (Positions for the robot)
– Tooldata (tool0) – Numeric data (Keep track of number of produced parts, etc.)
– Zonedata (fine, z1, z50) – Speeddata

If predefined data don’t cover your needs, you can create your own dataMN2

July 1, 2024 Slide 8


Slide 8

MN2 Might sound rude, thats not intended


Markus Naslund, 12/4/2017

Program Structure
Data

Constant Persistent Variable


Constantly declared data Persistent variable Can be changed by program
Cannot be changed by the program Can be changed by program Goes back to initial value on program restart
Does not loose its value on program restart

CONST robtarget pPosition:=[[x, y, z], [q1, q2, q3, q4], [cf1, cf4, cf6, cfx], [eax_a, eax_b, eax_c, eax_d, eax_e, eax_f]];

July 1, 2024 Slide 9



Program Structure
Instructions

Information Examples
Instructions are commands you can give the controller:
– MoveJ .….
– Incr …..
– Set …..
– + thousands more

July 1, 2024 Slide 10



Program Structure
Routines

Example
A set of instructions that can be called from the program typing the
name of the routine
Can be either a Procedure or a Function
Can be called from anywhere* in the task by typing its name followed
by a semicolon e.g., RoutineExample;

July 1, 2024 Slide 11



Program Structure
Exercises

Create a module Create a routine Create a user data


– Create a new program – Add a routine – Add a numeric data variable to one of your
– Add a new program module – Add an instrunction in your routine program modules

– Add a system module – Add a procedure call to your routine in the – Increase the value of the data in your
main-routine routine (Add Incr instruction)

– Test run the program from main – Check the new value
(PP to main) (Debug -> View value)

July 1, 2024 Slide 12



Program Structure
Discussion

Answer the questions first in your student manual

– In what type of module would you put a routine that moves a part from a fixture to a pallet?
– Why?

– In what type of module would you store the definition of a pallet work object?
– Why?

– If you have a program that is stacking boxes on a pallet and it can only stack 5 boxes on top of each other, would you use variable or persistent
data to keep track of the current amount of stacked boxes?
– Why?

July 1, 2024 Slide 13

You might also like