Counter variable

  • Hello ,

    KSS V4.1.5


    I have defined a counter in .DAT file like this:


    DECL INT usercont=0



    In .SRC file in every cycle between in an endless loop counter add number one to itself:


    usercont=usercont+1


    after every step program check this condition:


    IF $FLAG[1]==true THEN

    usercont=0

    ENDIF


    Everything works well and whenever I want I can reset the counter, but now I need to move this IF condition to SPS.SUB so i think i must define this counter variable as a global variable. I defined it as it was in .DAT file this time in CONFIG.DAT but when i set the $FLAG[1] to TRUE controller can't recognize this variable to reset it.


    Can anybody tell what is the problem?

  • What do you mean by "controller can't recognize this variable to reset it"? Can you change the value of the variable usercont directly from KCP when no robot program is active? If no, then I believe the problem might be as Panic Mode said, or if yes, you put that condition in a wrong place in the submit interpreter.

    Where did you write the IF condition in the sps.sub? It must be written in the loop section (not the initialization section). Everything is run only once at the beginning whenever sps.sub becomes active and then enters the loop.

  • thank you guys,


    problem solved, my mistake was, i had defined this variable in both CONFIG.DAT and .DAT file of my program. although it was exactly the same in both files but controller couldn't recognize it as a global variable.

Advertising from our partners