Skip to content

Loop Rate Calculator

Run the Loop Rate Calculator MicroSim Fullscreen

You can include this MicroSim on your website using the following iframe:

<iframe src="https://dmccreary.github.io/robot-arm/sims/loop-rate-calculator/main.html"
        height="604px" width="100%" scrolling="no"></iframe>

Description

Set a target rate and the work done in each cycle, and compare the rate that a naive loop and a scheduled loop really achieve. Then calculate six periods and rates yourself. Used in Chapter 11.

The two bars show a few cycles of each loop. Orange is the work (read, decide, write) and blue is the waiting. The dashed marks show when each cycle is due. A naive loop sleeps one whole period after its work, so its cycles drift later and later. A scheduled loop sleeps only for the time that is left, so it stays on the marks until the work no longer fits in the period.

The formulas are from the Chapter 11 sections "The Control Loop" and "Control Rate, Timing Jitter, and Latency". The numbers in the problems are illustrative.

Lesson Plan

Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.

  1. Explore. Start at 50 Hz with 8 ms of work. Read the period and the two rates. Which loop keeps its promise?
  2. Remove the work. Slide the work down to 0 ms, then up 1 ms at a time. When does the naive loop fall below its target?
  3. Break the scheduled loop. Keep 50 Hz and raise the work past 20 ms. What happens to the scheduled rate, and why?
  4. Six problems. Switch to Six problems. Work out each period or rate, type it and press Check. You get one try for each.
  5. Think about it. Why is a faster target rate not always better?

Specification

The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 11: Moving the Arm: Trajectories, Grippers, and Teleoperation.