The RMP Motion Controller APIs

Executes a specified number of loops and prints out both the total execution time and the average execution time of each loop.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


📜 Loop Timing Sample App
A sample application that measures the execution time of the specified number of loops.

1global int32 i; // global, so we can watch it increment in RapidSetup
2
3void main()
4{
5 double MAX_LOOPS = 10000;
6 double timestamp = now();
7 int32 fastestLoopIndex;
8 int32 slowestLoopIndex;
9 double previousTime = 0;
10 double currentTime = 0;
11 double totalTime = 0;
12 double averageTime = 0;
13 double currentDelta = 0;
14 double minDelta = 100000000;
15 double maxDelta = 0.0;
16
17 previousTime = now();
18 for(i = 0 ; i < MAX_LOOPS; ++i)
19 {
20 currentTime = now();
21 currentDelta = currentTime - previousTime;
22
23 if(currentDelta < minDelta)
24 {
25 minDelta = currentDelta;
26 fastestLoopIndex = i;
27 }
28 if(currentDelta > maxDelta)
29 {
30 maxDelta = currentDelta;
31 slowestLoopIndex = i;
32 }
33
34 previousTime = currentTime;
35 totalTime += currentDelta;
36 }
37
38 print("Fastest loop is " + minDelta + " ms on loop index " + fastestLoopIndex + ".");
39 print("Slowest loop is " + maxDelta + " ms on loop index " + slowestLoopIndex + ".");
40 averageTime = totalTime / MAX_LOOPS;
41 print("Total time is " + totalTime + " ms for " + MAX_LOOPS + " loops. Average loop time is " + averageTime + " ms.");
42
43}

Learn more in topic page.