I'm fairly new to KUKA programming, so I apologize in advance if my doubts are simple or do not make sense.
Is there some way to use variables within motion commands? I want to make a program that moves in a linear path, stops, goes up and comes back above the same line. What I wrote was:
B=50
FOR A=1 TO 5 STEP 1
B=-B
LIN_REL {X B}
LIN_REL {Z 2}
WAIT SEC 10
ENDFOR
But the program says it expects a constant in the LIN_REL command. Is there any way to make this work? Or another way to make this motion in a simple way? without having to repeat lines over and over?
Can I use variables within motion commands?
-
Tascanis -
January 23, 2023 at 12:26 AM -
Thread is marked as Resolved.
-
-
- Best Answer
motion command accept position values in form of variables, constants and literals.
structure aggregates (identified by curly braces) only accepts literals. i tested it and confirmed (as expected) that constants are rejected as well.
so when the message suggests that constant is expected, that is incorrect - it is just an example of message using sloppy language. the only names allowed in an aggregate are names of the structure elements. that's it.
btw. constants and literals are not the same thing. both constants and variables need to be declared and both have names. and neither of them can be used in your code.
literals are simply hardcoded values such as 50 or 3.14 or "Peter" or TRUE or #T1. but they are just that - values. they do not have suitable name by which they can be referred to, and they do not have declaration statements like constants and variables. every time you use literal, you have to type it in.
And here is the proof. Both var and const are declared and both have same value:
but neither of them are accepted (regardless what message tells):
Solution is to use dot operator to assign value to a single element within structure.
for example
-
Wow perfect, thank you for helping me! I'll test it as soon as possible, because I don't have access to the robot now. If anything goes wrong I'll come back to you, but this looks like it will work!
By the way, since you seem very knowledgeable and I see you here helping people often, do you think you could have a look at my other thread? -
maybe i could if you shared link. i don't approve of vague requests that require effort on my end.
-
if you shared link
How to activate and use mechanical weaving?
Sorry, here it is -
Just fyi, this worked perfectly