Motors with integrated controller