Controlling the speed of a DC motor