The control of a cyclical movement of the lower leg with electrical stimulation of the quadriceps muscles is formulated as an optimal control problem. The time integral of knee torque is taken as the optimisation criterion. As an additional condition, every cycle a certain reference maximum angle should be reached. A model study indicates that one stimulation burst per cycle at the maximum recruitment level is a suboptimal solution to this problem. To compensate for the influence of muscle fatigue, the burst time is adaptively adjusted by a discrete time PID-controller on the basis of the performance in the previous cycles. This strategy appeared to be successful in experimental tests. A considerable time difference (about 0·15 s) was found between the end of the stimulation burst and the tracking of the passive state trajectory, which satisfies the maximum angle condition.