how to control dc motor with encoder