How is precise control over motor as in Segway achieved?
By using closed-loop motion control and a lot of math.

&quot;...variable speed drill is started it
just accelerates at whatever rate and
actual rotation rate will largely
depend on the load...&quot;

What we need here is something that would regulate the rotation rate for us and eliminate its dependence on foreign load. Something like a government, they are good a regulating things...

A GOVERNOR is a part of a machine by means of which the velocity of the
machine is kept nearly uniform,
notwithstanding variations in the
driving-power or the resistance.
I propose at present, without entering into any details of mechanism
to direct the attention of engineers
and mathematicians to the dynamical
theory of such governors.
- James Clerk Maxwell. On Governors,
Proceedings of Royal Society, vol. 16
(1867–1868)

The motion control systems in a Segway &quot;govern&quot; motor speeds and positions by &quot;closing the loop&quot;.
Open-loop

Closed-loop

One small part of the loop found in a Segway.


More...
The DIY Segway
Introduction to Closed-Loop Control
United States Patent 6302230 : Personal mobility vehicles and methods
United States Patent 6799649 : Control of a balancing personal vehicle