Added encoder period calculation.