Kuka Newbie - KRC4 Counters

  • I am a Kuka newbie who comes from a Fanuc and ABB background. I am familiar with .TP, Rapid, and Karel, but quite new to Kuka KRL. Our Kuka is a KRC4 running, I believe, 8.2 software (the robot is at our remote location, so I cannot verify right now). I want to use an integer for robot tracking. This integer needs to be global. Initially, I found that there are counters in the robot variables. Logged in as expert, I didn't seem to be able to find how to access those counters in KRL. I tried creating a global tag in one of the routines that was an integer. I was able to access that integer in KRL, but could not access it in any other routine (I would get an error if I coded it in the SRC file.


    The manual I have doesn't go into detail the creation and access of global variables. Can anyone tell me what I could be doing wrong?


    Kris

  • Hello Kris,
    If you want to use counter globally, there will be some ways:
    1.Declare your own counter globally:
    (1)In dat file created by your own:GLOBAL INT zCounter=0;(GLOBAL is the key word to make variables globally,otherwise it will be local ones)
    (2)In config.dat file: INT zCounter=0
    2.Use kuka system build-in counters: I[1] TO I[20]


    Hope this could be helpful !



    Regards


    Andrew

  • Easiest way to create a global integer is to do it in the config.dat.


    KRC > R1 > System > $Config.dat in the 'User Globals' fold.


    Here you Declare your variable and initialise with a value, e.g.


    DECL INT MyInteger=0
    (if you don't give it a value you will get an error when you first try and use it).


    Then you can use 'MyInteger' in your .src like:


    If MyInteger=10 Then
    do something
    MyInteger=0
    Else
    MyInteger=MyInteger+1
    Endif

  • Two ways to create a Global variable in KRL, but either way, it requires creating the variable in a .DAT file -- variables created inside an SRC file only have scope inside the subroutine or function in which they were declared.


    The old way is $CONFIG.DAT -- any variable declared in this file is Global, but only needs a DECL


    The newer way allows you to create a Global variable in any .DAT file, using DECL GLOBAL VariableType VariableName.


    Personally, I try to avoid adding variables to $CONFIG.DAT, when I'm writing "portable" code for deployment across multiple robots. Unless two robots have identical Tool and Base definitions (among other settings), copying $CONFIG.DAT between robots is a bad idea.

Advertising from our partners