Slow down the mindstorms EV3 motor so target position is not overshot I have Debian jesse installed on a mindstorms EV3 and I'm using the ev3.lego library: https://github.com/topikachu/python-ev3

I want to be able to slow down the motor as it reaches its target destination because if it's going full speed when it gets there, it overshoots its target proportional to how fast it was going.

Example Python code: When I use this code to spin the motor:

from ev3.lego import Motor
b = Motor(port=Motor.PORT.B)
b.run_position_limited(position_sp = 100, speed_sp = 300)


The motor spins to position 100 on the tachometer with speed of 300.

When it gets to its destination, the momentum carries it to position 125 or so.  So next time I tell it to go to position 100.  It spins up, then overshoots to position 75.  

What is the best way to try to minimize this error so I can tell the motor to move to position 100, and it either slows down before it reaches its target, or otherwise freezes the motor when it reaches the destination?
There are two attributes in the python ev3dev Motor class called:

ramp_down_sp
ramp_up_sp


Link to documentation: http://ddemidov.github.io/ev3dev-lang-python/

ramp_down_sp Ramp Down SP: read/write

Writing sets the ramp down setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 100% duty cycle down to 0 over the span of this setpoint when stopping the motor. If the starting duty cycle is less than 100%, the ramp time duration will be less than the full span of the setpoint.

ramp_up_sp Ramp Up SP: read/write

Writing sets the ramp up setpoint. Reading returns the current value. Units are in milliseconds. When set to a value > 0, the motor will ramp the power sent to the motor from 0 to 100% duty cycle over the span of this setpoint when starting the motor. If the maximum duty cycle is limited by duty_cycle_sp or speed regulation, the actual ramp time duration will be less than the setpoint.

Example:

from ev3.lego import Motor
b = Motor(port=Motor.PORT.B)
b.ramp_up_sp = 1000
b.ramp_down_sp = 1000
b.run_position_limited(position_sp = 0, speed_sp = 300)


What the ramp_down_sp does is when the motor is 1000 milliseconds away from its target (doing its own estimations) then ramp down the power from 100% to 0% over exactly 1000 milliseconds.

ramp_up does a similar thing, except ramps up the power from 0% to 100% over 1000 milliseconds.  

This helps avoid unnecessary strain on the motors for applications where building up momentum is important.