CONST variables in multiple tasks
Hello,
I have two tasks. Each uses a constant value initialized in task1:
CONST num sizebuffer := 1000;
I need to use this constant value in task2. Problem is, I have to declare sizebuffer in task 2 in order to compile. But the compiler refuse just to initialize the variable without value
CONST num sizebuffer;
Syntax error(135): Expected ':='
If I initialize the sizebuffer in task2
CONST num sizebuffer := 1000;
The program compile. But the value can be different if it is initialized differently in the two tasks! How is it possible to fix that?
Thank you for youtr help,
Tagged:
0
Comments
-
Hi,
constant declarations can only be used in the task in which they are defined, other tasks have no access.
If you want use the data which are defined in another task, you have to declare them as persistent instead of constant.
In the task T_ROB1 you have to define:
PERS num nSizeBuffer:=1000;
And in your task2:
PERS num nSizeBuffer;
In this case only the value of the task T_ROB1 will be used to initialize the persistent.
/BR
Micky
0 -
Hello,Thank you for your answer. I forgot to mention, the variavle sizebuffer is used to specify the size of an array of jointtarget.CONST num sizebuffer := 1000; ! Size of the cyclic bufferPERS jointtarget cyclicbuffer{sizebuffer};RAPID programming does not allow to use non-constant variables to specify the size of an array; using PERS num nSizeBuffer:=1000 thus generate an error. How can I specify the size of an array so that the variable containing the size of the array is only initialized once for multiple tasks^Thank you0
-
Hello,
maybe you can define this constant declaration in a separate module and load it shared via "automatic loading of modules" (sys.cfg) into your memory.
If a module is loaded as shared, all data declarations are available in all tasks.
Best regards
Micky
0 -
I know this is an old Post but did you ever figure a way to do this? I am trying to do the same thing....0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings