Skip to main content

15.4.17 Clock commands

15.4.17.1 ClkRead

Explanation

It is used to read the value of the clock.

Definition

Return value, data type: double, to return the time interval between the stop time of the clock or the current time and the start of the clock. The accuracy is 0.001s.

ClkRead (Clock);

Clock, data type: clock, name of the clock.

Example

Example 1

VAR clock clock1;
ClkStart(clock1);
ClkStop(clock1);
VAR double interval=ClkRead(clock1);

interval stores the time interval between start and stop of clock1.

15.4.17.2 ClkReset

Explanation

It is used to reset a clock. ClkReset guarantees that the count is 0 before using a clock.

Definition

ClkReset (Clock);

Clock, data type: clock, name of the clock.

Example

Example 1

VAR clock clock1;
ClkReset (clock1);

Reset clock1.

15.4.17.3 ClkStart

Explanation

It is used to start a clock.

When a clock starts, it will continue to count until the clock stops or the program resets. The clock will continue to operate after the program stops or the robot is powered off.

Definition

ClkStart (Clock);

Clock, data type: clock, name of the clock.

Example

Example 1

VAR clock clock1;
ClkStart (clock1);

Declare clock1, and start clock1.

15.4.17.4 ClkStop

Explanation

It is used to stop a clock.

When the clock stops, it stops counting. After the clock stops, it can be read for the interval, restarted, or reset.

Definition

ClkStop (Clock);

Clock, data type: clock, name of the clock.

Example

Example 1

VAR clock clock1;
ClkStart (clock1);
…
ClkStop (clock1);
  // Stop clock1.