I'm working on a motion controller using the mbed platform. The idea is to calculate the theoretical position in the move every x milliseconds and then compare it to the actual position from the encoder, the resulting error of which will be subject to PID.
Currently I call the procedure every x milliseconds by using the delay() function at the end of the position calculation routine.
I feel this may not be the best way of doing this. Is there a lower level way of calling the routine with a fixed time step?