Electric motor with rotary encoder