Controlling an exercise machine includes receiving a stream of measurements of extension of a component of an exercise machine. It further includes detecting a first phase of a repeated motion. It further includes detecting a transition to a second phase of the repeated motion. A time constraint is applied to the detection of the transition to the second phase of the repeated motion. It further includes controlling a resistance associated with the second phase of the repeated motion.