RobotStudio event

Clock stops when program execution stops

According to the Rapid instruction manual a clock is supposed to continue running when the program which started it is stopped, and even when the robot is powered down.

On the virtual or real FlexPendant ...

In 'Program EditorDebugPP to Routine' I select ClockShow then start execution. The screen displays the incrementing clock values as expected.

I then stop execution and re-select ClockShow in 'Program EditorDebugPP to Routine', then use 'PP to Cursor' to position the PP to the start of the while loop.

When I start execution, the clock values displayed every 2 seconds are all '0', so the clock must have been stopped and reset.

If I delete the call to ClockStart from ClockShow, then execute ClockStart followed by ClockShow, again all displayed values are '0'.

I want the clock to continue counting while the program is stopped. What am I doing wrong?

[CODE]
MODULE ClockTest

VAR clock MyClock;

PROC ClockStart()
    ClkReset MyClock;
    ClkStart MyClock;
    TPErase;
ENDPROC

PROC ClockShow()
    ClockStart;
    !Displays clock value every 2 seconds
    WHILE TRUE DO
        TPWrite "Time="Num:= ClkRead(MyClock);
        WaitTime 2;
    ENDWHILE
ENDPROC

ENDMODULE
[/CODE]

Thanks,

Kevin


Comments

  • Petjo
    Petjo ✭✭
    I think that if you reset pp the "var" clock loses its value. When you make the first run the clock starts in the "clockstart" routine and everything works as expected, but when you manually set pp to the while loop in ClockShow, MyClock resets and isn't started again. Please correct me if i'm wrong.. I usually put a cycletime clock in my programs as follows, and the clock runs even if program is stopped but the value is lost when resetting pp.

     

          ClkStop cTime;
          TPWrite ""Num:=ClkRead(cTime);
          ClkReset cTime;
          ClkStart cTime;

     

    /Peter
  • Kevin
    Kevin ✭✭
    Thanks for the clarification Peter.

    The manual does not say what happens to the clock when the PP is moved, but the var certainly gets reset.

    It seems that my clock will have to be in a background task if it is to be unaffected by movement of the PP.

    Kevin


  • Not sure if your still trying to figure this out or not, but have you tried making your clock a PERS instead of a VAR?  CONST would not allow it to change, but PERS should keep the data across a PP to main, and possibly a power down.
  • DBrowne
    DBrowne
    edited November 2016
    I'm looking for a solution to this too. I need to be able to time absolutely, regardless of program execution or reset.
    Clocks must be of type VAR (PERS is not allowed). How can I maintain the clock reading when the PP is reset?

    I find this behaviour particularly confusing, as the documentation claims the clock keeps running even when the robot powers off.
    How can this be true? Doesn't the PP not exist at power on?

    A clock continues to run when the robot is powered down as long as the battery back-up retains the program that contains the clock variable.


  • If you run a clock in the Main task it will stop when the program/task stops.  The way I got around this is to put the clock in a background task that's continuously running even when the Main is stopped.  You'll need the multitasking option for this.